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

XmlShot.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_IDash_XmlShot_h
00002 #define Impala_Core_IDash_XmlShot_h
00003 
00004 #include "Util/XmlDoc.h"
00005 #include "Persistency/XmlFileReader.h"
00006 #include "Link/Curl/CurlFuncs.h"
00007 #include "Core/IDash/Href.h"
00008 
00009 namespace Impala
00010 {
00011 namespace Core
00012 {
00013 namespace IDash
00014 {
00015 
00016 
00017 class XmlShot : public Util::XmlDoc
00018 {
00019 public:
00020 
00021     XmlShot(String href) : mHref(href)
00022     {
00023         Link::Curl::Memory mem = Link::Curl::Get(href);
00024         Util::IOBuffer ioBuf(mem.size, (unsigned char*) mem.data);
00025         ReadData(href, &ioBuf);
00026     }
00027 
00028     virtual
00029     ~XmlShot()
00030     {
00031     }
00032 
00033     bool
00034     Valid() const
00035     {
00036         return mValid;
00037     }
00038 
00039     String
00040     GetVideo() const
00041     {
00042         return mVideo;
00043     }
00044 
00045     int
00046     GetFrame() const
00047     {
00048         return mFrame;
00049     }
00050 
00051     int
00052     GetShotIndex() const
00053     {
00054         return mShotIndex;
00055     }
00056 
00057 private:
00058 
00059     /* sample file:
00060 
00061 <?xml version="1.0" encoding="utf-8"?>
00062 <moment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.i-dash.eu/MetaData http://www.i-dash.eu/Schemas/MetaData/MetaData.xsd" xmlns="http://www.i-dash.eu/MetaData">
00063   <id />
00064   <entityType>Moment</entityType>
00065   <memo />
00066   <video xlink:type="simple" xlink:href="http://192.168.137.129:7878/services/vds/cases/122/videos/123" entityType="Video" />
00067   <timepoint>343343001</timepoint>
00068   <frameIndex>1029</frameIndex>
00069 
00070 </moment>
00071 
00072    newer version:
00073 
00074 <?xml version="1.0" encoding="utf-8"?>
00075 <moment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.i-dash.eu/MetaData http://www.i-dash.eu/Schemas/MetaData/MetaData.xsd" xmlns="http://www.i-dash.eu/MetaData">
00076   <id>720</id>
00077   <entityType>Moment</entityType>
00078   <memo />
00079   <keywords xlink:href="http://146.50.22.23:7878/services/vds/cases/122/videos/156/shots/0/keywords" />
00080   <video xlink:href="http://146.50.22.23:7878/services/vds/cases/122/videos/156" xlink:title="Bier-Baby.mpeg" entityType="Video" />
00081   <timepoint>416666</timepoint>
00082   <frameIndex>1</frameIndex>
00083   <keyFrameIndex>0</keyFrameIndex>
00084   <shotIndex>0</shotIndex>
00085   <frameType>shots</frameType>
00086 </moment>
00087     */
00088 
00089     void
00090     ReadData(String docName, Util::IOBuffer* ioBuf)
00091     {
00092         mValid = false;
00093         Persistency::XmlFileReader reader;
00094         DOMDocument* doc = reader.Read(docName, ioBuf);
00095         if (!doc)
00096             return;
00097         DOMNode* moment = GetChildNode(doc, "moment", true);
00098         if (!moment)
00099             return;
00100         DOMNode* video = GetChildNode(moment, "video", true);
00101         mVideo = GetAttributeValue(video, "xlink:href");;
00102         ILOG_DEBUG("video = " << mVideo);
00103         DOMNode* frame = GetChildNode(moment, "frameIndex", true);
00104         mFrame = Impala::atol(GetElementValue(frame));
00105         ILOG_DEBUG("frame = " << mFrame);
00106         DOMNode* shot = GetChildNode(moment, "shotIndex", true);
00107         mShotIndex = Impala::atol(GetElementValue(shot));
00108         ILOG_DEBUG("shotIndex = " << mShotIndex);
00109         mValid = true;
00110     }
00111 
00112     // data
00113 
00114     Href   mHref;
00115     String mVideo;
00116     int    mFrame;
00117     int    mShotIndex;
00118     bool   mValid;
00119 
00120     ILOG_VAR_DEC;
00121 
00122 };
00123 
00124 ILOG_VAR_INIT(XmlShot, Impala.Core.IDash);
00125 
00126 } // namespace IDash
00127 } // namespace Core
00128 } // namespace Impala
00129 
00130 #endif

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