Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

zeitgeist::FileServer Class Reference

FileServer - the global interface for file system access. More...

#include <fileserver.h>

Inheritance diagram for zeitgeist::FileServer:

Inheritance graph
[legend]
Collaboration diagram for zeitgeist::FileServer:

Collaboration graph
[legend]
List of all members.

Public Types

typedef int THandle

Public Member Functions

 FileServer ()
 constructs the fileserver
 ~FileServer ()
boost::shared_ptr< salt::RFileOpen (const std::string &inName)
 searchs each registered file system for a file with this name.
THandle Register (const std::string &inName)
 tries to open the requested file and registers it.
boost::shared_ptr< salt::RFileGet (THandle handle) const
 returns the file corresponding to the given handle.
void Close (THandle handle)
 closes the file corresponding to the given handle
bool Exist (const std::string &inName)
 returns true if the file 'inName' exists.
bool Mount (const std::string &inFileSysName, const std::string &inPath)
 registers a filesystem to the fileserver.
bool Unmount (const std::string &inPath)
 unmounts a file system at the mount point inPath.
bool Unmount (const std::string &inClass, const std::string &inPath)
 unmounts a file system at the mount point inPath.
int ForEachFile (const std::string &directory, const std::string &name, const std::string &extension, FileSystem::TCallback callback, void *param)
 iterates through files.

Protected Types

typedef std::map< THandle,
boost::shared_ptr< salt::RFile > > 
TFileMap

Protected Member Functions

virtual void OnUnlink ()
 This rountine is called, before the FileServer hierarchy object is removed from the parent.

Protected Attributes

TFileMap mFileMap
 registry of opened files using the handle base system
THandle mNextHandle
 the next free handle

Private Member Functions

 FileServer (const FileServer &)
FileServeroperator= (const FileServer &)

Detailed Description

FileServer - the global interface for file system access.

What the FileServer does:

The file server is an extremely useful subsystem, since it allows to access various implemented file systems. The regular file system is a standard directory-based implementation. The ZIP file system can load files from within ZIP-files. Before actually being able to open files, the FileServer is initialized with several FileSystems, which are associated with different paths. For each path, you have to pass in a file system. Now, when trying to open a file, each registered file system is asked to open the file. Filesystems are searched in the inverse order in wich they were registered- think of a filesystem stack. The first succesful opened file wins. This allows for some nice effects. File systems are associated with id strings like 'STD' or 'ZIP'.

Definition at line 81 of file fileserver.h.


Member Typedef Documentation

typedef std::map<THandle, boost::shared_ptr<salt::RFile> > zeitgeist::FileServer::TFileMap [protected]
 

Definition at line 90 of file fileserver.h.

typedef int zeitgeist::FileServer::THandle
 

Definition at line 87 of file fileserver.h.


Constructor & Destructor Documentation

FileServer::FileServer  ) 
 

constructs the fileserver

Definition at line 32 of file fileserver.cpp.

FileServer::~FileServer  ) 
 

Definition at line 36 of file fileserver.cpp.

zeitgeist::FileServer::FileServer const FileServer  )  [private]
 


Member Function Documentation

void FileServer::Close THandle  handle  ) 
 

closes the file corresponding to the given handle

Definition at line 96 of file fileserver.cpp.

References zeitgeist::Object::GetLog(), mFileMap, and mNextHandle.

Here is the call graph for this function:

bool zeitgeist::FileServer::Exist const std::string &  inName  ) 
 

returns true if the file 'inName' exists.

int zeitgeist::FileServer::ForEachFile const std::string &  directory,
const std::string &  name,
const std::string &  extension,
FileSystem::TCallback  callback,
void *  param
 

iterates through files.

'directory', 'name' and 'extension' give directory, name and extension a file must match. directory,name and extension may be NULL, in wich case every directory,extension and/or name matches. For each match the function callback is called with the name of the matched file and the additional user parameter 'param'. param is just passed through to the callback and has no meaning to the filesystem.

shared_ptr< salt::RFile > FileServer::Get THandle  handle  )  const
 

returns the file corresponding to the given handle.

Definition at line 81 of file fileserver.cpp.

References zeitgeist::Object::GetLog(), and mFileMap.

Here is the call graph for this function:

bool zeitgeist::FileServer::Mount const std::string &  inFileSysName,
const std::string &  inPath
 

registers a filesystem to the fileserver.

A file system may be registered only once, on each further try nothing is done and false returned

Parameters:
inFileSysName is the class name of the File system
inPath is the mount point in the virtual file system provided by the fileserver

void FileServer::OnUnlink  )  [protected, virtual]
 

This rountine is called, before the FileServer hierarchy object is removed from the parent.

Reimplemented from zeitgeist::Leaf.

Definition at line 117 of file fileserver.cpp.

References zeitgeist::Object::GetLog(), and mFileMap.

Here is the call graph for this function:

boost::shared_ptr<salt::RFile> zeitgeist::FileServer::Open const std::string &  inName  ) 
 

searchs each registered file system for a file with this name.

Filesystems are searched in the inverse order in which they are registered to the fileserve, i.e. a filesystem stack. The first succesful opened file is returned.

FileServer& zeitgeist::FileServer::operator= const FileServer  )  [private]
 

THandle zeitgeist::FileServer::Register const std::string &  inName  ) 
 

tries to open the requested file and registers it.

On success it returns a non 0 handle assiociated with the file object.

bool zeitgeist::FileServer::Unmount const std::string &  inClass,
const std::string &  inPath
 

unmounts a file system at the mount point inPath.

Returns true on success.

bool zeitgeist::FileServer::Unmount const std::string &  inPath  ) 
 

unmounts a file system at the mount point inPath.

if no file system id is given, for a first try FileSystemSTD is assumed, then the type is ignored. Returns true on success.


Member Data Documentation

TFileMap zeitgeist::FileServer::mFileMap [protected]
 

registry of opened files using the handle base system

Definition at line 167 of file fileserver.h.

Referenced by Close(), Get(), and OnUnlink().

THandle zeitgeist::FileServer::mNextHandle [protected]
 

the next free handle

Definition at line 170 of file fileserver.h.

Referenced by Close().


The documentation for this class was generated from the following files:
Generated on Thu Apr 6 15:50:08 2006 for rcssserver3d by  doxygen 1.4.4