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

XmlJobReference.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_IDash_XmlJobReference_h
00002 #define Impala_Core_IDash_XmlJobReference_h
00003 
00004 #include "Util/XmlDoc.h"
00005 #include "Persistency/XmlFileReader.h"
00006 
00007 namespace Impala
00008 {
00009 namespace Core
00010 {
00011 namespace IDash
00012 {
00013 
00014 
00015 class XmlJobReference : public Util::XmlDoc
00016 {
00017 public:
00018 
00019     XmlJobReference(String href)
00020     {
00021         mHref = href;
00022     }
00023 
00024     XmlJobReference(String docName, Util::IOBuffer* ioBuf)
00025     {
00026         ReadData(docName, ioBuf);
00027     }
00028 
00029     virtual
00030     ~XmlJobReference()
00031     {
00032     }
00033 
00034     // inquiry
00035 
00036     bool
00037     Valid() const
00038     {
00039         return mValid;
00040     }
00041 
00042     String
00043     GetHref()
00044     {
00045         return mHref;
00046     }
00047 
00048     // I/O
00049 
00050     void
00051     Export(Util::IOBuffer* ioBuf)
00052     {
00053         ioBuf->Puts("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>");
00054         ioBuf->Puts("<job xmlns=\"http://www.i-dash.eu/ActionData\"");
00055         ioBuf->Puts("     xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"");
00056         ioBuf->Puts("     xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
00057         ioBuf->Puts("     xmlns:xlink=\"http://www.w3.org/1999/xlink\"");
00058         ioBuf->Puts("     xsi:schemaLocation=\"http://www.i-dash.eu/ActionData http://www.i-dash.eu/Schemas/ActionData/Job.xsd\"");
00059 
00060         ioBuf->Puts("     xlink:type=\"simple\"");
00061         ioBuf->Puts("     xlink:href=\"" + mHref + "\"");
00062         ioBuf->Puts("     />");
00063     }
00064 
00065     String
00066     Export()
00067     {
00068         Util::IOBuffer ioBuf(2048);
00069         Export(&ioBuf);
00070         String res((char*) ioBuf.GetBuffer(), ioBuf.GetPosition());
00071         return res;
00072     }
00073 
00074 private:
00075 
00076     /* sample file:
00077 
00078 <?xml version="1.0" encoding="utf-8"?>
00079 <job xmlns="http://www.i-dash.eu/ActionData"
00080      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
00081      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
00082      xmlns:xlink="http://www.w3.org/1999/xlink"
00083      xsi:schemaLocation="http://www.i-dash.eu/ActionData http://www.i-dash.eu/Schemas/ActionData/Job.xsd"
00084      xlink:type="simple"
00085      xlink:href="http://myserver.i-dash.eu/myNGN/services/myServices/jobs/verySlowJobs/vsj08096"
00086      />
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* job = GetChildNode(doc, "job", true);
00098         mHref = GetAttributeValue(job, "xlink:href");
00099         ILOG_DEBUG("href = " << mHref);
00100         mValid = true;
00101     }
00102 
00103     // data
00104 
00105     String mHref;
00106     bool   mValid;
00107 
00108     ILOG_VAR_DEC;
00109 
00110 };
00111 
00112 ILOG_VAR_INIT(XmlJobReference, Impala.Core.IDash);
00113 
00114 } // namespace IDash
00115 } // namespace Core
00116 } // namespace Impala
00117 
00118 #endif

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