openmbvcppinterface  3.1.0
OpenMBV C++ Interface
group.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_GROUP_H_
21#define _OPENMBV_GROUP_H_
22
23#include <openmbvcppinterface/objectfactory.h>
24#include <openmbvcppinterface/object.h>
25#include <vector>
26#include <map>
27
28namespace OpenMBV {
29
31 class Group : public Object
32#ifndef SWIG
33 , public std::enable_shared_from_this<Group>
34#endif
35 {
36 friend class Body;
37 friend class Object;
38 friend class ObjectFactory;
39 protected:
40 std::vector<std::shared_ptr<Object> > object;
41 std::string expandStr;
42 boost::filesystem::path fileName; // the file name of the .ombvx file including the absolute or relatvie path
43 std::shared_ptr<H5::File> hdf5File;
44 std::function<void()> closeRequestCallback;
45 std::function<void()> refreshCallback;
46 void createHDF5File() override;
47 void openHDF5File() override;
48
49 Group();
50 ~Group() override = default;
51
52 std::shared_ptr<xercesc::DOMDocument> writeXMLDoc();
56 void writeXML();
57
61 void readXML();
62
63 public:
65 void setExpand(bool expand) { expandStr=(expand)?"true":"false"; }
66
67 bool getExpand() { return expandStr=="true"?true:false; }
68
70 void addObject(const std::shared_ptr<Object>& newObject);
71
72 std::vector<std::shared_ptr<Object> >& getObjects() {
73 return object;
74 }
75
76 std::shared_ptr<H5::File>& getHDF5File() { return hdf5File; }
77
79 std::string getFileName() { return fileName.string(); }
80
81 std::string getFullName() override;
82
84 void setFileName(const boost::filesystem::path &fn) { fileName=fn; }
85
90 void write(bool writeXMLFile=true, bool writeH5File=true, bool embedXMLInH5=false);
91
93 void read();
94
96 void enableSWMR();
97
99 void flushIfRequested();
100
102 void refresh();
103
105 void requestFlush();
106
108 void setCloseRequestCallback(const std::function<void()> &closeRequestCallback_) { closeRequestCallback=closeRequestCallback_; }
109
112 void setRefreshCallback(const std::function<void()> &refreshCallback_) { refreshCallback=refreshCallback_; }
113
115 void initializeUsingXML(xercesc::DOMElement *element) override;
116
117 xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *parent) override;
118
120 std::shared_ptr<Group> getTopLevelGroup() {
121 std::shared_ptr<Group> p=parent.lock();
122 return !p?shared_from_this():p->getTopLevelGroup();
123 }
124 };
125
126}
127
128#endif
Definition: body.h:32
Definition: group.h:35
void setCloseRequestCallback(const std::function< void()> &closeRequestCallback_)
Definition: group.h:108
void readXML()
Definition: group.cc:142
void addObject(const std::shared_ptr< Object > &newObject)
Definition: group.cc:50
void refresh()
Definition: group.cc:208
void flushIfRequested()
Definition: group.cc:204
void write(bool writeXMLFile=true, bool writeH5File=true, bool embedXMLInH5=false)
Definition: group.cc:160
void initializeUsingXML(xercesc::DOMElement *element) override
Definition: group.cc:119
void writeXML()
Definition: group.cc:115
void setExpand(bool expand)
Definition: group.h:65
void setFileName(const boost::filesystem::path &fn)
Definition: group.h:84
std::string getFullName() override
Definition: group.cc:59
std::shared_ptr< Group > getTopLevelGroup()
Definition: group.h:120
void setRefreshCallback(const std::function< void()> &refreshCallback_)
Definition: group.h:112
void requestFlush()
Definition: group.cc:212
void read()
Definition: group.cc:217
void enableSWMR()
Definition: group.cc:199
std::string getFileName()
Definition: group.h:79
Definition: objectfactory.h:38
Definition: object.h:48