FCDocument/FCDEntityReference.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2005-2007 Feeling Software Inc.
00003     Portions of the code are:
00004     Copyright (C) 2005-2007 Sony Computer Entertainment America
00005     
00006     MIT License: http://www.opensource.org/licenses/mit-license.php
00007 */
00008 
00014 #ifndef _FCD_ENTITY_REFERENCE_H_
00015 #define _FCD_ENTITY_REFERENCE_H_
00016 
00017 #ifndef __FCD_OBJECT_H_
00018 #include "FCDocument/FCDObject.h"
00019 #endif // __FCD_OBJECT_H_
00020 #ifndef _FU_URI_H_
00021 #include "FUtils/FUUri.h"
00022 #endif // _FU_URI_H_
00023 
00024 class FCDPlaceHolder;
00025 class FCDObjectWithId;
00026 
00053 class FCOLLADA_EXPORT FCDEntityReference : public FCDObject, FUTracker
00054 {
00055 private:
00056     DeclareObjectType(FCDObject);
00057 
00058     FCDEntity* entity;
00059     FCDPlaceHolder* placeHolder;
00060     fm::string entityId;
00061 
00062     // Pointer back to the nearest object with id that references
00063     // us down the hierarchy.  This is because the references from the
00064     // actual object with the link are irrelevant in terms of the hierarchy,
00065     // it is only objects with id's (ie FCDEntities) that actually matter in terms
00066     // of object durability etc.
00067     FCDObjectWithId* baseObject;
00068 
00069 public:
00073     FCDEntityReference(FCDocument* document, FCDObjectWithId* parent);
00074 
00076     virtual ~FCDEntityReference();
00077 
00081     FCDPlaceHolder* GetPlaceHolder() { return placeHolder; }
00082     const FCDPlaceHolder* GetPlaceHolder() const { return placeHolder; } 
00086     const fm::string& GetEntityId() const { return entityId; }
00087 
00091     inline bool IsExternal() const { return placeHolder != NULL; }
00092 
00096     inline bool IsLocal() const { return placeHolder == NULL; }
00097 
00100     void SetEntityId(const fm::string& id) { entityId = id; SetDirtyFlag(); }
00101 
00105     FUUri GetUri() const;
00106 
00110     void SetUri(const FUUri& uri);
00111     
00116     FCDEntity* GetEntity() { return const_cast<FCDEntity*>(const_cast<const FCDEntityReference*>(this)->GetEntity()); }
00117     const FCDEntity* GetEntity() const; 
00125     inline const FCDObjectWithId* GetClosestObjectWithId() const { return baseObject; }
00126 
00130     inline void SetClosestObjectWithId(FCDObjectWithId* obj) { FUAssert(baseObject == NULL,); baseObject = obj; }
00131 
00135     void SetEntity(FCDEntity* entity);
00136 
00137 private:
00138     // Attempt to find the entity based on the set URL etc. 
00139     // This can cause an external document to load if the reference is external.
00140     void LoadEntity();
00141 
00142     //  Sets the COLLADA document referenced by the entity instance.
00143     //  @param document The COLLADA document referenced by the entity instance.
00144     void SetEntityDocument(FCDocument* document);
00145 
00146     // Sets the COLLADA document place holder that replaces the
00147     // external COLLADA document for this reference.
00148     // @param placeHolder The COLLADA document place holder.
00149     void SetPlaceHolder(FCDPlaceHolder* placeHolder);
00150 
00151     virtual void OnObjectReleased(FUTrackable* object);
00152 };
00153 
00154 #endif // _FCD_ENTITY_REFERENCE_H_

Generated on Thu Feb 14 16:58:34 2008 for FCollada by  doxygen 1.4.6-NO