openmbvcppinterface  3.1.0
OpenMBV C++ Interface
object.h
1/*
2 OpenMBV - Open Multi Body Viewer.
3 Copyright (C) 2009 Markus Friedrich
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18*/
19
20#ifndef _OPENMBV_OBJECT_H_
21#define _OPENMBV_OBJECT_H_
22
23#include <fmatvec/atom.h>
24#include <string>
25#include <sstream>
26#include <hdf5serie/group.h>
27#include <mbxmlutilshelper/dom.h>
28#include <utility>
29#include <vector>
30
31namespace OpenMBV {
32
33 using Float = float;
34
35 using Index = int;
36
37#ifndef SWIG // SWIG can not parse this (swig bug?). However it is not needed for the swig interface -> removed for swig
38 const MBXMLUtils::NamespaceURI OPENMBV("http://www.mbsim-env.de/OpenMBV", {"ombv", "openmbv"});
39#endif
40
41 class Group;
42
44 class Object
45#ifndef SWIG
46 // with swig we do not need any access to fmatvec::Atom members. To avoid problems with other projects
47 // deriving from fmatvec::Atomm we skip this completely from swig processing.
48 : virtual public fmatvec::Atom
49#endif
50 {
51 friend class Group;
52 protected:
53 std::string name;
54 std::string enableStr, boundingBoxStr;
55 std::string ID; // Note: the ID is metadata and stored as a processing instruction in XML
56 std::string environmentStr;
57 std::weak_ptr<Group> parent;
58
59 virtual void createHDF5File()=0;
60 virtual void openHDF5File()=0;
61 H5::GroupBase *hdf5Group{nullptr};
62 std::string fullName;
63
64 Object();
65 ~Object() override;
66 public:
68 void setEnable(bool enable) { enableStr=(enable)?"true":"false"; }
69
70 bool getEnable() { return enableStr=="true"?true:false; }
71
73 void setBoundingBox(bool bbox) { boundingBoxStr=(bbox)?"true":"false"; }
74
75 bool getBoundingBox() { return boundingBoxStr=="true"?true:false; }
76
78 void setName(const std::string& name_) { name=name_; }
79
80 std::string getName() { return name; }
81
83 virtual std::string getFullName();
84
87 void setEnvironment(bool env) { environmentStr=(env)?"true":"false"; }
88
90 bool getEnvironment();
91
93 virtual void initializeUsingXML(xercesc::DOMElement *element);
94
95 virtual xercesc::DOMElement *writeXMLFile(xercesc::DOMNode *parent);
96
98 std::shared_ptr<Group> getTopLevelGroup();
99
100 std::weak_ptr<Group> getParent() { return parent; }
101
102 H5::GroupBase *getHDF5Group() { return hdf5Group; };
103
105 std::string getID() const { return ID; }
107 void setID(std::string ID_) { ID=std::move(ID_); }
108
109 };
110
111}
112
113#endif
Definition: group.h:36
Definition: object.h:50
virtual void initializeUsingXML(xercesc::DOMElement *element)
Definition: object.cc:55
void setName(const std::string &name_)
Definition: object.h:78
bool getEnvironment()
Definition: object.cc:97
std::shared_ptr< Group > getTopLevelGroup()
Definition: object.cc:93
void setID(std::string ID_)
Definition: object.h:107
void setBoundingBox(bool bbox)
Definition: object.h:73
virtual std::string getFullName()
Definition: object.cc:44
void setEnvironment(bool env)
Definition: object.h:87
void setEnable(bool enable)
Definition: object.h:68
std::string getID() const
Definition: object.h:105