All Classes Namespaces Functions Variables Typedefs Enumerations Pages
group.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_GROUP_H_
21 #define _OPENMBV_GROUP_H_
22 
23 #include <openmbvcppinterface/object.h>
24 #include <vector>
25 #include <map>
26 
27 namespace OpenMBV {
28 
30  class Group : public Object
31 #ifndef SWIG
32  , public std::enable_shared_from_this<Group>
33 #endif
34  {
35  friend class Body;
36  friend class Object;
37  friend class ObjectFactory;
38  protected:
39  std::vector<std::shared_ptr<Object> > object;
40  std::string expandStr;
41  std::string fileName; // the file name of the .ombv.xml file of this separateFile Group including the absolute or relatvie path
42  bool separateFile;
43  std::shared_ptr<H5::File> hdf5File;
44  void createHDF5File();
45  void openHDF5File();
46 
47  Group();
48  virtual ~Group();
49 
53  void writeXML();
54 
58  void readXML();
59 
64  void writeH5();
65 
68  void readH5();
69 
70  public:
72  std::string getClassName() { return "Group"; }
73 
75  void setExpand(bool expand) { expandStr=(expand==true)?"true":"false"; }
76 
77  bool getExpand() { return expandStr=="true"?true:false; }
78 
80  void addObject(std::shared_ptr<Object> object);
81 
82  std::vector<std::shared_ptr<Object> >& getObjects() {
83  return object;
84  }
85 
87  void setSeparateFile(bool sepFile) { separateFile=sepFile; }
88 
89  bool getSeparateFile() { return separateFile; }
90  std::shared_ptr<H5::File>& getHDF5File() { return hdf5File; }
91 
94  std::string getFileName() { return fileName; }
95 
96  std::string getFullName(bool includingFileName=false, bool stopAtSeparateFile=false);
97 
100  void setFileName(const std::string &fn) { fileName=fn; }
101 
105  void write(bool writeXMLFile=true, bool writeH5File=true);
106 
110  void read(bool readXMLFile=true, bool readH5File=true);
111 
115  void terminate();
116 
118  virtual void initializeUsingXML(xercesc::DOMElement *element);
119 
120  xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *parent);
121 
123  std::shared_ptr<Group> getSeparateGroup() {
124  return separateFile?shared_from_this():parent.lock()->getSeparateGroup();
125  }
126 
128  std::shared_ptr<Group> getTopLevelGroup() {
129  std::shared_ptr<Group> p=parent.lock();
130  return !p?shared_from_this():p->getTopLevelGroup();
131  }
132  };
133 
134 }
135 
136 #endif
void terminate()
Definition: group.cc:169
std::shared_ptr< Group > getTopLevelGroup()
Definition: group.h:128
std::string getClassName()
Definition: group.h:72
void writeH5()
Definition: group.cc:160
void readXML()
Definition: group.cc:198
Definition: objectfactory.h:36
virtual void initializeUsingXML(xercesc::DOMElement *element)
Definition: group.cc:177
std::shared_ptr< Group > getSeparateGroup()
Definition: group.h:123
void setFileName(const std::string &fn)
Definition: group.h:100
void setExpand(bool expand)
Definition: group.h:75
void write(bool writeXMLFile=true, bool writeH5File=true)
Definition: group.cc:222
std::string getFullName(bool includingFileName=false, bool stopAtSeparateFile=false)
Definition: group.cc:59
void read(bool readXMLFile=true, bool readH5File=true)
Definition: group.cc:269
Definition: object.h:50
void addObject(std::shared_ptr< Object > object)
Definition: group.cc:50
void writeXML()
Definition: group.cc:148
void readH5()
Definition: group.cc:207
std::string getFileName()
Definition: group.h:94
Definition: group.h:30
void setSeparateFile(bool sepFile)
Definition: group.h:87
Definition: body.h:31

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML