/* 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 */ #include "FUtils/FUDaeParser.h" template FCDLibrary::FCDLibrary(FCDocument* _document) { document = _document; } template FCDLibrary::~FCDLibrary() { CLEAR_POINTER_VECTOR(entities); } // Create a new entity within this library template T* FCDLibrary::AddEntity() { T* entity = new T(document); entities.push_back(entity); return entity; } // Deletes a entity of this library template void FCDLibrary::ReleaseEntity(T* entity) { // Not yet implemented, as this will most likely result in dangling pointers! // Needs more structure... } // Read in a list of entities for a library of a COLLADA document template FUStatus FCDLibrary::LoadFromXML(xmlNode* node) { FUStatus status; for (xmlNode* entityNode = node->children; entityNode != NULL; entityNode = entityNode->next) { if (entityNode->type == XML_ELEMENT_NODE) { T* entity = AddEntity(); status.AppendStatus(entity->LoadFromXML(entityNode)); } } return status; } // Write out the library to the COLLADA xml document template void FCDLibrary::WriteToXML(xmlNode* node) const { for (typename FCDEntityList::const_iterator itEntity = entities.begin(); itEntity != entities.end(); ++itEntity) { const T* entity = (const T*) (*itEntity); entity->WriteToXML(node); } } // Search for the entity in this library with a given COLLADA id. template T* FCDLibrary::FindDaeId(const string& _daeId) { const char* daeId = FUDaeParser::SkipPound(_daeId); for (typename FCDEntityList::iterator itEntity = entities.begin(); itEntity != entities.end(); ++itEntity) { if ((*itEntity)->GetDaeId() == daeId) return (*itEntity); } return NULL; } template StringList FCDLibrary::GetPostProcessCmds() const { StringList res; for (typename FCDEntityList::const_iterator itEntity = entities.begin(); itEntity != entities.end(); ++itEntity) { res = (*itEntity)->GetPostProcessCmds(); } return res; }