00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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 <H5Cpp.h>
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;
00038 bool separateFile;
00039 void createHDF5File();
00040 void openHDF5File();
00041 void readSimpleParameter();
00042 void writeSimpleParameter();
00043 void collectParameter(std::map<std::string, double>& sp, std::map<std::string, std::vector<double> >& vp, std::map<std::string, std::vector<std::vector<double> > >& mp, bool collectAlsoSeparateGroup=false);
00044
00045 virtual ~Group();
00046
00050 void writeXML();
00051
00055 void readXML();
00056
00061 void writeH5();
00062
00065 void readH5();
00066
00067 public:
00069 Group();
00070
00072 std::string getClassName() { return "Group"; }
00073
00075 void setExpand(bool expand) { expandStr=(expand==true)?"true":"false"; }
00076
00077 bool getExpand() { return expandStr=="true"?true:false; }
00078
00080 void addObject(Object* object);
00081
00082 std::vector<Object*> getObjects() {
00083 return object;
00084 }
00085
00087 void setSeparateFile(bool sepFile) { separateFile=sepFile; }
00088
00089 bool getSeparateFile() { return separateFile; }
00090
00093 std::string getFileName() { return fileName; }
00094
00095 std::string getFullName(bool includingFileName=false, bool stopAtSeparateFile=false);
00096
00099 void setFileName(const std::string &fn) { fileName=fn; }
00100
00104 void write(bool writeXMLFile=true, bool writeH5File=true);
00105
00109 void read(bool readXMLFile=true, bool readH5File=true);
00110
00114 void terminate();
00115
00117 virtual void initializeUsingXML(MBXMLUtils::TiXmlElement *element);
00118
00119 MBXMLUtils::TiXmlElement* writeXMLFile(MBXMLUtils::TiXmlNode *parent);
00120
00122 Group* getSeparateGroup() { return separateFile?this:parent->getSeparateGroup(); }
00123
00125 Group* getTopLevelGroup() { return parent==NULL?this:parent->getTopLevelGroup(); }
00126
00127 double getScalarParameter(std::string name);
00128 std::vector<double> getVectorParameter(std::string name);
00129 std::vector<std::vector<double> > getMatrixParameter(std::string name);
00130 };
00131
00132 }
00133
00134 #endif