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