Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

DataArchive Class Reference

Interface for reading and writing data archive files. More...

#include <DataArchive.h>

List of all members.

Public Methods

 DataArchive (std::string const &fn, bool read, bool chain=true)
 Open a new data archive.

 ~DataArchive ()
 Close the data archive and cleanup.

void addObject (Object &object, std::string const &path)
 Add an object to the archive.

void finalize ()
 Write the entry table and close the data archive.

bool isFinalized ()
 Test if the data archive has been finalized.

bool isWrite ()
 Test if the archive is in read or write mode.

void setDefault ()
 Make this archive the "default" archive.

const LinkBase getObject (std::string const &path_str)
 Create a new object from a path identifier string.

const LinkBase getObject (const Path &path, std::string const &path_str="")
 Create a new object from a Path instance.

std::string getFileName () const
 Get the full path of the archive file.

std::vector< ObjectIDgetChildren (ObjectID const &id) const
 Get all children of a given object id.

std::vector< ObjectIDgetChildren (std::string const &path) const
 Get all children of a given path.

bool hasObject (ObjectID const &id) const
 Check for the existance of an object in the archive.

bool hasObject (std::string const &path) const
 Check for the existance of an object in the archive.

std::string getPathString (ObjectID const &id) const
 Get the path string corresponding to a give object id.

std::vector< ObjectIDgetAllObjects () const
 Get a list of all objects in the archive.

std::vector< std::string > getAllPathStrings () const
 Get a list of all object paths in the archive.

void cleanStatic ()
 Remove unused static objects from the cache.

InterfaceProxygetObjectInterface (ObjectID const &id, std::string const &path="") const
 Return the interface proxy corresponding to the specified object in the archive.

InterfaceProxygetObjectInterface (std::string const &path) const
 Return the interface proxy corresponding to the specified object in the archive.

void dump () const
 Dump arhcive information to stdout (for debugging).


Static Public Methods

DataArchive * getDefault ()
 Get the current default archive.


Protected Methods

void _addEntry (int offset, int length, ObjectID hash, std::string const &path)
 Add a new entry to the object table.

void _addStatic (Object *ptr, std::string const &path_str, ObjectID key=0)
 Add an object to the static object cache.

LinkBase const * _getStatic (ObjectID key)
 Get an object from the static object cache.

Object_createObject (ObjectID classhash)
 Create an a new instance using a class identifier hash.

const TableEntry * _lookupPath (Path const &path, std::string const &path_str="") const
 Find the table entry corresponding to a given object path.

const TableEntry * _lookupPath (ObjectID const &id, std::string const &path_str="") const
 Find the table entry corresponding to a given object.

DataManagergetManager () const
 Get the associated data manager instance, if any.


Friends

class LinkBase
class DataManager


Detailed Description

Interface for reading and writing data archive files.

The DataArchive class provides read and write access to data archive files. Write mode is primarily intended for use by the data complier. In read mode, objects can be created dynamically from their path strings, with all external data loaded and linked objects created transparently. Static objects are cached internally. All created objects are returned via smart-pointers.

Author:
Mark Rose <mrose@stm.lbl.gov>


Constructor & Destructor Documentation

DataArchive::DataArchive std::string const &    fn,
bool    read,
bool    chain = true
 

Open a new data archive.

Parameters:
fn  the full path to the archive file
read  true for read mode, false for write mode.
chain  this is for internal use only.

DataArchive::~DataArchive  
 

Close the data archive and cleanup.


Member Function Documentation

void DataArchive::_addEntry int    offset,
int    length,
ObjectID    hash,
std::string const &    path
[protected]
 

Add a new entry to the object table.

Parameters:
offset  the byte offset of the start of the object data
length  the number of bytes in the serialized object
hash  the class hash identifier
path  the path string of the object

void DataArchive::_addStatic Object   ptr,
std::string const &    path_str,
ObjectID    key = 0
[protected]
 

Add an object to the static object cache.

Parameters:
ptr  the object to cache
path_str  the path identifier string
key  the object identifier hash (path hash)

Object * DataArchive::_createObject ObjectID    classhash [protected]
 

Create an a new instance using a class identifier hash.

Parameters:
classhash  the identifier hash of the class to create.
Returns:
the newly created object.

LinkBase const * DataArchive::_getStatic ObjectID    key [protected]
 

Get an object from the static object cache.

Returns:
the object if found, otherwise NULL.

const DataArchive::TableEntry * DataArchive::_lookupPath ObjectID const &    id,
std::string const &    path_str = ""
const [protected]
 

Find the table entry corresponding to a given object.

Parameters:
id  the object id to lookup
path_str  the path string, if available (only used for error logging).

const DataArchive::TableEntry * DataArchive::_lookupPath Path const &    path,
std::string const &    path_str = ""
const [protected]
 

Find the table entry corresponding to a given object path.

Parameters:
path  the path to lookup
path_str  the path string, if available (only used for error logging).

void DataArchive::addObject Object   object,
std::string const &    path
 

Add an object to the archive.

Parameters:
object  the object to add.
path  the path string of the object

void DataArchive::cleanStatic  
 

Remove unused static objects from the cache.

Call this method after many objects have been deleted to free any unused cache entries.

void DataArchive::dump  
 

Dump arhcive information to stdout (for debugging).

void DataArchive::finalize  
 

Write the entry table and close the data archive.

This should only be called after writing objects to a data archive. Do not call this in read mode.

std::vector< ObjectID > DataArchive::getAllObjects  
 

Get a list of all objects in the archive.

std::vector< std::string > DataArchive::getAllPathStrings  
 

Get a list of all object paths in the archive.

std::vector< ObjectID > DataArchive::getChildren std::string const &    path const
 

Get all children of a given path.

For path "A:X.Y", returns all object id's "A:X.Y.*". The id's can be converted to human-readable form by getPathString().

Parameters:
path  the path to search for children
Returns:
a list of object id's immediately below the given path.

std::vector< ObjectID > DataArchive::getChildren ObjectID const &    id const
 

Get all children of a given object id.

For id "A:X.Y", returns all object id's "A:X.Y.*". The id's can be converted to human-readable form by getPathString().

Parameters:
id  the object id to search for children
Returns:
a list of object id's immediately below the given path.

DataArchive * DataArchive::getDefault   [static]
 

Get the current default archive.

Returns:
the current default or NULL if there is none.
Deprecated:
Use of this default utility is not recommended.

std::string DataArchive::getFileName   const [inline]
 

Get the full path of the archive file.

Returns:
the full path of the archive file.

DataManager* DataArchive::getManager   const [inline, protected]
 

Get the associated data manager instance, if any.

const LinkBase DataArchive::getObject const Path   path,
std::string const &    path_str = ""
 

Create a new object from a Path instance.

Parameters:
path  the Path instance.
path_str  The path identifier string (if available). This is only used for error logging.

const LinkBase DataArchive::getObject std::string const &    path_str
 

Create a new object from a path identifier string.

Parameters:
path_str  The path identifier string.
Returns:
A smart-pointer to the new object.

InterfaceProxy * DataArchive::getObjectInterface std::string const &    path const
 

Return the interface proxy corresponding to the specified object in the archive.

InterfaceProxy * DataArchive::getObjectInterface ObjectID const &    id,
std::string const &    path = ""
const
 

Return the interface proxy corresponding to the specified object in the archive.

std::string DataArchive::getPathString ObjectID const &    id const
 

Get the path string corresponding to a give object id.

This provides a human-readable path string that is useful for error and debugging messages.

Returns:
the path string if found, otherwise an empty string.

bool DataArchive::hasObject std::string const &    path const
 

Check for the existance of an object in the archive.

Returns:
true if the object id exists.

bool DataArchive::hasObject ObjectID const &    id const
 

Check for the existance of an object in the archive.

Returns:
true if the object id exists.

bool DataArchive::isFinalized  
 

Test if the data archive has been finalized.

Returns:
true if the archive is finalized.

bool DataArchive::isWrite  
 

Test if the archive is in read or write mode.

Returns:
true if in write mode.

void DataArchive::setDefault  
 

Make this archive the "default" archive.

It will remain so until another archive is assigned or it is deleted (in which case the dafault reverts to NULL).

Deprecated:
Use of this default utility is not recommended.


Friends And Related Function Documentation

friend class DataManager [friend]
 

friend class LinkBase [friend]
 


The documentation for this class was generated from the following files:
SimData version pre-0.4.0. For more information on SimData, visit the SimData Homepage.

Generated on Tue Oct 14 12:06:40 2003, using Doxygen 1.2.18.

[SF.net]