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 program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program 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
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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  typedef int Index;
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  bool selected{false}; // Note: the selected flag is metadata and not stored in XML but used by OpenMBVGUI
57  std::weak_ptr<Group> parent;
58 
59  virtual void createHDF5File()=0;
60  virtual void openHDF5File()=0;
61  H5::GroupBase *hdf5Group{nullptr};
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(bool includingFileName=false);
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 
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 
109  bool getSelected() const { return selected; }
111  void setSelected(bool selected_) { selected=selected_; }
112  };
113 
114 }
115 
116 #endif
bool getSelected() const
Definition: object.h:109
void setName(const std::string &name_)
Definition: object.h:77
bool getEnvironment()
Definition: object.cc:94
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(bool includingFileName=false)
Definition: object.cc:44
void setSelected(bool selected_)
Definition: object.h:111
Definition: object.h:43
std::string getID() const
Definition: object.h:104
std::shared_ptr< Group > getTopLevelGroup()
Definition: object.cc:90
virtual void initializeUsingXML(xercesc::DOMElement *element)
Definition: object.cc:52
Definition: group.h:30