From: <mk...@us...> - 2003-08-17 10:50:24
|
Update of /cvsroot/csp/APPLICATIONS/SimData/Include/SimData In directory sc8-pr-cvs1:/tmp/cvs-serv30918/Include/SimData Modified Files: DataArchive.h DataManager.h Path.h Log Message: Index: DataArchive.h =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/SimData/Include/SimData/DataArchive.h,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** DataArchive.h 17 Aug 2003 08:03:45 -0000 1.20 --- DataArchive.h 17 Aug 2003 10:50:21 -0000 1.21 *************** *** 101,107 **** struct TableEntry { /// the object path identifier hash ! hasht pathhash; /// the class identifier hash ! hasht classhash; /// the file offset of the serialized object uint32 offset; --- 101,107 ---- struct TableEntry { /// the object path identifier hash ! ObjectID pathhash; /// the class identifier hash ! ObjectID classhash; /// the file offset of the serialized object uint32 offset; *************** *** 151,167 **** ! typedef HASH_MAPS<hasht, std::vector<hasht>, hasht_hash, hasht_eq>::Type ChildMap; /// A map of all parent-child relationships in the archive. ChildMap _children; ! typedef HASH_MAPS<hasht, std::string, hasht_hash, hasht_eq>::Type PathMap; /// A map for accessing the path string of any object id in the archive. PathMap _pathmap; ! typedef HASH_MAPS<hasht, std::size_t, hasht_hash, hasht_eq>::Type TableMap; /// A map for finding the table index of an object id in the archive. TableMap _table_map; ! typedef HASH_MAPS<hasht, LinkBase, hasht_hash, hasht_eq>::Type CacheMap; /// A map of all cached objects indexed by object id. CacheMap _static_map; --- 151,167 ---- ! typedef HASH_MAPS<ObjectID, std::vector<ObjectID>, ObjectID_hash, ObjectID_eq>::Type ChildMap; /// A map of all parent-child relationships in the archive. ChildMap _children; ! typedef HASH_MAPS<ObjectID, std::string, ObjectID_hash, ObjectID_eq>::Type PathMap; /// A map for accessing the path string of any object id in the archive. PathMap _pathmap; ! typedef HASH_MAPS<ObjectID, std::size_t, ObjectID_hash, ObjectID_eq>::Type TableMap; /// A map for finding the table index of an object id in the archive. TableMap _table_map; ! typedef HASH_MAPS<ObjectID, LinkBase, ObjectID_hash, ObjectID_eq>::Type CacheMap; /// A map of all cached objects indexed by object id. CacheMap _static_map; *************** *** 376,385 **** * @param path the path string of the object */ ! void _addEntry(int offset, int length, hasht hash, std::string const &path); /* Object* getObject(const Object &a, const char* path); ! Object* getObject(const Object &a, hasht path, const char* path=""); ! Object* getObject(hasht path); */ --- 376,385 ---- * @param path the path string of the object */ ! void _addEntry(int offset, int length, ObjectID hash, std::string const &path); /* Object* getObject(const Object &a, const char* path); ! Object* getObject(const Object &a, ObjectID path, const char* path=""); ! Object* getObject(ObjectID path); */ *************** *** 390,394 **** * @param key the object identifier hash (path hash) */ ! void _addStatic(Object* ptr, std::string const &path_str, hasht key=0); /** Get an object from the static object cache. --- 390,394 ---- * @param key the object identifier hash (path hash) */ ! void _addStatic(Object* ptr, std::string const &path_str, ObjectID key=0); /** Get an object from the static object cache. *************** *** 396,400 **** * @returns the object if found, otherwise NULL. */ ! LinkBase const * _getStatic(hasht key); /** Create an a new instance using a class identifier hash. --- 396,400 ---- * @returns the object if found, otherwise NULL. */ ! LinkBase const * _getStatic(ObjectID key); /** Create an a new instance using a class identifier hash. *************** *** 403,407 **** * @returns the newly created object. */ ! Object* _createObject(hasht classhash); /** Find the table entry corresponding to a given object path. --- 403,407 ---- * @returns the newly created object. */ ! Object* _createObject(ObjectID classhash); /** Find the table entry corresponding to a given object path. *************** *** 421,426 **** const TableEntry* _lookupPath(ObjectID const &id, std::string const &path_str="") const; private: ! void setManager(DataManager *m) { _manager = m; } ChildMap const &getChildMap() const { return _children; } }; --- 421,432 ---- const TableEntry* _lookupPath(ObjectID const &id, std::string const &path_str="") const; + /** Get the associated data manager instance, if any. + */ + DataManager *getManager() const { return _manager; } + private: ! /** Called by DataManager to bind the archive. ! */ ! void setManager(DataManager *m); ChildMap const &getChildMap() const { return _children; } }; Index: DataManager.h =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/SimData/Include/SimData/DataManager.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** DataManager.h 16 Aug 2003 10:29:43 -0000 1.10 --- DataManager.h 17 Aug 2003 10:50:21 -0000 1.11 *************** *** 1,4 **** /* SimData: Data Infrastructure for Simulations ! * Copyright (C) 2002 Mark Rose <tm...@st...> * * This file is part of SimData. --- 1,4 ---- /* SimData: Data Infrastructure for Simulations ! * Copyright (C) 2002, 2003 Mark Rose <tm...@st...> * * This file is part of SimData. *************** *** 28,34 **** #include <SimData/Export.h> #include <SimData/Path.h> #include <SimData/HashUtility.h> ! #include <SimData/Namespace.h> #include <string> --- 28,35 ---- #include <SimData/Export.h> + #include <SimData/Namespace.h> #include <SimData/Path.h> #include <SimData/HashUtility.h> ! #include <SimData/Ref.h> #include <string> *************** *** 47,54 **** ! /** ! * @brief Class for managing read access to multiple data archives. * ! * @author Mark Rose <mr...@st...> */ class SIMDATA_EXPORT DataManager { --- 48,54 ---- ! /** Class for managing read access to multiple data archives. * ! * @author Mark Rose <mr...@st...> */ class SIMDATA_EXPORT DataManager { *************** *** 56,201 **** public: ! /** ! * Construct a new (empty) data manager. */ DataManager(); ! /** ! * Destroy the data manager and all the archives it contains. */ virtual ~DataManager(); ! /** ! * Create a new object from a path identifier string. * ! * @param path_str the path identifier string. ! * @returns a smart-pointer to the new object. */ const LinkBase getObject(std::string const &path_str); ! /** ! * Create a new object from a Path instance. * ! * @param path the Path instance. ! * @param path_str the path identifier string (if available). This is ! * only used for error logging. */ const LinkBase getObject(Path const& path, std::string const &path_str=""); ! /** ! * Add a new data archive to the manager. * ! * All objects in the archive will subsequently be available from the ! * manager. The manager "owns" the pointer and will delete it when the ! * manager is destroyed. */ void addArchive(DataArchive *); ! /** ! * 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(). * ! * @param id the object id to search for children ! * @returns a list of object id's immediately below the given path. */ std::vector<ObjectID> getChildren(ObjectID const &id) 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(). * ! * @param path the path to search for children ! * @returns a list of object id's immediately below the given path. */ std::vector<ObjectID> getChildren(std::string const & path) const; ! /** ! * Check for the existance of an object in the archives. * ! * @returns true if the object id exists. */ bool hasObject(ObjectID const &id) const; ! /** ! * Check for the existance of an object in the archives. * ! * @returns true if the object id exists. */ bool hasObject(std::string const & path) 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. */ std::string getPathString(ObjectID const &id) const; ! /** ! * Remove unused static objects from the cache. * ! * Call this method after many objects have been deleted ! * to free any unused cache entries. */ void cleanStatic(); ! /** ! * Return the interface proxy corresponding to the specified ! * object in the archive. */ InterfaceProxy *getObjectInterface(ObjectID const &id) const; ! /** ! * Return the interface proxy corresponding to the specified ! * object in the archive. */ InterfaceProxy *getObjectInterface(std::string const &path) const; private: ! /** ! * Find the archive that holds the specified object. * ! * Throws an exception if the object isn't found. */ DataArchive *findArchive(ObjectID const &id, std::string const &path_str, DataArchive const *d) const; ! /** ! * Create a new object from a Path instance. * ! * For internal use by the DataArchive class. When a particular ! * DataArchive class fails to find an object, it asks the associated ! * Manager to create the object. The last parameter is used to ! * prevent unwanted recursion if an object isn't found. * ! * @param path the Path instance. ! * @param path_str the path identifier string (if available). This is ! * only used for error logging. ! * @param d the data archive that is requesting the object. */ const LinkBase getObject(Path const& path, std::string const &path_str, DataArchive const *d) const; ! /** ! * Return the interface proxy corresponding to the specified ! * object in the archive. * ! * For internal use by the DataArchive class. When a particular ! * DataArchive class fails to find an object, it asks the associated ! * Manager to create the object. The last parameter is used to ! * prevent unwanted recursion if an object isn't found. */ InterfaceProxy *getObjectInterface(ObjectID const &id, std::string const &path_str, DataArchive const *d) const; ! std::vector<DataArchive*> _archives; ! hasht_map _archive_map; ! typedef HASH_MAPS<hasht, std::vector<hasht>, hasht_hash, hasht_eq>::Type child_map; ! child_map _children; }; --- 56,194 ---- public: ! /** Construct a new (empty) data manager. */ DataManager(); ! /** Destroy the data manager and all the archives it contains. */ virtual ~DataManager(); ! /** Create a new object from a path identifier string. * ! * @param path_str the path identifier string. ! * @returns a smart-pointer to the new object. */ const LinkBase getObject(std::string const &path_str); ! /** Create a new object from a Path instance. * ! * @param path the Path instance. ! * @param path_str the path identifier string (if available). This is ! * only used for error logging. */ const LinkBase getObject(Path const& path, std::string const &path_str=""); ! /** Add a new data archive to the manager. * ! * All objects in the archive will subsequently be available from the ! * manager. The manager "owns" the pointer and will delete it when the ! * manager is destroyed. */ void addArchive(DataArchive *); ! /** 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(). * ! * @param id the object id to search for children ! * @returns a list of object id's immediately below the given path. */ std::vector<ObjectID> getChildren(ObjectID const &id) 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(). * ! * @param path the path to search for children ! * @returns a list of object id's immediately below the given path. */ std::vector<ObjectID> getChildren(std::string const & path) const; ! /** Check for the existance of an object in the archives. * ! * @returns true if the object id exists. */ bool hasObject(ObjectID const &id) const; ! /** Check for the existance of an object in the archives. * ! * @returns true if the object id exists. */ bool hasObject(std::string const & path) 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. */ std::string getPathString(ObjectID const &id) const; ! /** Remove unused static objects from the cache. * ! * Call this method after many objects have been deleted ! * to free any unused cache entries. */ void cleanStatic(); ! /** Return the interface proxy corresponding to the specified ! * object in the archive. */ InterfaceProxy *getObjectInterface(ObjectID const &id) const; ! /** Return the interface proxy corresponding to the specified ! * object in the archive. */ InterfaceProxy *getObjectInterface(std::string const &path) const; + /** Close all managed archives. + */ + void closeAll(); private: ! /** Find the archive that holds the specified object. * ! * Throws an exception if the object isn't found. */ DataArchive *findArchive(ObjectID const &id, std::string const &path_str, DataArchive const *d) const; ! /** Create a new object from a Path instance. * ! * For internal use by the DataArchive class. When a particular ! * DataArchive class fails to find an object, it asks the associated ! * Manager to create the object. The last parameter is used to ! * prevent unwanted recursion if an object isn't found. * ! * @param path the Path instance. ! * @param path_str the path identifier string (if available). This is ! * only used for error logging. ! * @param d the data archive that is requesting the object. */ const LinkBase getObject(Path const& path, std::string const &path_str, DataArchive const *d) const; ! /** Return the interface proxy corresponding to the specified ! * object in the archive. * ! * For internal use by the DataArchive class. When a particular ! * DataArchive class fails to find an object, it asks the associated ! * Manager to create the object. The last parameter is used to ! * prevent unwanted recursion if an object isn't found. */ InterfaceProxy *getObjectInterface(ObjectID const &id, std::string const &path_str, DataArchive const *d) const; ! typedef std::vector<DataArchive *> Archives; ! /// The collection of managed archives. ! Archives _archives; ! typedef HASH_MAPS<ObjectID, std::size_t, ObjectID_hash, ObjectID_eq>::Type ArchiveMap; ! /// A map for finding the index of an archive. ! ArchiveMap _archive_map; ! ! typedef HASH_MAPS<ObjectID, std::vector<hasht>, ObjectID_hash, ObjectID_eq>::Type ChildMap; ! /// A map of all parent-child relationships in the managed archives. ! ChildMap _children; }; Index: Path.h =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/SimData/Include/SimData/Path.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Path.h 15 Aug 2003 01:17:06 -0000 1.13 --- Path.h 17 Aug 2003 10:50:21 -0000 1.14 *************** *** 53,56 **** --- 53,58 ---- typedef hasht ObjectID; + typedef hasht_eq ObjectID_eq; + typedef hasht_hash ObjectID_hash; |