Home || Visual Search || Applications || Architecture || 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         vidSet->SetProtocolAndHost(loc.GetProtocolAndHost());
00055         for (int i=0 ; i<fName.size() ; i++)
00056         {
00057             int fileId = QuidId(quid[i]);
00058             vidSet->AddFile(fName[i], fileId);
00059             if (vidSet->GetQuidVideo(i, true) != quid[i])
00060                 ILOG_ERROR("Quid " << i << " doesn't match");
00061         }
00062         delete quid;
00063         return vidSet;
00064     }
00065 
00066     void
00067     Add(const Locator& loc, VideoSet* vidSet)
00068     {
00069         Connection* conn = RepMonet().GetConnection(loc);
00070 
00071         String vidSetBase = FileNameBase(loc.GetDataSet());
00072         for (int i=0 ; i<vidSet->NrFiles() ; i++)
00073         {
00074             String file = vidSet->GetAsPath(i);
00075             Quid quid = vidSet->GetQuidVideo(i, true);
00076             // todo : get info from video
00077             //String q = "select i_add_video_file('" + vidSetBase + "', "
00078             //    + MakeString(quid) + ", '" + file
00079             //    + "', 352, 288, 25, -1, 'mpeg1', 'bitrate');";
00080             bool uniqueEvent = false;
00081             String evName = (uniqueEvent) ? vidSetBase + "_" + MakeString(quid)
00082                                           : FileNameBase(file);
00083             String q = "select i_add_video_file_event('" + vidSetBase + "', '"
00084                 + evName + "', 'no description', " + MakeString(quid) + ", '"
00085                 + file + "', 352, 288, true, 25, -1, 'mpeg1', 'bitrate');";
00086             ILOG_INFO("q = [" + q + "]");
00087             conn->Query(q, false, false);
00088         }
00089     }
00090 
00091 private:
00092 
00093     RepositoryInMonetDB&
00094     RepMonet()
00095     {
00096         return RepositoryInMonetDB::GetInstance();
00097     }
00098 
00099     ILOG_VAR_DEC;
00100 };
00101 
00102 ILOG_VAR_INIT(VideoSetRepositoryInMonet, Impala.Persistency);
00103 
00104 } // namespace Persistency
00105 } // namespace Impala
00106 
00107 #endif

Generated on Thu Jan 13 09:05:13 2011 for ImpalaSrc by  doxygen 1.5.1