[brlcad-commits] SF.net SVN: brlcad:[44122]
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <dav...@us...> - 2011-03-31 15:48:34
|
Revision: 44122 http://brlcad.svn.sourceforge.net/brlcad/?rev=44122&view=rev Author: davidloman Date: 2011-03-31 15:48:28 +0000 (Thu, 31 Mar 2011) Log Message: ----------- Add/override Load() and Save() as well as make loading and non loading constructors. This must be done in order to preserve filename + path in the MinimalDatabase object. filename and path is required to have so that MinimalObjects generatedd by this MinimalDatabase have all they required information to be transmitted across a network Modified Paths: -------------- rt^3/trunk/include/MinimalDatabase.h rt^3/trunk/src/libge/MinimalDatabase.cxx Modified: rt^3/trunk/include/MinimalDatabase.h =================================================================== --- rt^3/trunk/include/MinimalDatabase.h 2011-03-31 15:43:07 UTC (rev 44121) +++ rt^3/trunk/include/MinimalDatabase.h 2011-03-31 15:48:28 UTC (rev 44122) @@ -38,9 +38,21 @@ namespace BRLCAD { class MinimalDatabase : public MemoryDatabase { public: - MinimalDatabase(void) throw(bad_alloc); + MinimalDatabase() throw(bad_alloc); + MinimalDatabase(std::string filePath) throw(bad_alloc); virtual ~MinimalDatabase(void) throw(); + bool Load(const std::string name) throw() ; + bool Load(const char* name) throw() ; + bool Load() throw() ; + + bool Save(const std::string name) throw() ; + bool Save(const char* name) throw() ; + bool Save() throw() ; + + + std::string getFilePath(); + MinimalObject* getObjectByName(std::string name); std::list<MinimalObject*>* getAllObjectsBelow(std::string name); std::list<MinimalObject*>* getAllObjects(); @@ -49,7 +61,7 @@ private: /// Performs database object look ups, but copies the contents into a bu_external which it returns bu_external* GetExternal(const char* objectName) const; - + std::string currentFilePath; }; } #endif /* __MINIMALDATABASE_H__ */ Modified: rt^3/trunk/src/libge/MinimalDatabase.cxx =================================================================== --- rt^3/trunk/src/libge/MinimalDatabase.cxx 2011-03-31 15:43:07 UTC (rev 44121) +++ rt^3/trunk/src/libge/MinimalDatabase.cxx 2011-03-31 15:48:28 UTC (rev 44122) @@ -36,8 +36,12 @@ using namespace BRLCAD; -MinimalDatabase::MinimalDatabase() throw(bad_alloc) : MemoryDatabase() { +MinimalDatabase::MinimalDatabase() throw(bad_alloc) + : MemoryDatabase(), currentFilePath("") {} +MinimalDatabase::MinimalDatabase(std::string filePath) throw(bad_alloc) + : MemoryDatabase(), currentFilePath(filePath) { + this->Load(); } MinimalDatabase::~MinimalDatabase(void) throw() { @@ -52,7 +56,7 @@ return NULL; } - return NULL; + return new MinimalObject(currentFilePath, name, ext); } std::list<MinimalObject*>* @@ -83,9 +87,6 @@ directory* pDir = db_lookup(m_rtip->rti_dbip, objectName, LOOKUP_NOISE); if (pDir != RT_DIR_NULL) { - //rt_db_internal intern; - //int id = rt_db_get_internal(&intern, pDir, m_rtip->rti_dbip, 0, m_resp); - /* Check to see if passed in ext was malloced */ if (ext == NULL) ext = (bu_external*)bu_calloc(sizeof(bu_external),1,"GetExternal bu_external calloc"); @@ -97,7 +98,6 @@ bu_free(ext, "Freeing bu_external due to error."); return ext; } - // rt_db_free_internal(&intern); } } } @@ -106,7 +106,43 @@ return ext; } +std::string +MinimalDatabase::getFilePath() { + return this->currentFilePath; +} +bool +MinimalDatabase::Load() throw() { + return this->Load(this->currentFilePath); +} + +bool +MinimalDatabase::Load(const std::string name) throw() { + return this->Load(name.c_str()); +} + +bool +MinimalDatabase::Load(const char* name) throw() { + this->currentFilePath = name; + return MemoryDatabase::Load(name); +} + +bool +MinimalDatabase::Save() throw() { + return this->Save(this->currentFilePath); +} + +bool +MinimalDatabase::Save(const std::string name) throw() { + return this->Save(name.c_str()); +} + +bool +MinimalDatabase::Save(const char* name) throw() { + this->currentFilePath = name; + return MemoryDatabase::Save(name); +} + // Local Variables: // tab-width: 8 // mode: C++ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |