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

link_map.cpp

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 #include "link_map.h"
00021 #include "link_list.h"
00022 #include "link.h"
00023 #include "find_cfg.h"
00024 #include "debug.h"
00025 
00026 
00027 bool CLinkMap::FindPathTo(const SemanticID       a_dstID,
00028                                               CFindPathConfig &a_config)
00029 {
00030         CSemanticLinkMap_i i;
00031 
00032         DPRINT("visiting link map.\n");
00033 
00034         for (i = m_linkMap.begin();i != m_linkMap.end();++i)
00035         {
00036                 a_config.VisitNode();
00037 
00038                 (*i).second->FindPathTo(a_dstID, a_config);
00039         }
00040 
00041         return false;
00042 }
00043 
00044 
00045 void CLinkMap::Remove(const SemanticID a_id)
00046 {
00047         CSemanticLinkMap_i i;
00048 
00049         i = m_linkMap.find(a_id);
00050 
00051         if (m_linkMap.end() != i)
00052         {
00053                 m_linkMap.erase(i);
00054         }
00055 }
00056 
00057 void CLinkMap::Store(CSemanticLink *a_link)
00058 {
00059         CSemanticLinkMap_i i;
00060 
00061         i = m_linkMap.find(a_link->GetID());
00062 
00063         if (m_linkMap.end() == i)
00064         {
00065                 m_linkMap[a_link->GetID()] = a_link;
00066         }
00067 }
00068 
00069 
00070 bool CLinkMap::Load(FILE        *a_fp,
00071                     CConceptMap &a_conceptMap)
00072 {
00073         if (!a_fp)
00074         {
00075                 return false;
00076         }
00077 
00078         u_int l_size = 0;
00079 
00080         fread(&l_size, sizeof(u_int), 1, a_fp);
00081 
00082         printf("Loading %d links...\n", l_size);
00083 
00084         CSemanticLink *l_link = NULL;
00085 
00086         for (u_int i = 0;i < l_size;++i)
00087         {
00088                 l_link = new CSemanticLink();
00089 
00090                 if (l_link)
00091                 {
00092                         if (false == l_link->Load(a_fp, a_conceptMap))
00093                         {
00094                                 printf("error loading link %d of %d\n",
00095                                         i, l_size);
00096 
00097                                 return false;
00098                         }
00099                 }
00100 
00101                 Store(l_link);
00102         }
00103 
00104         return true;
00105 }
00106 

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