20 #ifndef _OPENMBV_OBJECT_H_
21 #define _OPENMBV_OBJECT_H_
23 #include <fmatvec/atom.h>
26 #include <openmbvcppinterface/objectfactory.h>
27 #include <hdf5serie/group.h>
28 #include <mbxmlutilshelper/dom.h>
29 #include <xercesc/dom/DOMElement.hpp>
30 #include <xercesc/dom/DOMNode.hpp>
31 #include <xercesc/dom/DOMDocument.hpp>
34 namespace XERCES_CPP_NAMESPACE {
41 #ifndef SWIG // SWIG can not parse this (swig bug?). However it is not needed for the swig interface -> removed for swig
42 const MBXMLUtils::NamespaceURI OPENMBV(
"http://www.mbsim-env.de/OpenMBV");
52 std::string enableStr, boundingBoxStr;
55 boost::weak_ptr<Group> parent;
57 virtual void createHDF5File()=0;
58 virtual void openHDF5File()=0;
60 virtual void terminate()=0;
70 void setEnable(
bool enable) { enableStr=(enable==
true)?
"true":
"false"; }
72 bool getEnable() {
return enableStr==
"true"?
true:
false; }
75 void setBoundingBox(
bool bbox) { boundingBoxStr=(bbox==
true)?
"true":
"false"; }
77 bool getBoundingBox() {
return boundingBoxStr==
"true"?
true:
false; }
80 void setName(
const std::string& name_) { name=name_; }
82 std::string getName() {
return name; }
85 virtual std::string
getFullName(
bool includingFileName=
false,
bool stopAtSeparateFile=
false);
90 virtual xercesc::DOMElement *writeXMLFile(xercesc::DOMNode *parent);
98 boost::weak_ptr<Group> getParent() {
return parent; }
103 std::string
getID()
const {
return ID; }
105 void setID(std::string ID_) { ID=ID_; }
113 static double getDouble(xercesc::DOMElement *e);
114 static std::vector<double> getVec(xercesc::DOMElement *e,
unsigned int rows=0);
115 static std::vector<std::vector<double> > getMat(xercesc::DOMElement *e,
unsigned int rows=0,
unsigned int cols=0);
116 static std::vector<int> getIntVec(xercesc::DOMElement *e,
unsigned int rows=0);
118 static std::string numtostr(
int i) { std::ostringstream oss; oss << i;
return oss.str(); }
119 static std::string numtostr(
double d) { std::ostringstream oss; oss << d;
return oss.str(); }
123 static void addElementText(xercesc::DOMElement *parent,
const MBXMLUtils::FQN &name,
const T &value) {
124 std::ostringstream oss;
126 xercesc::DOMElement *ele = MBXMLUtils::D(parent->getOwnerDocument())->createElement(name);
127 ele->insertBefore(parent->getOwnerDocument()->createTextNode(MBXMLUtils::X()%oss.str()), NULL);
128 parent->insertBefore(ele, NULL);
130 static void addElementText(xercesc::DOMElement *parent,
const MBXMLUtils::FQN &name,
double value,
double def);
131 static void addElementText(xercesc::DOMElement *parent,
const MBXMLUtils::FQN &name,
const std::vector<double> &value);
132 static void addElementText(xercesc::DOMElement *parent,
const MBXMLUtils::FQN &name,
const std::vector<std::vector<double> > &value);
133 static void addElementText(xercesc::DOMElement *parent,
const MBXMLUtils::FQN &name,
const std::vector<int> &value);
136 static void addAttribute(xercesc::DOMNode *node, std::string name, T value) {
137 xercesc::DOMElement *ele =
dynamic_cast<xercesc::DOMElement*
>(node);
139 std::ostringstream oss;
141 MBXMLUtils::E(ele)->setAttribute(name, oss.str());
146 static void addAttribute(xercesc::DOMNode *node, std::string name, T value, std::string def) {
147 if(value!=def) addAttribute(node, name, value);
151 static std::vector<double> toVector(std::string str);
152 static std::vector<std::vector<double> > toMatrix(std::string str);
153 static std::vector<int> toIntVector(std::string str);
154 static std::vector<std::vector<int> > toIntMatrix(std::string str);
void setName(const std::string &name_)
Definition: object.h:80
void setBoundingBox(bool bbox)
Definition: object.h:75
void setEnable(bool enable)
Definition: object.h:70
void setID(std::string ID_)
Definition: object.h:105
boost::shared_ptr< Group > getSeparateGroup()
Definition: object.cc:205
virtual std::string getFullName(bool includingFileName=false, bool stopAtSeparateFile=false)
Definition: object.cc:43
bool getSelected() const
Definition: object.h:108
void setSelected(bool selected_)
Definition: object.h:110
virtual std::string getClassName()=0
std::string getID() const
Definition: object.h:103
boost::shared_ptr< Group > getTopLevelGroup()
Definition: object.cc:209
virtual void initializeUsingXML(xercesc::DOMElement *element)
Definition: object.cc:51