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

link_map.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_MAP
00021 
00022 #define _LINK_MAP
00023 
00024 #include <map>
00025 #include <string>
00026 
00027 #include "link.h"
00028 #include "link_list.h"
00029 
00030 class CFindPathConfig;
00031 class CTextIDMap;
00032 
00034 typedef std::map<SemanticID, CSemanticLink *>   CSemanticLinkMap;
00035 
00037 typedef CSemanticLinkMap::iterator              CSemanticLinkMap_i;
00039 typedef CSemanticLinkMap::const_iterator        CSemanticLinkMap_ci;
00040 
00042 class CLinkMap
00043 {
00044         public:
00046                 bool Load(FILE        *a_fp,
00047                           CConceptMap &a_conceptMap);
00048 
00050                 bool Save(FILE *a_fp)
00051                 {
00052                         if (!a_fp)
00053                         {
00054                                 return false;
00055                         }
00056 
00057                         u_int l_size = m_linkMap.size();
00058 
00059                         fwrite(&l_size, sizeof(u_int), 1, a_fp);
00060 
00061                         CSemanticLinkMap_i i;
00062 
00063                         for (i = m_linkMap.begin();i != m_linkMap.end();++i)
00064                         {
00065                                 if (false == (*i).second->Save(a_fp))
00066                                 {
00067                                         return false;
00068                                 }
00069                         }
00070 
00071                         return true;
00072                 }
00073 
00075                 bool FindPathTo(const SemanticID       a_dstID,
00076                                       CFindPathConfig &a_config);
00077 
00079                 CSemanticLinkMap_i GetIterator()
00080                 {
00081                         return m_linkMap.begin();
00082                 }
00083 
00085                 CSemanticLink *GetNext(CSemanticLinkMap_i &a_iter)
00086                 {
00087                         if (a_iter != m_linkMap.end())
00088                         {
00089                                 CSemanticLink *l_link = (*a_iter).second;
00090 
00091                                 ++a_iter;
00092 
00093                                 return l_link;
00094                         }
00095 
00096                         return NULL;
00097                 }       
00098 
00100                 CSemanticLink *Lookup(const SemanticID a_id)
00101                 {
00102                         CSemanticLinkMap_i i;
00103 
00104                         i = m_linkMap.find(a_id);
00105 
00106                         if (m_linkMap.end() != i)
00107                         {
00108                                 return (*i).second;
00109                         }
00110 
00111                         return NULL;
00112                 }
00113 
00115                 void Store(CSemanticLink *a_link);
00116 
00118                 void Remove(const SemanticID a_id);
00119 
00121                 u_int GetSize() const
00122                 {
00123                         return m_linkMap.size();
00124                 }
00125 
00127                 CLinkMap() {}
00128 
00130                 ~CLinkMap() {}
00131 
00132         private:
00134                 CSemanticLinkMap m_linkMap;
00135 };
00136 
00137 #endif
00138 

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