/* Copyright (C) 2005-2006 Feeling Software Inc. MIT License: http://www.opensource.org/licenses/mit-license.php */ /* Based on the FS Import classes: Copyright (C) 2005-2006 Feeling Software Inc Copyright (C) 2005-2006 Autodesk Media Entertainment MIT License: http://www.opensource.org/licenses/mit-license.php */ /** @file FCDExternalReference.h This file contains the FCDExternalReference class. */ #ifndef _FCD_XREF_ENTITY_H_ #define _FCD_XREF_ENTITY_H_ #include "FCDocument/FCDEntityInstance.h" #include "FUtils/FUStringConversion.h" #include "FUtils/FUUri.h" /** A COLLADA external reference for an entity instance. COLLADA supports many types of external references. FCollada only exposes external references within the visual scene graph. @ingroup FCDocument */ class FCOLLADA_EXPORT FCDExternalReference : public FCDEntityInstance { private: DeclareObjectType; FCDEntity::Type entityType; FUUri uri; public: /** Constructor: do not use directly. Instead, use the appropriate allocation function. For visual scene node instances: FCDSceneNode::AddInstance, with the entity pointer set to NULL. @param document The COLLADA document that owns the reference. @param uri The URI of the referenced entity. */ FCDExternalReference(FCDocument* document, const FUUri& uri); /** Destructor: do not use directly. Instead, use the appropriate release function. For visual scene node instances: FCDSceneNode::ReleaseInstance. */ virtual ~FCDExternalReference() {} /** Retrieves the entity instance class type. @return The class type: EXTERNAL_REFERENCE. */ virtual Type GetType() const { return EXTERNAL_REFERENCE; } /** Retrieves the type of the entity that is referenced. @return The type of the external entity. */ inline FCDEntity::Type GetEntityType() const { return entityType; } /** Sets the type of the entity that is referenced. @param type The type of the external entity. */ inline void SetEntityType(FCDEntity::Type type) { entityType = type; } /** Retrieves the URI of the external reference. This points to the COLLADA document and the id of the referenced entity. @return The referenced entity URI. */ inline const FUUri& GetUri() const { return uri; } /** Sets the URI of the external reference. This points to the COLLADA document and the id of the referenced entity. @param _uri The referenced entity URL. */ inline void SetUri(const FUUri& _uri) { uri = _uri; } /** Retrieves the filename of the COLLADA document referenced. @return The referenced document filename. */ inline const fstring& GetFilename() const { return uri.prefix; } /** Sets the filename of the COLLADA document referenced. @param filename The referenced document filename. */ void SetFilename(const fchar* filename); inline void SetFilename(const fstring& filename) { SetFilename(filename.c_str()); } /**< See above. */ /** Retrieves the COLLADA id of the external entity. @return The COLLADA id. */ inline fstring GetObjectId() const { return TO_FSTRING(uri.suffix); } /** Sets the COLLADA id of the external entity. @param daeId The COLLADA id. */ inline void SetObjectId(const fchar* daeId) { uri.suffix = TO_STRING(daeId); } inline void SetObjectId(const fstring& daeId) { uri.suffix = TO_STRING(daeId); } /**< See above. */ /** [INTERNAL] Writes out the entity instance to the given COLLADA XML tree node. @param parentNode The COLLADA XML parent node in which to insert the node. @return The created XML tree node. */ virtual xmlNode* WriteToXML(xmlNode* parentNode) const; }; #endif // _FCD_XREF_ENTITY_H_