daeDocument.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * Copyright 2006 Sony Computer Entertainment Inc.
  3. *
  4. * Licensed under the SCEA Shared Source License, Version 1.0 (the "License"); you may not use this
  5. * file except in compliance with the License. You may obtain a copy of the License at:
  6. * http://research.scea.com/scea_shared_source_license.html
  7. *
  8. * Unless required by applicable law or agreed to in writing, software distributed under the License
  9. * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  10. * implied. See the License for the specific language governing permissions and limitations under the
  11. * License.
  12. */
  13. #ifndef __DAE_DOCUMENT__
  14. #define __DAE_DOCUMENT__
  15. #include <dae/daeTypes.h>
  16. #include <dae/daeElement.h>
  17. #include <dae/daeURI.h>
  18. #include <dae/daeStringRef.h>
  19. class DAE;
  20. class daeDatabase;
  21. /**
  22. * The @c daeDocument class implements a COLLADA runtime database entry.
  23. */
  24. class DLLSPEC daeDocument
  25. {
  26. public:
  27. /**
  28. * Constructor
  29. * @param dae The dae that owns this document.
  30. */
  31. daeDocument(DAE& dae);
  32. /**
  33. * Destructor
  34. */
  35. ~daeDocument();
  36. /**
  37. * Accessor to get the @c domCollada associated with this document.
  38. * @return A @c daeElementRef for the @c domCollada that is the root of this document.
  39. * @note This function should really return a domColladaRef,
  40. * but we're trying to avoid having @c dae classes depend on generated dom classes.
  41. */
  42. daeElement* getDomRoot() const {return(dom);}
  43. /**
  44. * Accessor to set the domCollada associated with this document
  45. * @param domRoot the domCollada that is the root of this document
  46. * @remarks Should really require a domColladaRef but we're trying to avoid having dae classes depend on generated dom classes.
  47. */
  48. void setDomRoot(daeElement* domRoot) {dom = domRoot; domRoot->setDocument(this); }
  49. /**
  50. * Accessor to get the URI associated with the document in this document;
  51. * this is currently set to the URI from which the document was loaded, but
  52. * is blank if the document was created with @c insertDocument().
  53. * @return Returns a pointer to the URI for this document.
  54. * @note This is the full URI of the document and not the document base URI.
  55. */
  56. daeURI* getDocumentURI() {return (&uri);}
  57. /**
  58. * Const accessor to get the URI associated with the document in this collection;
  59. * this is currently set to the URI from which the collection was loaded, but
  60. * is blank if the collection was created with @c insertCollection().
  61. * @return Returns a pointer to the URI for this collection.
  62. * @note This is the full URI of the document and not the document base URI.
  63. */
  64. const daeURI* getDocumentURI() const {return (&uri);}
  65. /**
  66. * Accessor to get the DAE that owns this document.
  67. * @return Returns the DAE that owns this document.
  68. */
  69. DAE* getDAE();
  70. /**
  71. * Accessor to get the database associated with this document.
  72. * @return Returns the database associated with this document.
  73. */
  74. daeDatabase* getDatabase();
  75. /**
  76. * This function is used to track how a document gets modified. It gets called internally.
  77. * @param element The element that was added to this document.
  78. * @note This function is called internally and not meant to be called by the client application.
  79. * Calling this function from the client application may result in unexpected behavior.
  80. */
  81. void insertElement( daeElementRef element );
  82. /**
  83. * This function is used to track how a document gets modified. It gets called internally.
  84. * @param element The element that was removed from this document.
  85. * @note This function is called internally and not meant to be called by the client application.
  86. * Calling this function from the client application may result in unexpected behavior.
  87. */
  88. void removeElement( daeElementRef element );
  89. /**
  90. * This function is used to track how a document gets modified. It gets called internally.
  91. * @param element The element whose ID is about to be changed.
  92. * @param newID The ID that is going to be assigned to the element.
  93. * @note This function is called internally and not meant to be called by the client application.
  94. * Calling this function from the client application may result in unexpected behavior.
  95. */
  96. void changeElementID( daeElementRef element, daeString newID );
  97. /**
  98. * This function is just like changeElementID, except it keeps track of sids instead of IDs.
  99. * @param element The element whose sid is about to be changed.
  100. * @param newSID The sid that is going to be assigned to the element.
  101. * @note This function is called internally and not meant to be called by the client application.
  102. * Calling this function from the client application may result in unexpected behavior.
  103. */
  104. void changeElementSID( daeElementRef element, daeString newSID );
  105. /**
  106. * Adds a URI to the list of external references in this document.
  107. * @param uri The URI that is the external reference.
  108. * @note This function gets called internally from daeURI upon trying to resolve an element.
  109. * Calling this function in your client code my result in unexpected behavior.
  110. */
  111. void addExternalReference( daeURI &uri );
  112. /**
  113. * Gets a list of all the documents that are referenced from URI contained within this document.
  114. * @return Returns a list of URI strings, each being a URI which is referenced from within this document.
  115. */
  116. const daeStringRefArray &getReferencedDocuments() const { return referencedDocuments; }
  117. private:
  118. /**
  119. * The DAE that owns this document. The DAE's database is notified by the document when
  120. * elements are inserted, removed, or have their ID changed.
  121. */
  122. DAE* dae;
  123. /**
  124. * Top Level element for of the document, always a domCollada
  125. * @remarks This member will eventually be taken private, use getDomRoot() to access it.
  126. */
  127. daeElementRef dom;
  128. /**
  129. * The URI of the document, may be blank if the document wasn't loaded from a URI
  130. * @remarks This member will eventually be taken private, use getDocumentURI() to access it.
  131. */
  132. daeURI uri;
  133. daeStringRefArray referencedDocuments;
  134. };
  135. typedef daeDocument daeCollection;
  136. #endif