daeSTLDatabase.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Copyright 2006 Sony Computer Entertainment Inc.
  3. *
  4. * Licensed under the MIT Open Source License, for details please see license.txt or the website
  5. * http://www.opensource.org/licenses/mit-license.php
  6. *
  7. */
  8. #ifndef __DAE_STLDATABASE__
  9. #define __DAE_STLDATABASE__
  10. #include <stdio.h>
  11. #include <vector>
  12. #include <map>
  13. #include <string>
  14. #include <algorithm>
  15. #include <functional>
  16. #include <dae/daeElement.h>
  17. #include <dae/daeDatabase.h>
  18. /**
  19. * The @c daeSTLDatabase class derives from @c daeDatabase and implements
  20. * the default database.
  21. */
  22. class DLLSPEC daeSTLDatabase : public daeDatabase
  23. {
  24. public:
  25. /**
  26. * Constructor
  27. */
  28. daeSTLDatabase(DAE& dae);
  29. /**
  30. * Destructor
  31. */
  32. virtual ~daeSTLDatabase();
  33. public:
  34. // Element Types of all Elements
  35. virtual daeUInt getTypeCount();
  36. virtual daeString getTypeName(daeUInt index);
  37. virtual daeInt setMeta(daeMetaElement *_topMeta);
  38. // Documents
  39. virtual daeInt insertDocument(daeString name, daeElement* dom, daeDocument** document = NULL, bool zaeRootDocument = false, const std::string& extractedFileURI = "");
  40. virtual daeInt insertDocument(daeString name, daeDocument** document = NULL);
  41. virtual daeInt createDocument(daeString name, daeElement* dom, daeDocument** document = NULL, bool zaeRootDocument = false, const std::string& extractedFileURI = "");
  42. virtual daeInt createDocument(daeString name, daeDocument** document = NULL);
  43. virtual daeInt insertDocument( daeDocument *c );
  44. virtual daeInt removeDocument(daeDocument* document);
  45. virtual daeUInt getDocumentCount();
  46. virtual daeDocument* getDocument(daeUInt index);
  47. virtual daeDocument* getDocument(daeString name, bool skipUriNormalization = false);
  48. virtual daeString getDocumentName(daeUInt index);
  49. virtual daeBool isDocumentLoaded(daeString name);
  50. // Elements
  51. virtual daeInt insertElement(daeDocument* document, daeElement* element);
  52. virtual daeInt removeElement(daeDocument* document, daeElement* element);
  53. virtual daeInt changeElementID(daeElement* element, daeString newID);
  54. virtual daeInt changeElementSID(daeElement* element, daeString newSID); // Not implemented
  55. virtual daeInt clear();
  56. virtual std::vector<daeElement*> idLookup(const std::string& id);
  57. virtual void typeLookup(daeInt typeID,
  58. std::vector<daeElement*>& matchingElements,
  59. daeDocument* doc = NULL);
  60. // Currently not implemented, but you can uncomment some code in daeSTLDatabase.cpp to get
  61. // it working.
  62. virtual void sidLookup(const std::string& sid,
  63. std::vector<daeElement*>& matchingElements,
  64. daeDocument* doc = NULL);
  65. // Deprecated. Don't use these. Use idLookup or typeLookup instead.
  66. virtual daeUInt getElementCount(daeString name = NULL,
  67. daeString type = NULL,
  68. daeString file = NULL);
  69. virtual daeInt getElement(daeElement** pElement,
  70. daeInt index,
  71. daeString name = NULL,
  72. daeString type = NULL,
  73. daeString file = NULL);
  74. private:
  75. std::map< std::string, std::vector< daeElement* > > elements; // type name --> element lookup table (deprecated)
  76. std::multimap<daeInt, daeElement*> typeMap; // type ID --> element lookup table
  77. typedef std::multimap<daeInt, daeElement*>::iterator typeMapIter;
  78. typedef std::pair<daeInt, daeElement*> typeMapPair;
  79. typedef std::pair<typeMapIter, typeMapIter> typeMapRange;
  80. std::multimap< std::string, daeElement* > elementsIDMap; //map for elements keyed on ID
  81. typedef std::multimap<std::string, daeElement*>::iterator idMapIter;
  82. typedef std::pair<std::string, daeElement*> idMapPair;
  83. typedef std::pair<idMapIter, idMapIter> idMapRange;
  84. std::multimap< std::string, daeElement* > sidMap; // sid --> element lookup table
  85. typedef std::multimap<std::string, daeElement*>::iterator sidMapIter;
  86. typedef std::pair<std::string, daeElement*> sidMapPair;
  87. typedef std::pair<sidMapIter, sidMapIter> sidMapRange;
  88. std::vector<daeDocument*> documents;
  89. daeMetaElement* topMeta;
  90. daeInt insertChildren( daeDocument *c, daeElement *element );
  91. daeInt removeChildren( daeDocument *c, daeElement *element );
  92. };
  93. #endif // __DAE_STLDATABASE__