Home || Visual Search || Applications || Architecture || Important Messages || OGL || Src

KeywordListRepositoryInFile.h

Go to the documentation of this file.
00001 #ifndef Impala_Persistency_KeywordListRepositoryInFile_h
00002 #define Impala_Persistency_KeywordListRepositoryInFile_h
00003 
00004 #include "Persistency/RepositoryInFileSystem.h"
00005 #include "Core/Table/KeywordList.h"
00006 #include "Persistency/KeywordListLocator.h"
00007 
00008 namespace Impala
00009 {
00010 namespace Persistency
00011 {
00012 
00013 
00014 class KeywordListRepositoryInFile
00015 {
00016 public:
00017 
00018     typedef Core::Table::KeywordList KeywordList;
00019 
00020     KeywordListRepositoryInFile()
00021     {
00022     }
00023 
00024     bool
00025     Exists(const KeywordListLocator& loc)
00026     {
00027         File file = RepFS().GetFile(loc, "Annotations", loc.GetConceptSet(),
00028                                     false, true);
00029         return file.Valid();
00030     }
00031 
00032     KeywordList*
00033     Get(const KeywordListLocator& loc)
00034     {
00035         File file = RepFS().GetFile(loc, "Annotations", loc.GetConceptSet(),
00036                                     false, false);
00037         if (!file.Valid())
00038             return 0;
00039         KeywordList* res = new KeywordList();
00040         file.ReadStrings(std::back_inserter(*res));
00041         return res;
00042     }
00043 
00044     void
00045     Add(const KeywordListLocator& loc, KeywordList* keyList)
00046     {
00047         File file = RepFS().GetFile(loc, "Annotations", loc.GetConceptSet(),
00048                                     true, false);
00049         if (!file.Valid())
00050             return;
00051         file.WriteStrings(keyList->begin(), keyList->end());
00052     }
00053 
00054     void
00055     Delete(const KeywordListLocator& loc)
00056     {
00057         File file = RepFS().GetFile(loc, "Annotations", loc.GetConceptSet(),
00058                                     true, true);
00059         file.Delete();
00060     }
00061 
00062 private:
00063 
00064     RepositoryInFileSystem&
00065     RepFS()
00066     {
00067         return RepositoryInFileSystem::GetInstance();
00068     }
00069 
00070     ILOG_VAR_DEC;
00071 };
00072 
00073 ILOG_VAR_INIT(KeywordListRepositoryInFile, Impala.Persistency);
00074 
00075 } // namespace Persistency
00076 } // namespace Impala
00077 
00078 #endif

Generated on Thu Jan 13 09:05:08 2011 for ImpalaSrc by  doxygen 1.5.1