FDO API Reference | Feature Data Objects |
00001 #ifndef _READONLYUNNAMEDCOLLECTION_H_ 00002 #define _READONLYUNNAMEDCOLLECTION_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 #include <FdoStd.h> 00026 00027 /// \brief 00028 /// FdoReadOnlyUnnamedCollection is an abstract template class used to define a collection 00029 /// that can not be modified after it is constructed, i.e. provides read-only access. The 00030 /// difference to the class FdoReadOnlyCollection is that this class contains objects that 00031 /// do not have a property name. 00032 template <class OBJ, class BASE, class EXC> class FdoReadOnlyUnnamedCollection : public FdoIDisposable 00033 { 00034 protected: 00035 FDO_API FdoReadOnlyUnnamedCollection() 00036 { 00037 } 00038 00039 FDO_API virtual ~FdoReadOnlyUnnamedCollection() 00040 { 00041 FDO_SAFE_RELEASE(m_base); 00042 } 00043 00044 void SetBaseCollection(BASE* base) 00045 { 00046 FDO_SAFE_ADDREF(base); 00047 m_base = base; 00048 } 00049 00050 public: 00051 /// \brief 00052 /// Gets the number of items in the collection. 00053 /// 00054 /// \return 00055 /// Returns number of items in the collection 00056 /// 00057 FDO_API virtual FdoInt32 GetCount() 00058 { 00059 if (m_base) 00060 return m_base->GetCount(); 00061 else 00062 return 0; 00063 } 00064 00065 /// \brief 00066 /// Gets the item in the collection at the specified index. Throws an invalid argument exception if the index is out of range. 00067 /// 00068 /// \param index 00069 /// Input index 00070 /// 00071 /// \return 00072 /// Returns the item in the collection at the specified index 00073 /// 00074 FDO_API virtual OBJ* GetItem(FdoInt32 index) 00075 { 00076 if (m_base) 00077 return (OBJ*)m_base->GetItem(index); 00078 else 00079 throw EXC::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_INDEXOUTOFBOUNDS))); 00080 } 00081 00082 /// \brief 00083 /// Returns true if the collection contains the specified item, false otherwise. 00084 /// 00085 /// \param value 00086 /// Input value 00087 /// 00088 /// \return 00089 /// Returns true if the collection contains the specified item, false otherwise 00090 /// 00091 FDO_API virtual bool Contains(const OBJ* value) 00092 { 00093 if (m_base) 00094 return m_base->Contains(value); 00095 else 00096 return false; 00097 } 00098 00099 /// \brief 00100 /// Returns the index of the specified item in the collection or -1 if the item does not exist. 00101 /// 00102 /// \param value 00103 /// Input value 00104 /// 00105 /// \return 00106 /// Returns the index of the specified item in the collection or -1 if the item does not exist 00107 /// 00108 FDO_API virtual FdoInt32 IndexOf(const OBJ* value) 00109 { 00110 if (m_base) 00111 return m_base->IndexOf(value); 00112 else 00113 return -1; 00114 } 00115 00116 private: 00117 BASE* m_base; 00118 }; 00119 #endif 00120 00121
Comments or suggestions? Send us feedback. |