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