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 <openmbvcppinterface/objectfactory.h>
27 #include <hdf5serie/group.h>
28 #include <mbxmlutilshelper/dom.h>
29 #include <utility>
30 #include <vector>
31 
32 namespace OpenMBV {
33 
34  using Index = int;
35 
36 #ifndef SWIG // SWIG can not parse this (swig bug?). However it is not needed for the swig interface -> removed for swig
37  const MBXMLUtils::NamespaceURI OPENMBV("http://www.mbsim-env.de/OpenMBV");
38 #endif
39 
40  class Group;
41 
43  class Object
44 #ifndef SWIG
45  // with swig we do not need any access to fmatvec::Atom members. To avoid problems with other projects
46  // deriving from fmatvec::Atomm we skip this completely from swig processing.
47  : virtual public fmatvec::Atom
48 #endif
49  {
50  friend class Group;
51  protected:
52  std::string name;
53  std::string enableStr, boundingBoxStr;
54  std::string ID; // Note: the ID is metadata and stored as a processing instruction in XML
55  std::string environmentStr;
56  std::weak_ptr<Group> parent;
57 
58  virtual void createHDF5File()=0;
59  virtual void openHDF5File()=0;
60  H5::GroupBase *hdf5Group{nullptr};
61  std::string fullName;
62 
63  Object();
64  ~Object() override;
65  public:
67  void setEnable(bool enable) { enableStr=(enable)?"true":"false"; }
68 
69  bool getEnable() { return enableStr=="true"?true:false; }
70 
72  void setBoundingBox(bool bbox) { boundingBoxStr=(bbox)?"true":"false"; }
73 
74  bool getBoundingBox() { return boundingBoxStr=="true"?true:false; }
75 
77  void setName(const std::string& name_) { name=name_; }
78 
79  std::string getName() { return name; }
80 
82  virtual std::string getFullName();
83 
86  void setEnvironment(bool env) { environmentStr=(env)?"true":"false"; }
87 
89  bool getEnvironment();
90 
92  virtual void initializeUsingXML(xercesc::DOMElement *element);
93 
94  virtual xercesc::DOMElement *writeXMLFile(xercesc::DOMNode *parent);
95 
97  std::shared_ptr<Group> getTopLevelGroup();
98 
99  std::weak_ptr<Group> getParent() { return parent; }
100 
101  H5::GroupBase *getHDF5Group() { return hdf5Group; };
102 
104  std::string getID() const { return ID; }
106  void setID(std::string ID_) { ID=std::move(ID_); }
107 
108  };
109 
110 }
111 
112 #endif
void setName(const std::string &name_)
Definition: object.h:77
bool getEnvironment()
Definition: object.cc:97
void setEnvironment(bool env)
Definition: object.h:86
void setBoundingBox(bool bbox)
Definition: object.h:72
void setEnable(bool enable)
Definition: object.h:67
void setID(std::string ID_)
Definition: object.h:106
virtual std::string getFullName()
Definition: object.cc:44
Definition: object.h:43
std::string getID() const
Definition: object.h:104
std::shared_ptr< Group > getTopLevelGroup()
Definition: object.cc:93
virtual void initializeUsingXML(xercesc::DOMElement *element)
Definition: object.cc:55
Definition: group.h:30