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

XmlVideoList.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_IDash_XmlVideoList_h
00002 #define Impala_Core_IDash_XmlVideoList_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 XmlVideoList : public Util::XmlDoc
00018 {
00019 public:
00020 
00021     XmlVideoList(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     ~XmlVideoList()
00030     {
00031     }
00032 
00033     bool
00034     Valid() const
00035     {
00036         return mValid;
00037     }
00038 
00039     int
00040     GetNrVideos() const
00041     {
00042         return mVideos.size();
00043     }
00044 
00045     String
00046     GetVideo(int i) const
00047     {
00048         return mVideos[i];
00049     }
00050 
00051     std::vector<String>
00052     GetVideos() const
00053     {
00054         return mVideos;
00055     }
00056 
00057 private:
00058 
00059     /* sample file:
00060 
00061 <?xml version="1.0" encoding="utf-8"?>
00062 <videos 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" xmlns="http://www.i-dash.eu/MetaData">
00063   <video xlink:type="simple" xlink:href="http://146.50.22.23:7878/services/vds/cases/16/videos/17" entityType="Video" />
00064   <video xlink:type="simple" xlink:href="http://146.50.22.23:7878/services/vds/cases/16/videos/18" entityType="Video" />
00065   <video xlink:type="simple" xlink:href="http://146.50.22.23:7878/services/vds/cases/16/videos/19" entityType="Video" />
00066   <video xlink:type="simple" xlink:href="http://146.50.22.23:7878/services/vds/cases/16/videos/20" entityType="Video" />
00067   <video xlink:type="simple" xlink:href="http://146.50.22.23:7878/services/vds/cases/16/videos/21" entityType="Video" />
00068   <video xlink:type="simple" xlink:href="http://146.50.22.23:7878/services/vds/cases/16/videos/22" entityType="Video" />
00069   <video xlink:type="simple" xlink:href="http://146.50.22.23:7878/services/vds/cases/16/videos/23" entityType="Video" />
00070   <video xlink:type="simple" xlink:href="http://146.50.22.23:7878/services/vds/cases/16/videos/24" entityType="Video" />
00071   <video xlink:type="simple" xlink:href="http://146.50.22.23:7878/services/vds/cases/16/videos/25" entityType="Video" />
00072 </videos>
00073 
00074     */
00075 
00076     void
00077     ReadData(String docName, Util::IOBuffer* ioBuf)
00078     {
00079         mValid = false;
00080         Persistency::XmlFileReader reader;
00081         DOMDocument* doc = reader.Read(docName, ioBuf);
00082         if (!doc)
00083             return;
00084         DOMNode* videos = GetChildNode(doc, "videos", true);
00085 
00086         std::vector<DOMNode*> vidNodes = GetChildNodes(videos, "video");
00087         ILOG_DEBUG("nr videos = " << vidNodes.size());
00088         for (int i=0 ; i<vidNodes.size() ; i++)
00089         {
00090             String href = GetAttributeValue(vidNodes[i], "xlink:href");
00091             if (!href.empty())
00092                 mVideos.push_back(href);
00093         }
00094         mValid = true;
00095     }
00096 
00097     // data
00098 
00099     Href                mHref;
00100     std::vector<String> mVideos;
00101     bool                mValid;
00102 
00103     ILOG_VAR_DEC;
00104 
00105 };
00106 
00107 ILOG_VAR_INIT(XmlVideoList, Impala.Core.IDash);
00108 
00109 } // namespace IDash
00110 } // namespace Core
00111 } // namespace Impala
00112 
00113 #endif

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