Hosted by: BerliOS Developer Logo

OpenMBV C++ Interface

BerliOS Project Page
/home/user/MBSimWindows/openmbv/openmbvcppinterface/openmbvcppinterface/group.h
00001 /*
00002     OpenMBV - Open Multi Body Viewer.
00003     Copyright (C) 2009 Markus Friedrich
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00020 #ifndef _OPENMBV_GROUP_H_
00021 #define _OPENMBV_GROUP_H_
00022 
00023 #include <openmbvcppinterface/object.h>
00024 #include <vector>
00025 #include <map>
00026 #include <boost/shared_ptr.hpp>
00027 
00028 namespace OpenMBV {
00029 
00031   class Group : public Object {
00032     friend class Body;
00033     friend class Object;
00034     protected:
00035       std::vector<Object*> object;
00036       std::string expandStr;
00037       std::string fileName; // the file name of the .ombv.xml file of this separateFile Group including the absolute or relatvie path
00038       bool separateFile;
00039       boost::shared_ptr<H5::File> hdf5File;
00040       void createHDF5File();
00041       void openHDF5File();
00042 
00043       virtual ~Group();
00044 
00048       void writeXML();
00049 
00053       void readXML();
00054       
00059       void writeH5();
00060 
00063       void readH5();
00064 
00065     public:
00067       Group();
00068 
00070       std::string getClassName() { return "Group"; }
00071 
00073       void setExpand(bool expand) { expandStr=(expand==true)?"true":"false"; }
00074 
00075       bool getExpand() { return expandStr=="true"?true:false; }
00076 
00078       void addObject(Object* object);
00079 
00080       std::vector<Object*> getObjects() {
00081         return object;
00082       }
00083       
00085       void setSeparateFile(bool sepFile) { separateFile=sepFile; }
00086 
00087       bool getSeparateFile() { return separateFile; }
00088       boost::shared_ptr<H5::File> getHDF5File() { return hdf5File; }
00089 
00092       std::string getFileName() { return fileName; }
00093 
00094       std::string getFullName(bool includingFileName=false, bool stopAtSeparateFile=false);
00095       
00098       void setFileName(const std::string &fn) { fileName=fn; }
00099       
00103       void write(bool writeXMLFile=true, bool writeH5File=true);
00104 
00108       void read(bool readXMLFile=true, bool readH5File=true);
00109 
00113       void terminate();
00114 
00116       virtual void initializeUsingXML(xercesc::DOMElement *element);
00117 
00118       xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *parent);
00119 
00121       Group* getSeparateGroup() { return separateFile?this:parent->getSeparateGroup(); }
00122 
00124       Group* getTopLevelGroup() { return parent==NULL?this:parent->getTopLevelGroup(); }
00125   };
00126 
00127 }
00128 
00129 #endif