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

FoldRepositoryInFile.h

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

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