FDO API Reference | Feature Data Objects |
00001 #ifndef _READONLYNAMEDCOLLECTION_H_ 00002 #define _READONLYNAMEDCOLLECTION_H_ 00003 // 00004 00005 // 00006 // Copyright (C) 2004-2006 Autodesk, Inc. 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of version 2.1 of the GNU Lesser 00010 // General Public License as published by the Free Software Foundation. 00011 // 00012 // This library is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 // Lesser General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU Lesser General Public 00018 // License along with this library; if not, write to the Free Software 00019 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00020 // 00021 00022 #ifdef _WIN32 00023 #pragma once 00024 #endif 00025 00026 /// \brief 00027 /// FdoReadOnlyNamedCollection is an abstract template class that can be 00028 /// wrapped around a base collection of type specified by the BASECOLLECTION 00029 /// template argument. It allows access to the members of the base collection 00030 /// but disallows the adding or removing of members to or from the base 00031 /// collection. 00032 /// 00033 /// Note1: the OBJ template argument must be set to the type of the members 00034 /// of the BASECOLLECTION. 00035 /// 00036 /// Note2: BASECOLLECTION must be a type based on FdoNamedCollection. 00037 template <class OBJ, class BASECOLLECTION> class FdoReadOnlyNamedCollection : public FdoIDisposable 00038 { 00039 protected: 00040 FdoReadOnlyNamedCollection() {} 00041 /// \brief 00042 /// Read Only Named Collection constructor 00043 /// 00044 /// \param baseCollection 00045 /// Input collection to wrap around. This collection 00046 /// provides read-only access to the base collection. 00047 /// 00048 FdoReadOnlyNamedCollection( BASECOLLECTION* baseCollection ) 00049 { 00050 m_collection = FDO_SAFE_ADDREF(baseCollection); 00051 } 00052 00053 public: 00054 00055 /// \brief 00056 /// Gets the number of items in the base collection. 00057 /// 00058 /// \return 00059 /// Returns number of items in the base collection 00060 /// 00061 virtual FdoInt32 GetCount() const 00062 { 00063 return m_collection->GetCount(); 00064 } 00065 00066 /// \brief 00067 /// Gets the item in the base collection at the specified index. Throws an invalid argument exception if the index is out of range. 00068 /// 00069 /// \param index 00070 /// Input index 00071 /// 00072 /// \return 00073 /// Returns the item in the base collection at the specified index 00074 /// 00075 virtual OBJ* GetItem(FdoInt32 index) const 00076 { 00077 return m_collection->GetItem(index); 00078 } 00079 00080 /// \brief 00081 /// Gets the item in the base collection with the specified name. Throws an exception if the item is not found. 00082 /// 00083 /// \param name 00084 /// Input item name 00085 /// 00086 /// \return 00087 /// Returns the item in the base collection with the specified name 00088 /// 00089 virtual OBJ* GetItem(const wchar_t* name) const 00090 { 00091 return m_collection->GetItem(name); 00092 } 00093 00094 /// \brief 00095 /// Finds the item in the base collection with the specified name. 00096 /// 00097 /// \param name 00098 /// Input item name 00099 /// 00100 /// \return 00101 /// Returns the item in the base collection with the specified name. 00102 /// Returns NULL if the item was not found. 00103 /// 00104 virtual OBJ* FindItem(const wchar_t* name) const 00105 { 00106 return m_collection->FindItem(name); 00107 } 00108 00109 /// \brief 00110 /// Returns true if the base collection contains the specified item, false otherwise. 00111 /// 00112 /// \param value 00113 /// Input value 00114 /// 00115 /// \return 00116 /// Returns true if the base collection contains the specified item, false otherwise 00117 /// 00118 virtual bool Contains(const OBJ* value) const 00119 { 00120 return m_collection->Contains(value); 00121 } 00122 00123 /// \brief 00124 /// Returns the index of the specified item in the base collection or -1 if the item does not exist. 00125 /// 00126 /// \param value 00127 /// Input value 00128 /// 00129 /// \return 00130 /// Returns the index of the specified item in the base collection or -1 if the item does not exist 00131 /// 00132 virtual FdoInt32 IndexOf(const OBJ* value) const 00133 { 00134 return m_collection->IndexOf(value); 00135 } 00136 00137 private: 00138 FdoPtr<BASECOLLECTION > m_collection; 00139 }; 00140 00141 #endif 00142 00143
Comments or suggestions? Send us feedback. |