FCDocument/FCDLibrary.hpp

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 /*
00009     Based on the FS Import classes:
00010     Copyright (C) 2005-2006 Feeling Software Inc
00011     Copyright (C) 2005-2006 Autodesk Media Entertainment
00012     MIT License: http://www.opensource.org/licenses/mit-license.php
00013 */
00014 
00015 template <class T>
00016 FCDLibrary<T>::FCDLibrary(FCDocument* document)
00017 :   FCDObject(document)
00018 ,   InitializeParameterNoArg(entities)
00019 ,   InitializeParameterNoArg(extra)
00020 ,   InitializeParameterNoArg(asset)
00021 {
00022     extra = new FCDExtra(document, this);
00023 }
00024 
00025 template <class T>
00026 FCDLibrary<T>::~FCDLibrary()
00027 {
00028     SAFE_RELEASE(extra);
00029     SAFE_RELEASE(asset);
00030 }
00031 
00032 // Create the asset if it isn't already there.
00033 template <class T>
00034 FCDAsset* FCDLibrary<T>::GetAsset(bool create)
00035 {
00036     if (create && asset == NULL) asset = new FCDAsset(GetDocument());
00037     return asset;
00038 }
00039 
00040 // Search for the entity in this library with a given COLLADA id.
00041 template <class T>
00042 const T* FCDLibrary<T>::FindDaeId(const fm::string& daeId) const
00043 {
00044 #ifdef _DEBUG
00045     // [staylor] June 12 2007 - !!Code change verification check!!
00046     // When fixing up the FCPlugin archive merge, removed SkipPound
00047     // here (Should be obsolete).  If you see this code much past this 
00048     // date, feel free to remove it.
00049     FUAssert (daeId.empty() || daeId[0] != '#',);
00050 #endif
00051 
00052     size_t entityCount = entities.size();
00053     for (size_t i = 0; i < entityCount; ++i)
00054     {
00055         const FCDEntity* found = entities[i]->FindDaeId(daeId);
00056         if (found != NULL && found->GetObjectType() == T::GetClassType())
00057         {
00058             return (T*) found;
00059         }
00060     }
00061     return NULL;
00062 }
00063 
00064 // Search for the entity in this library with a given COLLADA id.
00065 template <class T>
00066 T* FCDLibrary<T>::AddEntity()
00067 {
00068     T* entity = new T(GetDocument());
00069     entities.push_back(entity);
00070     SetNewChildFlag();
00071     return entity;
00072 }
00073 
00074 
00075 template <class T>
00076 void FCDLibrary<T>::AddEntity(T* entity) 
00077 { 
00078     entities.push_back(entity); SetNewChildFlag(); 
00079 }

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