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 {
43 #ifndef SWIG // SWIG can not parse this (swig bug?). However it is not needed for the swig interface -> removed for swig
60 std::string enableStr, boundingBoxStr;
63 std::weak_ptr<Group> parent;
65 virtual void createHDF5File()=0;
66 virtual void openHDF5File()=0;
68 virtual void terminate()=0;
78 void setEnable(
bool enable) { enableStr=(enable==
true)?
"true":
"false"; }
80 bool getEnable() {
return enableStr==
"true"?
true:
false; }
83 void setBoundingBox(
bool bbox) { boundingBoxStr=(bbox==
true)?
"true":
"false"; }
85 bool getBoundingBox() {
return boundingBoxStr==
"true"?
true:
false; }
88 void setName(
const std::string& name_) { name=name_; }
90 std::string getName() {
return name; }
93 virtual std::string
getFullName(
bool includingFileName=
false,
bool stopAtSeparateFile=
false);
98 virtual xercesc::DOMElement *writeXMLFile(xercesc::DOMNode *parent);
106 std::weak_ptr<Group> getParent() {
return parent; }
111 std::string
getID()
const {
return ID; }
113 void setID(std::string ID_) { ID=ID_; }
121 static int getInt(xercesc::DOMElement *e);
122 static double getDouble(xercesc::DOMElement *e);
123 static std::vector<double> getVec(xercesc::DOMElement *e,
unsigned int rows=0);
124 static std::vector<std::vector<double> > getMat(xercesc::DOMElement *e,
unsigned int rows=0,
unsigned int cols=0);
125 static std::vector<int> getIntVec(xercesc::DOMElement *e,
unsigned int rows=0);
127 static std::string numtostr(
int i) { std::ostringstream oss; oss << i;
return oss.str(); }
128 static std::string numtostr(
double d) { std::ostringstream oss; oss << d;
return oss.str(); }
132 static void addElementText(xercesc::DOMElement *parent,
const MBXMLUtils::FQN &name,
const T &value) {
133 std::ostringstream oss;
135 xercesc::DOMElement *ele = MBXMLUtils::D(parent->getOwnerDocument())->createElement(name);
136 ele->insertBefore(parent->getOwnerDocument()->createTextNode(
MBXMLUtils::X()%oss.str()), NULL);
137 parent->insertBefore(ele, NULL);
139 static void addElementText(xercesc::DOMElement *parent,
const MBXMLUtils::FQN &name,
double value,
double def);
140 static void addElementText(xercesc::DOMElement *parent,
const MBXMLUtils::FQN &name,
const std::vector<double> &value);
141 static void addElementText(xercesc::DOMElement *parent,
const MBXMLUtils::FQN &name,
const std::vector<std::vector<double> > &value);
142 static void addElementText(xercesc::DOMElement *parent,
const MBXMLUtils::FQN &name,
const std::vector<int> &value);
145 static void addAttribute(xercesc::DOMNode *node, std::string name, T value) {
146 xercesc::DOMElement *ele =
dynamic_cast<xercesc::DOMElement*
>(node);
148 std::ostringstream oss;
150 MBXMLUtils::E(ele)->setAttribute(name, oss.str());
155 static void addAttribute(xercesc::DOMNode *node, std::string name, T value, std::string def) {
156 if(value!=def) addAttribute(node, name, value);
160 static std::vector<double> toVector(std::string str);
161 static std::vector<std::vector<double> > toMatrix(std::string str);
162 static std::vector<int> toIntVector(std::string str);
163 static std::vector<std::vector<int> > toIntMatrix(std::string str);
void setName(const std::string &name_)
Definition: object.h:88
void setBoundingBox(bool bbox)
Definition: object.h:83
void setEnable(bool enable)
Definition: object.h:78
void setID(std::string ID_)
Definition: object.h:113
virtual std::string getFullName(bool includingFileName=false, bool stopAtSeparateFile=false)
Definition: object.cc:43
bool getSelected() const
Definition: object.h:116
void setSelected(bool selected_)
Definition: object.h:118
virtual std::string getClassName()=0
std::shared_ptr< Group > getSeparateGroup()
Definition: object.cc:218
std::string getID() const
Definition: object.h:111
std::shared_ptr< Group > getTopLevelGroup()
Definition: object.cc:222
virtual void initializeUsingXML(xercesc::DOMElement *element)
Definition: object.cc:51