00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00020 #include "concept_map.h"
00021 #include "concept.h"
00022
00023
00024 void CConceptMap::Store(CSemanticConcept *a_concept)
00025 {
00026 CSemanticConceptMap_i i;
00027
00028 i = m_conceptMap.find(a_concept->GetID());
00029
00030 if (m_conceptMap.end() == i)
00031 {
00032 m_conceptMap[a_concept->GetID()] = a_concept;
00033 }
00034 }
00035
00036 bool CConceptMap::Load(FILE *a_fp,
00037 CTextIDMap &a_idMap)
00038 {
00039 if (!a_fp)
00040 {
00041 return false;
00042 }
00043
00044 u_int l_size = 0;
00045
00046 fread(&l_size, sizeof(u_int), 1, a_fp);
00047
00048 printf("Loading %d concepts..\n", l_size);
00049
00050 CSemanticConcept *l_concept = NULL;
00051
00052 for (u_int i = 0;i < l_size;++i)
00053 {
00054 l_concept = new CSemanticConcept("", NULL, NULL);
00055
00056 if (l_concept)
00057 {
00058 if (false == l_concept->Load(a_fp, a_idMap))
00059 {
00060 printf("error loading concept %d of %d\n",
00061 i, l_size);
00062
00063 return false;
00064 }
00065 }
00066
00067 Store(l_concept);
00068 }
00069
00070 return true;
00071 }
00072
00073 bool CConceptMap::Save(FILE *a_fp)
00074 {
00075 if (!a_fp)
00076 {
00077 return false;
00078 }
00079
00080 u_int l_size = m_conceptMap.size();
00081
00082 fwrite(&l_size, sizeof(u_int), 1, a_fp);
00083
00084 CSemanticConceptMap_i i;
00085
00086 for (i = m_conceptMap.begin();i != m_conceptMap.end();++i)
00087 {
00088 if (false == (*i).second->Save(a_fp))
00089 {
00090 return false;
00091 }
00092 }
00093
00094 return true;
00095 }
00096