00001 #ifndef Impala_Persistency_QuidTableRepositoryInFile_h
00002 #define Impala_Persistency_QuidTableRepositoryInFile_h
00003
00004 #include "Persistency/RepositoryInFileSystem.h"
00005 #include "Core/Table/QuidTable.h"
00006 #include "Persistency/QuidTableLocator.h"
00007
00008 namespace Impala
00009 {
00010 namespace Persistency
00011 {
00012
00013
00014 class QuidTableRepositoryInFile
00015 {
00016 public:
00017
00018 typedef Core::Table::QuidTable QuidTable;
00019
00020 QuidTableRepositoryInFile()
00021 {
00022 }
00023
00024 QuidTable*
00025 Get(const QuidTableLocator& loc)
00026 {
00027 QuidTable* res = new QuidTable();
00028 File file = RepFS().GetFile(loc, loc.GetDir(), loc.GetName(),
00029 false, false);
00030 if (!file.Valid())
00031 return 0;
00032 Read(res, file);
00033 return res;
00034 }
00035
00036 void
00037 Add(const QuidTableLocator& loc, QuidTable* tab)
00038 {
00039 File file = RepFS().GetFile(loc, loc.GetDir(), loc.GetName(),
00040 true, false);
00041 Write(tab, file);
00042 }
00043
00044 void
00045 Delete(const QuidTableLocator& loc)
00046 {
00047 File file = RepFS().GetFile(loc, loc.GetDir(), loc.GetName(),
00048 true, true);
00049 file.Delete();
00050 }
00051
00052 private:
00053
00054 RepositoryInFileSystem&
00055 RepFS()
00056 {
00057 return RepositoryInFileSystem::GetInstance();
00058 }
00059
00060 ILOG_VAR_DEC;
00061 };
00062
00063 ILOG_VAR_INIT(QuidTableRepositoryInFile, Impala.Persistency);
00064
00065 }
00066 }
00067
00068 #endif