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

LabelSetRepositoryInFile.h

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

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