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

AnnotationTableRepositoryInFile.h

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

Generated on Fri Mar 19 09:31:42 2010 for ImpalaSrc by  doxygen 1.5.1