Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   Namespace Members   Compound Members  

PLMResFinder Class Reference

Resource finder. More...

#include <PLMResFinder.hpp>

List of all members.

Public Methods

 PLMResFinder ()
bool AddSource (const char *name, bool first=false)
bool RemoveSource (const char *name)
PLMResFileFindRes (const char *name) const
void PrintInfo () const


Detailed Description

Resource finder.

This object is meant to help resource managers to find their files from many sources. A source is a file provider, a PLMFileProvider implementation like PLMDir (for standard directories) or PLMArchive (for archive files).

How to use it:

  • add new sources with AddSource(), a source can be a directory or a PLM archive file. Simpy give its filename.
  • add sources in the order you want them to be checked.
  • when a resource is loaded, FindRes() looks for it in the first source of the list, then in the following sources until one of them returns a valid PLMResFile.
  • you can also remove sources when they are not available anymore, (like a CD-ROM for example).


Constructor & Destructor Documentation

PLMResFinder::PLMResFinder  
 

Create a resource finder (no source).


Member Function Documentation

bool PLMResFinder::AddSource const char *    name,
bool    first = false
 

Add a new source (provider) to search for resources.

The type of source depends on the name's target: a directory will add a PLMDir object, and an archive filename will add a PLMArchive object.

If first is true, the new provider is added at the beginning of the list, otherwise at the end. This order is important since FindRes() will search resources in the order in which sources were added.

Returns:
true on success, false on error (bad path, bad archive, ...).

bool PLMResFinder::RemoveSource const char *    name
 

Remove one source from the list of providers.

Return true on success, false if not found.

PLMResFile* PLMResFinder::FindRes const char *    name const
 

Ask all sources for a resource with the given name.

Return the first matching resource found, or NULL on failure. Important: the resource file returned must be deleted after use. The order in which sources are added does matter, since they are checked in that order.

void PLMResFinder::PrintInfo  
 

Print debug info about current state (list of sources).


The documentation for this class was generated from the following file:
  • PLMResFinder.hpp

Generated by Doxygen 1.2.18 on Tue Oct 26 12:07:44 2004.