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

FeatureTableSetRepository.h

Go to the documentation of this file.
00001 #ifndef Impala_Persistency_FeatureTableSetRepository_h
00002 #define Impala_Persistency_FeatureTableSetRepository_h
00003 
00004 #include "Persistency/RepositoryDispatcher.h"
00005 #include "Persistency/RepositoryStub.h"
00006 #include "Core/Feature/FeatureTableSet.h"
00007 #include "Persistency/FeatureListRepository.h"
00008 #include "Persistency/FeatureTableRepository.h"
00009 #include "Core/Table/Append.h"
00010 
00011 namespace Impala
00012 {
00013 namespace Persistency
00014 {
00015 
00016 
00017 class FeatureTableSetRepository
00018     : public RepositoryDispatcher<FeatureLocator,
00019                                   Core::Feature::FeatureTableSet,
00020                                   RepositoryStub,
00021                                   RepositoryStub>
00022 {
00023 public:
00024 
00025     typedef Core::Feature::FeatureTableSet FeatureTableSet;
00026     typedef Core::Feature::FeatureDefinition FeatureDefinition;
00027     typedef Core::Feature::FeatureTable FeatureTable;
00028     typedef Core::Feature::FeatureList FeatureList;
00029 
00030     FeatureTableSet*
00031     Get(const FeatureLocator& loc)
00032     {
00033         String featureString = loc.GetFeatureString();
00034         FeatureList featList;
00035         if (FileNameExt(featureString) == "txt")
00036         {
00037             featList = *(FeatureListRepository().Get(loc));
00038         }
00039         else
00040         {
00041             StringList defList(featureString, ';');
00042             for (StringListCI i=defList.begin() ; i!=defList.end() ; i++)
00043                 featList.push_back(*i);
00044         }
00045         if (featList.size() == 0)
00046         {
00047             ILOG_ERROR("Get: feature list is empty");
00048             return 0;
00049         }
00050 
00051         FeatureTableSet* res = new FeatureTableSet();
00052         FeatureLocator tLoc = loc;
00053         for (int i=0 ; i<featList.size() ; i++)
00054         {
00055             tLoc.SetFeatureDef(featList[i]);
00056             FeatureTable* table = 0;
00057             tLoc.SetStartFrame(0);
00058             bool done = false;
00059             while (!done)
00060             {
00061                 if (tLoc.GetIsPartial() && (tLoc.GetStartFrame() != 0) &&
00062                     !FeatureTableRepository().Exists(tLoc))
00063                 {
00064                     done = true;
00065                 }
00066                 else
00067                 {
00068                     if (table == 0)
00069                     {
00070                         table = FeatureTableRepository().Get(tLoc);
00071                     }
00072                     else
00073                     {
00074                         FeatureTable* t = FeatureTableRepository().Get(tLoc);
00075                         Core::Table::Append(table, t);
00076                         delete t;
00077                     }
00078                 }
00079                 if (!tLoc.GetIsPartial())
00080                     done = true;
00081                 tLoc.SetStartFrame(tLoc.GetStartFrame()+tLoc.GetNumberFrames());
00082             }
00083             if (table != 0)
00084                 res->Add(table);
00085         }
00086         if (res->Size() == 0)
00087         {
00088             ILOG_ERROR("Get: no feature tables found");
00089             res->Delete();
00090             delete res;
00091             return 0;
00092         }
00093         return res;
00094     }
00095 
00096     void
00097     Add(const FeatureLocator& loc, FeatureTableSet* tSet)
00098     {
00099         ILOG_ERROR("Not implemented yet");
00100     }
00101 
00102 private:
00103 
00104     ILOG_VAR_DEC;
00105 };
00106 
00107 ILOG_VAR_INIT(FeatureTableSetRepository, Impala.Persistency);
00108 
00109 } // namespace Persistency
00110 } // namespace Impala
00111 
00112 #endif

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