nidas  v1.2-1520
DOMable.h
Go to the documentation of this file.
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4; -*-
2 // vim: set shiftwidth=4 softtabstop=4 expandtab:
3 /*
4  ********************************************************************
5  ** NIDAS: NCAR In-situ Data Acquistion Software
6  **
7  ** 2004, Copyright University Corporation for Atmospheric Research
8  **
9  ** This program is free software; you can redistribute it and/or modify
10  ** it under the terms of the GNU General Public License as published by
11  ** the Free Software Foundation; either version 2 of the License, or
12  ** (at your option) any later version.
13  **
14  ** This program is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  ** GNU General Public License for more details.
18  **
19  ** The LICENSE.txt file accompanying this software contains
20  ** a copy of the GNU General Public License. If it is not found,
21  ** write to the Free Software Foundation, Inc.,
22  ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  **
24  ********************************************************************
25 */
26 
27 #ifndef NIDAS_CORE_DOMABLE_H
28 #define NIDAS_CORE_DOMABLE_H
29 
31 
32 #include "DOMObjectFactory.h"
33 #include "XDOM.h"
34 #include "XMLStringConverter.h"
35 
36 #include <xercesc/util/XMLUniDefs.hpp>
37 #include <xercesc/util/XMLString.hpp>
38 #include <xercesc/dom/DOMDocument.hpp>
39 #include <xercesc/dom/DOMNode.hpp>
40 #include <xercesc/dom/DOMElement.hpp>
41 #include <xercesc/dom/DOMException.hpp>
42 #include <xercesc/dom/DOMNamedNodeMap.hpp>
43 
44 namespace nidas { namespace core {
45 
51 class DOMable {
52 public:
53 
57  virtual ~DOMable() {}
58 
62  virtual void fromDOMElement(const xercesc::DOMElement*)
63  throw(nidas::util::InvalidParameterException) = 0;
64 
68  virtual xercesc::DOMElement*
69  toDOMParent(xercesc::DOMElement* parent,bool complete) const
70  throw(xercesc::DOMException);
71 
75  virtual xercesc::DOMElement*
76  toDOMElement(xercesc::DOMElement* node,bool complete) const
77  throw(xercesc::DOMException);
78 
79  static const XMLCh* getNamespaceURI() {
81  xercesc::XMLString::transcode(
82  "http://www.eol.ucar.edu/nidas");
83  return namespaceURI;
84  }
85 
86 private:
87  static XMLCh* namespaceURI;
88 
89 };
90 
91 }} // namespace nidas namespace core
92 
151 #define NIDAS_CREATOR_FUNCTION(CLASSNAME) \
152 extern "C" {\
153  nidas::core::DOMable* create_nidas_dynld_##CLASSNAME()\
154  {\
155  return new nidas::dynld::CLASSNAME();\
156  }\
157 }
158 
165 #define NIDAS_CREATOR_FUNCTION_NS(NS,CLASSNAME) \
166 extern "C" {\
167  nidas::core::DOMable* create_nidas_dynld_##NS##_##CLASSNAME()\
168  {\
169  return new nidas::dynld::NS::CLASSNAME();\
170  }\
171 }
172 
173 #endif
static const XMLCh * getNamespaceURI()
Definition: DOMable.h:79
virtual void fromDOMElement(const xercesc::DOMElement *)=0
Initialize myself from a xercesc::DOMElement.
virtual xercesc::DOMElement * toDOMParent(xercesc::DOMElement *parent, bool complete) const
Create a DOMElement and append it to the parent.
Definition: DOMable.cc:41
virtual xercesc::DOMElement * toDOMElement(xercesc::DOMElement *node, bool complete) const
Add my content into a DOMElement.
Definition: DOMable.cc:66
Interface of an object that can be instantiated from a DOM element, via the fromDOMElement method...
Definition: DOMable.h:51
virtual ~DOMable()
Virtual destructor.
Definition: DOMable.h:57
static XMLCh * namespaceURI
Definition: DOMable.h:87