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

XmlCase.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_IDash_XmlCase_h
00002 #define Impala_Core_IDash_XmlCase_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 XmlCase : public Util::XmlDoc
00018 {
00019 public:
00020 
00021     XmlCase(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     ~XmlCase()
00030     {
00031     }
00032 
00033     bool
00034     Valid() const
00035     {
00036         return mValid;
00037     }
00038 
00039     String
00040     GetId() const
00041     {
00042         return mId;
00043     }
00044 
00045     String
00046     GetVideosLink() const
00047     {
00048         return mVideosLink;
00049     }
00050 
00051 private:
00052 
00053     /* sample file:
00054 
00055 <?xml version="1.0" encoding="utf-8"?>
00056 <case 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">
00057   <id>16</id>
00058   <entityType>Case</entityType>
00059   <memo />
00060   <videos xlink:type="simple" xlink:href="http://146.50.22.23:7878/services/vds/cases/16/videos/" entityType="VideoList" />
00061   <localReference>Gerrit</localReference>
00062   <localGroup>I-Dash</localGroup>
00063   <description>Holliday videos from the set "Gerrit"</description>
00064   <creationDate>2009-05-13T15:04:38.733</creationDate>
00065 </case>
00066     */
00067 
00068     void
00069     ReadData(String docName, Util::IOBuffer* ioBuf)
00070     {
00071         mValid = false;
00072         Persistency::XmlFileReader reader;
00073         DOMDocument* doc = reader.Read(docName, ioBuf);
00074         if (!doc)
00075             return;
00076         DOMNode* casee = GetChildNode(doc, "case", true);
00077         DOMNode* id = GetChildNode(casee, "id", true);
00078         mId = GetElementValue(id);
00079         ILOG_DEBUG("id = " << mId);
00080 
00081         DOMNode* videos = GetChildNode(casee, "videos", true);
00082         mVideosLink = GetAttributeValue(videos, "xlink:href");
00083         ILOG_DEBUG("videos = " << mVideosLink);
00084         mValid = true;
00085     }
00086 
00087     // data
00088 
00089     Href   mHref;
00090     String mId;
00091     String mVideosLink;
00092     bool   mValid;
00093 
00094     ILOG_VAR_DEC;
00095 
00096 };
00097 
00098 ILOG_VAR_INIT(XmlCase, Impala.Core.IDash);
00099 
00100 } // namespace IDash
00101 } // namespace Core
00102 } // namespace Impala
00103 
00104 #endif

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