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

XmlAnnotationSet.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_IDash_XmlAnnotationSet_h
00002 #define Impala_Core_IDash_XmlAnnotationSet_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 XmlAnnotationSet : public Util::XmlDoc
00018 {
00019 public:
00020 
00021     XmlAnnotationSet(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     ~XmlAnnotationSet()
00030     {
00031     }
00032 
00033     bool
00034     Valid() const
00035     {
00036         return mValid;
00037     }
00038 
00039     int
00040     GetNrMoments() const
00041     {
00042         return mMoments.size();
00043     }
00044 
00045     String
00046     GetMoment(int i) const
00047     {
00048         return mMoments[i];
00049     }
00050 
00051     std::vector<String>
00052     GetMoments() const
00053     {
00054         return mMoments;
00055     }
00056 
00057 private:
00058 
00059     /* sample file:
00060 
00061 <?xml version="1.0" encoding="utf-8"?>
00062 <moments 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   <moment xlink:href="http://146.50.22.23:7878/services/vds/cases/112/videos/114/shots/91" entityType="Moment" />
00064   <moment xlink:href="http://146.50.22.23:7878/services/vds/cases/112/videos/115/shots/7" entityType="Moment" />
00065   <moment xlink:href="http://146.50.22.23:7878/services/vds/cases/112/videos/116/shots/0" entityType="Moment" />
00066   <moment xlink:href="http://146.50.22.23:7878/services/vds/cases/112/videos/117/shots/10" entityType="Moment" />
00067   <moment xlink:href="http://146.50.22.23:7878/services/vds/cases/519/videos/524/shots/13" entityType="Moment" />
00068   <moment xlink:href="http://146.50.22.23:7878/services/vds/cases/519/videos/526/shots/25" entityType="Moment" />
00069 </moments>
00070 
00071     */
00072 
00073     void
00074     ReadData(String docName, Util::IOBuffer* ioBuf)
00075     {
00076         mValid = false;
00077         Persistency::XmlFileReader reader;
00078         DOMDocument* doc = reader.Read(docName, ioBuf);
00079         if (!doc)
00080             return;
00081         DOMNode* moments = GetChildNode(doc, "moments", true);
00082 
00083         std::vector<DOMNode*> momNodes = GetChildNodes(moments, "moment");
00084         ILOG_DEBUG("nr moments = " << momNodes.size());
00085         for (int i=0 ; i<momNodes.size() ; i++)
00086         {
00087             String href = GetAttributeValue(momNodes[i], "xlink:href");
00088             if (!href.empty())
00089                 mMoments.push_back(href);
00090         }
00091         mValid = true;
00092     }
00093 
00094     // data
00095 
00096     Href                mHref;
00097     std::vector<String> mMoments;
00098     bool                mValid;
00099 
00100     ILOG_VAR_DEC;
00101 
00102 };
00103 
00104 ILOG_VAR_INIT(XmlAnnotationSet, Impala.Core.IDash);
00105 
00106 } // namespace IDash
00107 } // namespace Core
00108 } // namespace Impala
00109 
00110 #endif

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