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

VideoSetRepositoryInFile.h

Go to the documentation of this file.
00001 #ifndef Impala_Persistency_VideoSetRepositoryInFile_h
00002 #define Impala_Persistency_VideoSetRepositoryInFile_h
00003 
00004 #include "Persistency/RepositoryInFileSystem.h"
00005 #include "Core/VideoSet/VideoSet.h"
00006 
00007 namespace Impala
00008 {
00009 namespace Persistency
00010 {
00011 
00012 
00013 class VideoSetRepositoryInFile
00014 {
00015 public:
00016 
00017     typedef Core::VideoSet::VideoSet VideoSet;
00018 
00019     VideoSetRepositoryInFile()
00020     {
00021     }
00022 
00023     VideoSet*
00024     Get(const Locator& loc)
00025     {
00026         VideoSet* res = new VideoSet(loc.GetDataSet());
00027         File f = RepFS().GetFile(loc, "VideoData", loc.GetDataSet(), false,
00028                                  false);
00029         Timer timer(1);
00030         Util::IOBuffer* buf = f.GetReadBuffer();
00031         if (buf->Valid())
00032         {
00033             while (buf->Available())
00034             {
00035                 String line = buf->ReadLine();
00036                 if (line[0] && (line[0] != '#'))
00037                 {
00038                     int id = -1;
00039                     String name("");
00040                     Util::StringParser p(line);
00041                     while (!p.TheEnd())
00042                     {
00043                         if (p.At("<id="))
00044                         {
00045                             p.Eat('=');
00046                             id = p.GetInt('>', true);
00047                             p.Eat('>');
00048                         }
00049                         else
00050                         {
00051                             String s = p.GetString2(false);
00052                             name = StringReplaceAll(s, "\\", "/");
00053                         }
00054                     }
00055                     res->AddFile(name, id);
00056                 }
00057             }
00058         }
00059         delete buf;
00060         return res;
00061     }
00062 
00063     void
00064     Add(const Locator& loc, VideoSet* vidSet)
00065     {
00066         File f = RepFS().GetFile(loc, "VideoData", loc.GetDataSet(), true,
00067                                  false);
00068 
00069         Util::IOBuffer* ioBuf = f.GetWriteBuffer();
00070         if (! ioBuf)
00071             return;
00072         for (int i=0 ; i<vidSet->NrFiles() ; i++)
00073             ioBuf->IOBuffer::Puts("\"" + vidSet->GetAsPath(i) + "\"");
00074         delete ioBuf;
00075     }
00076 
00077 private:
00078 
00079     RepositoryInFileSystem&
00080     RepFS()
00081     {
00082         return RepositoryInFileSystem::GetInstance();
00083     }
00084 
00085     ILOG_VAR_DEC;
00086 };
00087 
00088 ILOG_VAR_INIT(VideoSetRepositoryInFile, Impala.Persistency);
00089 
00090 } // namespace Persistency
00091 } // namespace Impala
00092 
00093 #endif

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