kfbxpropertymap.h

Go to the documentation of this file.
00001 /****************************************************************************************
00002 
00003 Copyright (C) 2010 Autodesk, Inc.
00004 All rights reserved.
00005 
00006 Use of this software is subject to the terms of the Autodesk license agreement
00007 provided at the time of installation or download, or which otherwise accompanies
00008 this software in either electronic or hard copy form.
00009 
00010 ****************************************************************************************/
00011 
00015 #ifndef FBXFILESDK_FBXCORE_FBXCOLLECTION_KFBXPROPERTYMAP_H
00016 #define FBXFILESDK_FBXCORE_FBXCOLLECTION_KFBXPROPERTYMAP_H
00017 
00018 #include <fbxfilesdk/fbxfilesdk_def.h>
00019 
00020 #include <fbxfilesdk/components/kbaselib/klib/kmap.h>
00021 #include <fbxfilesdk/kfbxplugins/kfbxproperty.h>
00022 #include <fbxfilesdk/kfbxplugins/kfbxobject.h>
00023 
00024 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00025 
00029 template <class K, class T, class Compare>
00030 class KFBX_DLL KFbxMap
00031 {
00033 //
00034 //  WARNING!
00035 //
00036 //  Anything beyond these lines may not be documented accurately and is 
00037 //  subject to change without notice.
00038 //
00040 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00041 private:
00042     typedef KMap<K, T, Compare> KMapDef;
00043     KMapDef mMap;
00044 #endif // DOXYGEN_SHOULD_SKIP_THIS
00045 
00046 public:
00047     typedef typename KMapDef::RecordType* kIterator;
00048 
00050     inline KFbxMap()
00051     {
00052     }
00053 
00058     inline void Add(K const &pKey, T const &pValue)
00059     {
00060         mMap.Insert(pKey, pValue);
00061     }
00062 
00067     inline kIterator Find(K const &pKey) const
00068     {
00069         return (kIterator)mMap.Find( pKey );
00070     }
00071 
00076     inline kIterator Find(T const &pValue) const
00077     {
00078         kIterator lIterator = GetFirst();
00079         while (lIterator)
00080         {
00081             if (lIterator->GetValue()==pValue)
00082             {
00083                 return lIterator;
00084             }
00085             lIterator = GetNext(lIterator);
00086         }
00087         return 0;
00088     }
00089 
00093     inline void Remove(kIterator pIterator)
00094     {
00095         if (pIterator) mMap.Remove( pIterator->GetKey() );
00096     }
00097 
00101     inline kIterator GetFirst() const
00102     {
00103         return (kIterator)mMap.Minimum();
00104     }
00105 
00110     inline kIterator GetNext(kIterator pIterator) const
00111     {
00112         return (kIterator)pIterator ? pIterator->Successor() : 0;
00113     }
00114 
00117     inline void Clear() 
00118     {
00119         mMap.Clear();
00120     }
00121 
00125     inline void Reserve(int pSize)
00126     {
00127         mMap.Reserve( pSize );
00128     }
00129 
00133     inline int GetCount() const
00134     {
00135         return mMap.GetSize();
00136     }
00137 };
00138 
00142 template <class T,class Compare>
00143 class KFBX_DLL KFbxPropertyMap : public KFbxMap<T,KFbxProperty,Compare>
00144 {
00145 public:
00147     inline KFbxPropertyMap()
00148     {
00149     }
00150 
00155     inline KFbxProperty Get(typename KFbxMap<T,KFbxProperty,Compare>::kIterator pIterator)
00156     {
00157         return pIterator ? pIterator->GetValue() : KFbxProperty();
00158     }
00159 };
00160 
00164 template <class T, class Compare>
00165 class KFBX_DLL KFbxObjectMap : public KFbxMap<T,KFbxObject*,Compare>
00166 {
00167 public:
00169     inline KFbxObjectMap()
00170     {
00171     }
00172 
00177     inline KFbxObject* Get(typename KFbxMap<T,KFbxObject*,Compare>::kIterator pIterator)
00178     {
00179         return pIterator ? pIterator->GetValue() : 0;
00180     }
00181 };
00182 
00186 class KFbxMapKStringCompare
00187 {
00188 public:
00194     inline int operator()(KString const &pKeyA, KString const &pKeyB) const
00195     {
00196         return (pKeyA < pKeyB) ? -1 : ((pKeyB < pKeyA) ? 1 : 0);
00197     }
00198 };
00199 
00203 class KFBX_DLL KFbxPropertyStringMap : public KFbxPropertyMap<KString,KFbxMapKStringCompare>
00204 {
00205 public:
00207     inline KFbxPropertyStringMap()
00208     {
00209     }
00210 };
00211 
00215 class KFBX_DLL KFbxObjectStringMap : public KFbxObjectMap<class KString,class KFbxMapKStringCompare>
00216 {
00217 public:
00219     inline KFbxObjectStringMap()
00220     {
00221     }
00222 };
00223 
00224 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00225 
00226 #endif // FBXFILESDK_FBXCORE_FBXCOLLECTION_KFBXPROPERTYMAP_H
00227