daeDocument.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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_DOCUMENT__
  9. #define __DAE_DOCUMENT__
  10. #include <dae/daeTypes.h>
  11. #include <dae/daeElement.h>
  12. #include <dae/daeURI.h>
  13. #include <dae/daeStringRef.h>
  14. class DAE;
  15. class daeDatabase;
  16. /**
  17. * The @c daeDocument class implements a COLLADA runtime database entry.
  18. */
  19. class DLLSPEC daeDocument
  20. {
  21. public:
  22. /**
  23. * Constructor
  24. * @param dae The dae that owns this document.
  25. * @param zaeRootDocument Indicates if the new document is the root document of a ZAE archive.
  26. * @param extractedFileURI URI to extracted dae file.
  27. */
  28. daeDocument(DAE& dae, bool zaeRootDocument = false, const std::string& extractedFileURI = "");
  29. /**
  30. * Destructor
  31. */
  32. ~daeDocument();
  33. /**
  34. * Accessor to get the @c domCollada associated with this document.
  35. * @return A @c daeElementRef for the @c domCollada that is the root of this document.
  36. * @note This function should really return a domColladaRef,
  37. * but we're trying to avoid having @c dae classes depend on generated dom classes.
  38. */
  39. daeElement* getDomRoot() const {return(dom);}
  40. /**
  41. * Accessor to set the domCollada associated with this document
  42. * @param domRoot the domCollada that is the root of this document
  43. * @remarks Should really require a domColladaRef but we're trying to avoid having dae classes depend on generated dom classes.
  44. */
  45. void setDomRoot(daeElement* domRoot) {dom = domRoot; domRoot->setDocument(this); }
  46. /**
  47. * Accessor to get the URI associated with the document in this document;
  48. * this is currently set to the URI from which the document was loaded, but
  49. * is blank if the document was created with @c insertDocument().
  50. * @return Returns a pointer to the URI for this document.
  51. * @note This is the full URI of the document and not the document base URI.
  52. */
  53. daeURI* getDocumentURI() {return (&uri);}
  54. /**
  55. * Const accessor to get the URI associated with the document in this collection;
  56. * this is currently set to the URI from which the collection was loaded, but
  57. * is blank if the collection was created with @c insertCollection().
  58. * @return Returns a pointer to the URI for this collection.
  59. * @note This is the full URI of the document and not the document base URI.
  60. */
  61. const daeURI* getDocumentURI() const {return (&uri);}
  62. /**
  63. * Accessor to get the DAE that owns this document.
  64. * @return Returns the DAE that owns this document.
  65. */
  66. DAE* getDAE();
  67. /**
  68. * Accessor to get the database associated with this document.
  69. * @return Returns the database associated with this document.
  70. */
  71. daeDatabase* getDatabase();
  72. /**
  73. * This function is used to track how a document gets modified. It gets called internally.
  74. * @param element The element that was added to this document.
  75. * @note This function is called internally and not meant to be called by the client application.
  76. * Calling this function from the client application may result in unexpected behavior.
  77. */
  78. void insertElement( daeElementRef element );
  79. /**
  80. * This function is used to track how a document gets modified. It gets called internally.
  81. * @param element The element that was removed from this document.
  82. * @note This function is called internally and not meant to be called by the client application.
  83. * Calling this function from the client application may result in unexpected behavior.
  84. */
  85. void removeElement( daeElementRef element );
  86. /**
  87. * This function is used to track how a document gets modified. It gets called internally.
  88. * @param element The element whose ID is about to be changed.
  89. * @param newID The ID that is going to be assigned to the element.
  90. * @note This function is called internally and not meant to be called by the client application.
  91. * Calling this function from the client application may result in unexpected behavior.
  92. */
  93. void changeElementID( daeElementRef element, daeString newID );
  94. /**
  95. * This function is just like changeElementID, except it keeps track of sids instead of IDs.
  96. * @param element The element whose sid is about to be changed.
  97. * @param newSID The sid that is going to be assigned to the element.
  98. * @note This function is called internally and not meant to be called by the client application.
  99. * Calling this function from the client application may result in unexpected behavior.
  100. */
  101. void changeElementSID( daeElementRef element, daeString newSID );
  102. /**
  103. * Returns true if this document is the root of a ZAE archive.
  104. * In that case getExtractedFileURI() can be used to parse
  105. * this document and for URI resolving.
  106. * @note This function is called internally and not meant to be called by the client application.
  107. */
  108. bool isZAERootDocument() {return mZAERootDocument;}
  109. /**
  110. * If this document is the root of a ZAE archive, this method can be used
  111. * to get the extracted file. Return value is only valid if isZAERootDocument()
  112. * returns true.
  113. * @note This function is called internally and not meant to be called by the client application.
  114. */
  115. const daeURI& getExtractedFileURI() {return mExtractedFileURI;}
  116. private:
  117. /**
  118. * The DAE that owns this document. The DAE's database is notified by the document when
  119. * elements are inserted, removed, or have their ID changed.
  120. */
  121. DAE* dae;
  122. /**
  123. * Top Level element for of the document, always a domCollada
  124. * @remarks This member will eventually be taken private, use getDomRoot() to access it.
  125. */
  126. daeElementRef dom;
  127. /**
  128. * The URI of the document, may be blank if the document wasn't loaded from a URI
  129. * @remarks This member will eventually be taken private, use getDocumentURI() to access it.
  130. */
  131. daeURI uri;
  132. /**
  133. * Indicates if this document is the root of a ZAE archive.
  134. */
  135. bool mZAERootDocument;
  136. /**
  137. * URI pointing to the extracted root DAE if mZAERootDocument is true.
  138. * Otherwise it is not valid.
  139. */
  140. daeURI mExtractedFileURI;
  141. };
  142. typedef daeDocument daeCollection;
  143. #endif