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

XmlQuerySet.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_IDash_XmlQuerySet_h
00002 #define Impala_Core_IDash_XmlQuerySet_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 XmlQuerySet : public Util::XmlDoc
00018 {
00019 public:
00020 
00021     XmlQuerySet(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         if (!mValid)
00027             return;
00028         Util::StringParser p(href);
00029         p.Eat("/cases/");
00030         mCaseId = p.GetString('/', true);
00031         if (mCaseId.empty())
00032             mValid = false;
00033     }
00034 
00035     virtual
00036     ~XmlQuerySet()
00037     {
00038     }
00039 
00040     bool
00041     Valid() const
00042     {
00043         return mValid;
00044     }
00045 
00046     String
00047     GetLink() const
00048     {
00049         return mHref.AsString();
00050     }
00051 
00052     String
00053     GetId() const
00054     {
00055         return mId;
00056     }
00057 
00058     String
00059     GetVideosLink() const
00060     {
00061         return mVideosLink;
00062     }
00063 
00064     String
00065     GetCaseId() const
00066     {
00067         return mCaseId;
00068     }
00069 
00070 private:
00071 
00072     /* sample file:
00073 
00074 <?xml version="1.0" encoding="utf-8"?>
00075 <querySet 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>all</id>
00077   <entityType>QuerySet</entityType>
00078   <memo />
00079   <videos xlink:type="simple" xlink:href="http://192.168.137.129:7878/services/vds/cases/16/videos/?querySet=all" entityType="VideoList" />
00080   <caseID>16</caseID>
00081 </querySet>
00082     */
00083 
00084     void
00085     ReadData(String docName, Util::IOBuffer* ioBuf)
00086     {
00087         mValid = false;
00088         Persistency::XmlFileReader reader;
00089         DOMDocument* doc = reader.Read(docName, ioBuf);
00090         if (!doc)
00091             return;
00092         DOMNode* qSet = GetChildNode(doc, "querySet", true);
00093         DOMNode* id = GetChildNode(qSet, "id", true);
00094         mId = GetElementValue(id);
00095         ILOG_DEBUG("id = " << mId);
00096 
00097         DOMNode* videos = GetChildNode(qSet, "videos", true);
00098         mVideosLink = GetAttributeValue(videos, "xlink:href");
00099         ILOG_DEBUG("videos = " << mVideosLink);
00100         mValid = true;
00101     }
00102 
00103     // data
00104 
00105     Href   mHref;
00106     String mId;
00107     String mVideosLink;
00108     String mCaseId;
00109     bool   mValid;
00110 
00111     ILOG_VAR_DEC;
00112 
00113 };
00114 
00115 ILOG_VAR_INIT(XmlQuerySet, Impala.Core.IDash);
00116 
00117 } // namespace IDash
00118 } // namespace Core
00119 } // namespace Impala
00120 
00121 #endif

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