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

VideoSetRepositoryInMonet.h

Go to the documentation of this file.
00001 #ifndef Impala_Persistency_VideoSetRepositoryInMonet_h
00002 #define Impala_Persistency_VideoSetRepositoryInMonet_h
00003 
00004 #include "Persistency/RepositoryInMonetDB.h"
00005 #include "Core/VideoSet/VideoSet.h"
00006 
00007 namespace Impala
00008 {
00009 namespace Persistency
00010 {
00011 
00012 
00013 class VideoSetRepositoryInMonet
00014 {
00015 public:
00016 
00017     typedef Link::Monet::Connection Connection;
00018     typedef Core::VideoSet::VideoSet VideoSet;
00019 
00020     VideoSetRepositoryInMonet()
00021     {
00022     }
00023 
00024     VideoSet*
00025     Get(const Locator& loc)
00026     {
00027         Connection* conn = RepMonet().GetConnection(loc);
00028 
00029         String vidSetBase = FileNameBase(loc.GetDataSet());
00030         String query =
00031             "select f.filename, f.quid \
00032              from   file f, video_set vs, video_sets vss \
00033              where  vss.set_name = '" + vidSetBase + "' and \
00034                     vs.video_sets_id = vss.video_sets_id and \
00035                     f.file_id = vs.file_id \
00036              order by f.quid;";
00037 
00038         MapiHdl hdl = conn->QueryPartStart(query);
00039         if (hdl == 0)
00040             return 0;
00041 
00042         std::vector<String> fName;
00043         if (!conn->QueryPartFetchString(hdl, 0, fName))
00044             return 0;
00045 
00046         Quid* quid = 0;
00047         int quidSize = 0;
00048         if (!conn->QueryPartFetchULL(hdl, 1, quid, quidSize))
00049             return 0;
00050 
00051         conn->QueryPartEnd(hdl);
00052 
00053         VideoSet* vidSet = new VideoSet(loc.GetDataSet());
00054         for (int i=0 ; i<fName.size() ; i++)
00055         {
00056             int fileId = QuidId(quid[i]);
00057             vidSet->AddFile(fName[i], fileId);
00058             if (vidSet->GetQuidVideo(i, true) != quid[i])
00059                 ILOG_ERROR("Quid " << i << " doesn't match");
00060         }
00061         delete quid;
00062         return vidSet;
00063     }
00064 
00065     void
00066     Add(const Locator& loc, VideoSet* vidSet)
00067     {
00068         Connection* conn = RepMonet().GetConnection(loc);
00069 
00070         String vidSetBase = FileNameBase(loc.GetDataSet());
00071         for (int i=0 ; i<vidSet->NrFiles() ; i++)
00072         {
00073             String file = vidSet->GetAsPath(i);
00074             Quid quid = vidSet->GetQuidVideo(i, true);
00075             // todo : get info from video
00076             //String q = "select i_add_video_file('" + vidSetBase + "', "
00077             //    + MakeString(quid) + ", '" + file
00078             //    + "', 352, 288, 25, -1, 'mpeg1', 'bitrate');";
00079             bool uniqueEvent = false;
00080             String evName = (uniqueEvent) ? vidSetBase + "_" + MakeString(quid)
00081                                           : FileNameBase(file);
00082             String q = "select i_add_video_file_event('" + vidSetBase + "', '"
00083                 + evName + "', 'no description', " + MakeString(quid) + ", '"
00084                 + file + "', 352, 288, true, 25, -1, 'mpeg1', 'bitrate');";
00085             ILOG_INFO("q = [" + q + "]");
00086             conn->Query(q, false, false);
00087         }
00088     }
00089 
00090 private:
00091 
00092     RepositoryInMonetDB&
00093     RepMonet()
00094     {
00095         return RepositoryInMonetDB::GetInstance();
00096     }
00097 
00098     ILOG_VAR_DEC;
00099 };
00100 
00101 ILOG_VAR_INIT(VideoSetRepositoryInMonet, Impala.Persistency);
00102 
00103 } // namespace Persistency
00104 } // namespace Impala
00105 
00106 #endif

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