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

ConceptSet.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Feature_ConceptSet_h
00002 #define Impala_Core_Feature_ConceptSet_h
00003 
00004 #include "Core/Feature/Concept.h"
00005 
00006 namespace Impala
00007 {
00008 namespace Core
00009 {
00010 namespace Feature
00011 {
00012 
00013 
00014 class ConceptSet
00015 {
00016 public:
00017 
00018     ConceptSet(String conceptSetName)
00019     {
00020         mConceptSetName = conceptSetName;
00021     }
00022 
00023     virtual
00024     ~ConceptSet()
00025     {
00026         for (int i=0 ; i<mConcepts.size() ; i++)
00027             delete mConcepts[i];
00028     }
00029 
00030     static ConceptSet*
00031     MakeFromFile(Database::RawDataSet* annoSet, String conceptSetName,
00032                  String modelType)
00033     {
00034         ILOG_VAR(Impala.Core.Feature.ConceptSet.MakeFromFile);
00035         String path = annoSet->GetFilePathAnnotation(conceptSetName, false,
00036                                                      false);
00037         ConceptSet* res = new ConceptSet(conceptSetName);
00038         Util::Database* db = annoSet->GetDatabase();
00039         Util::IOBuffer* buf = db->GetIOBuffer(path, true, true, "");
00040         if (! buf)
00041         {
00042             ILOG_ERROR("File not valid : " << path);
00043             return res;
00044         }
00045         while (buf->Available())
00046         {
00047             String line = buf->ReadLine();
00048             if (line[0] && line[0] != '#')
00049                 res->AddConcept(new Concept(annoSet, conceptSetName, modelType,
00050                                             line));
00051         }
00052         return res;
00053     }
00054 
00055     int
00056     GetNrConcepts()
00057     {
00058         return mConcepts.size();
00059     }
00060 
00061     std::vector<String>
00062     GetNames()
00063     {
00064         std::vector<String> res;
00065         for (int i=0 ; i<GetNrConcepts() ; i++)
00066             res.push_back(GetConcept(i)->GetName());
00067         return res;
00068     }
00069 
00070     Concept*
00071     GetConcept(int idx)
00072     {
00073         return mConcepts[idx];
00074     }
00075 
00076     Concept*
00077     GetConcept(CString name)
00078     {
00079         for (int i=0 ; i<mConcepts.size() ; i++)
00080             if (mConcepts[i]->GetName() == name)
00081                 return mConcepts[i];
00082         return 0;
00083     }
00084 
00085     void
00086     AddConcept(Concept* concept)
00087     {
00088         mConcepts.push_back(concept);
00089     }
00090 
00091 private:
00092 
00093     String                mConceptSetName;
00094     std::vector<Concept*> mConcepts;
00095 
00096 };
00097 
00098 } // namespace Feature
00099 } // namespace Core
00100 } // namespace Impala
00101 
00102 #endif

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