Main Page | Alphabetical List | Compound List | File List | Compound Members | File Members

link_list.h

Go to the documentation of this file.
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 _LINK_LIST
00021 
00022 #define _LINK_LIST
00023 
00024 #include <list>
00025 
00026 //#include "link.h"
00027 #include "id_map.h"
00028 
00029 class CSemanticLink;
00030 
00032 typedef std::list<CSemanticLink *>      CLinkList;
00033 
00035 typedef CLinkList::iterator             CLinkList_i;
00037 typedef CLinkList::const_iterator       CLinkList_ci;
00039 typedef CLinkList::reverse_iterator     CLinkList_ri;
00040 
00042 class CSemanticLinkList
00043 {
00044         public:
00046                 CSemanticLinkList *Clone()
00047                 {
00048                         CSemanticLinkList *l_list = new CSemanticLinkList;
00049 
00050                         CLinkList_i i;
00051 
00052                         for (i = m_links.begin();i != m_links.end();++i)
00053                         {
00054                                 l_list->Store((*i));
00055                         }
00056 
00057                         return l_list;
00058                 }
00059 
00061                 bool Lookup(CSemanticLink *a_link)
00062                 {
00063                         CLinkList_i i;
00064 
00065                         for (i = m_links.begin();i != m_links.end();++i)
00066                         {
00067                                 if ((*i) == a_link)
00068                                 {
00069                                         return true;
00070                                 }
00071                         }
00072 
00073                         return false;
00074                 }
00075 
00077                 CLinkList_i GetIterator()
00078                 {
00079                         return m_links.begin();
00080                 }
00081 
00083                 CLinkList_ri GetReverseIterator()
00084                 {
00085                         return m_links.rbegin();
00086                 }
00087 
00089                 CSemanticLink *GetNext(CLinkList_ri &a_iter)
00090                 {
00091                         if (a_iter == m_links.rend())
00092                         {
00093                                 return NULL;
00094                         }
00095 
00096                         return (*a_iter++);
00097                 }       
00098 
00100                 CSemanticLink *GetNext(CLinkList_i &a_iter)
00101                 {
00102                         if (a_iter == m_links.end())
00103                         {
00104                                 return NULL;
00105                         }
00106 
00107                         return (*a_iter++);
00108                 }       
00109 
00111                 void Store(CSemanticLink *a_link)
00112                 {
00113                         m_links.push_back(a_link);
00114                 }
00115 
00117                 void StoreFront(CSemanticLink *a_link)
00118                 {
00119                         m_links.push_front(a_link);
00120                 }
00121 
00123                 void Remove()
00124                 {
00125                         m_links.pop_back();
00126                 }
00127 
00129                 void RemoveFront()
00130                 {
00131                         m_links.pop_front();
00132                 }
00133 
00135                 void Clear()
00136                 {
00137                         m_links.clear();
00138                 }
00139 
00141                 u_int GetSize() const
00142                 {
00143                         return m_links.size();
00144                 }
00145 
00147                 CSemanticLinkList() {}
00148 
00150                 ~CSemanticLinkList() {}
00151 
00152         private:
00153                 CLinkList m_links;
00154 };
00155 
00156 
00157 #endif
00158 

Generated on Tue Sep 16 09:43:50 2003 for OMCSNetCPP by doxygen 1.3.3