00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __DAE_DATABASE__
00010 #define __DAE_DATABASE__
00011
00012 #include <memory>
00013 #include <vector>
00014 #include <dae.h>
00015 #include <dae/daeTypes.h>
00016 #include <dae/daeElement.h>
00017 #include <dae/daeURI.h>
00018 #include <dae/daeDocument.h>
00019
00020
00024 class DLLSPEC daeDatabase
00025 {
00026 public:
00030 daeDatabase(DAE& dae);
00031
00035 virtual ~daeDatabase() {}
00036
00041 virtual DAE* getDAE();
00042
00054 virtual daeInt insertDocument(daeString name, daeElement* dom, daeDocument** document = NULL, bool zaeRootDocument = false, const std::string& extractedFileURI = "") = 0;
00062 virtual daeInt insertDocument(daeString name, daeDocument** document = NULL) = 0;
00073 virtual daeInt createDocument(daeString name, daeElement* dom, daeDocument** document = NULL, bool zaeRootDocument = false, const std::string& extractedFileURI = "") = 0;
00080 virtual daeInt createDocument(daeString name, daeDocument** document = NULL) = 0;
00081
00087 virtual daeInt insertDocument( daeDocument *c ) = 0;
00088
00094 virtual daeInt removeDocument(daeDocument* document) = 0;
00099 virtual daeUInt getDocumentCount() = 0;
00105 virtual daeDocument* getDocument(daeUInt index) = 0;
00111 daeDocument* getDoc(daeUInt index);
00120 virtual daeDocument* getDocument(daeString name, bool skipUriNormalization = false) = 0;
00126 virtual daeString getDocumentName(daeUInt index) = 0;
00133 virtual daeBool isDocumentLoaded(daeString name) = 0;
00134
00141 virtual daeInt insertElement(daeDocument* document,
00142 daeElement* element) = 0;
00149 virtual daeInt removeElement(daeDocument* document,
00150 daeElement* element) = 0;
00160 virtual daeInt changeElementID(daeElement* element,
00161 daeString newID) = 0;
00162
00173 virtual daeInt changeElementSID(daeElement* element,
00174 daeString newSID) = 0;
00175
00182 virtual daeInt clear() = 0;
00183
00189 virtual std::vector<daeElement*> idLookup(const std::string& id) = 0;
00190
00197 daeElement* idLookup(const std::string& id, daeDocument* doc);
00198
00205 std::vector<daeElement*> typeLookup(daeInt typeID, daeDocument* doc = NULL);
00206
00214 virtual void typeLookup(daeInt typeID,
00215 std::vector<daeElement*>& matchingElements,
00216 daeDocument* doc = NULL) = 0;
00217
00223 template<typename T>
00224 std::vector<T*> typeLookup(daeDocument* doc = NULL) {
00225 std::vector<T*> result;
00226 typeLookup(result, doc);
00227 return result;
00228 }
00229
00236 template<typename T> void
00237 typeLookup(std::vector<T*>& matchingElements, daeDocument* doc = NULL) {
00238 std::vector<daeElement*> elts;
00239 typeLookup(T::ID(), elts, doc);
00240 matchingElements.clear();
00241 matchingElements.reserve(elts.size());
00242 for (size_t i = 0; i < elts.size(); i++)
00243 matchingElements.push_back((T*)elts[i]);
00244 }
00245
00253 std::vector<daeElement*> sidLookup(const std::string& sid, daeDocument* doc = NULL);
00254
00263 virtual void sidLookup(const std::string& sid,
00264 std::vector<daeElement*>& matchingElements,
00265 daeDocument* doc = NULL) = 0;
00266
00276 virtual daeInt setMeta(daeMetaElement *_topMeta) = 0;
00277
00278 public:
00279
00280
00281
00282 virtual daeUInt getTypeCount() = 0;
00283 virtual daeString getTypeName(daeUInt index) = 0;
00284
00285
00286 virtual daeUInt getElementCount(daeString name = NULL,
00287 daeString type = NULL,
00288 daeString file = NULL) = 0;
00289 virtual daeInt getElement(daeElement** pElement,
00290 daeInt index,
00291 daeString name = NULL,
00292 daeString type = NULL,
00293 daeString file = NULL ) = 0;
00294
00295 inline daeInt insertCollection(daeString name, daeElement* dom, daeDocument** document = NULL) {
00296 return insertDocument( name, dom, document );
00297 }
00298 inline daeInt insertCollection(daeString name, daeDocument** document = NULL) {
00299 return insertDocument( name, document );
00300 }
00301 inline daeInt createCollection(daeString name, daeElement* dom, daeDocument** document = NULL) {
00302 return createDocument( name, dom, document );
00303 }
00304 inline daeInt createCollection(daeString name, daeDocument** document = NULL) {
00305 return createDocument( name, document );
00306 }
00307 inline daeInt insertCollection( daeDocument *c ) {
00308 return insertDocument( c );
00309 }
00310 inline daeInt removeCollection(daeDocument* document) {
00311 return removeDocument( document );
00312 }
00313 inline daeUInt getCollectionCount() {
00314 return getDocumentCount();
00315 }
00316 inline daeDocument* getCollection(daeUInt index) {
00317 return getDocument( index );
00318 }
00319 inline daeDocument* getCollection(daeString name) {
00320 return getDocument( name );
00321 }
00322 inline daeString getCollectionName(daeUInt index) {
00323 return getDocumentName( index );
00324 }
00325 inline daeBool isCollectionLoaded(daeString name) {
00326 return isDocumentLoaded( name );
00327 }
00328
00329 protected:
00330 DAE& dae;
00331 };
00332
00333 #endif //__DAE_DATABASE__
00334