00001 /* This file is part of OMCSNetCPP 00002 00003 OMCSNetCPP is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU Lesser General Public License as published by 00005 the Free Software Foundation; either version 2.1 of the License, or 00006 (at your option) any later version. 00007 00008 OMCSNetCPP is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU Lesser General Public License for more details. 00012 00013 You should have received a copy of the GNU Lesser General Public License 00014 along with OMCSNetCPP; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00016 */ 00017 00020 #ifndef _CONCEPT_LIST 00021 00022 #define _CONCEPT_LIST 00023 00024 #include <list> 00025 00026 #include "id_map.h" 00027 00028 class CSemanticConcept; 00029 00030 typedef std::list<CSemanticConcept *> CConceptList; 00031 typedef CSemanticConceptList::iterator CConceptList_i; 00032 typedef CSemanticConceptList::const_iterator CConceptList_ci; 00033 typedef CSemanticConceptList::reverse_iterator CConceptList_ri; 00034 00036 class CSemanticConceptList 00037 { 00038 public: 00040 CSemanticConceptList *Clone() 00041 { 00042 CSemanticConceptList *l_list = new CSemanticConceptList; 00043 00044 CConceptList_i i; 00045 00046 for (i = m_concepts.begin();i != m_concepts.end();++i) 00047 { 00048 l_list->Store((*i)); 00049 } 00050 00051 return l_list; 00052 } 00053 00055 bool Lookup(CSemanticConcept *a_concept) 00056 { 00057 CConceptList_i i; 00058 00059 for (i = m_concepts.begin();i != m_concepts.end();++i) 00060 { 00061 if ((*i) == a_link) 00062 { 00063 return true; 00064 } 00065 } 00066 00067 return false; 00068 } 00069 00071 CSemanticConceptList_i GetIterator() 00072 { 00073 return m_concepts.begin(); 00074 } 00075 00077 CSemanticConceptList_ri GetReverseIterator() 00078 { 00079 return m_concepts.rbegin(); 00080 } 00081 00083 CSemanticConcept *GetNext(CSemanticConceptList_ri &a_iter) 00084 { 00085 if (a_iter == m_concepts.rend()) 00086 { 00087 return NULL; 00088 } 00089 00090 return (*a_iter++); 00091 } 00092 00094 CSemanticConcept *GetNext(CSemanticConceptList_i &a_iter) 00095 { 00096 if (a_iter == m_concepts.end()) 00097 { 00098 return NULL; 00099 } 00100 00101 return (*a_iter++); 00102 } 00103 00105 void Store(CSemanticConcept *a_link) 00106 { 00107 m_concepts.push_back(a_link); 00108 } 00109 00111 void StoreFront(CSemanticConcept *a_link) 00112 { 00113 m_concepts.push_front(a_link); 00114 } 00115 00117 void Remove() 00118 { 00119 m_concepts.pop_back(); 00120 } 00121 00123 void RemoveFront() 00124 { 00125 m_concepts.pop_front(); 00126 } 00127 00129 void Clear() 00130 { 00131 m_concepts.clear(); 00132 } 00133 00135 u_int GetSize() const 00136 { 00137 return m_concepts.size(); 00138 } 00139 00141 CSemanticConceptList() {} 00142 00144 ~CSemanticConceptList() {} 00145 00146 private: 00147 CConceptList m_concepts; 00148 }; 00149 00150 00151 #endif 00152
1.3.3