MBSim

Project Page
environment.h
00001 /* Copyright (C) 2004-2009 MBSim Development Team
00002  * 
00003  * This library is free software; you can redistribute it and/or 
00004  * modify it under the terms of the GNU Lesser General Public 
00005  * License as published by the Free Software Foundation; either 
00006  * version 2.1 of the License, or (at your option) any later version. 
00007  * 
00008  * This library is distributed in the hope that it will be useful, 
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00011  * Lesser General Public License for more details. 
00012  *
00013  * You should have received a copy of the GNU Lesser General Public 
00014  * License along with this library; if not, write to the Free Software 
00015  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
00016  *
00017  * Contact: friedrich.at.gc@googlemail.com
00018  */
00019 
00020 #ifndef _MBSIM_ENVIRONMENT_H_
00021 #define _MBSIM_ENVIRONMENT_H_
00022 
00023 #include "mbxmlutilstinyxml/tinyxml.h"
00024 #include "fmatvec/fmatvec.h"
00025 
00026 namespace MBSim {
00027 
00033   class Environment {
00034     public:
00035       /* INTERFACE FOR DERIVED CLASSES */
00040       virtual void initializeUsingXML(MBXMLUtils::TiXmlElement *element) {}
00041       virtual MBXMLUtils::TiXmlElement* writeXMLFile(MBXMLUtils::TiXmlNode *parent)=0;
00042       /***************************************************/
00043     
00044     protected:
00048       Environment() {};
00049 
00053       virtual ~Environment() {};
00054   };
00055 
00061   class MBSimEnvironment : public Environment {
00062     public:
00063       /* INHERITED INTERFACE */
00064       virtual void initializeUsingXML(MBXMLUtils::TiXmlElement *element);
00065       virtual MBXMLUtils::TiXmlElement* writeXMLFile(MBXMLUtils::TiXmlNode *parent);
00066       /***************************************************/
00067 
00068       /* GETTER / SETTER */
00069       static MBSimEnvironment *getInstance() { return instance?instance:(instance=new MBSimEnvironment); }
00070       void setAccelerationOfGravity(const fmatvec::Vec3 &grav_) { grav=grav_; }
00071       const fmatvec::Vec3& getAccelerationOfGravity() const { return grav; }
00072       /***************************************************/
00073     
00074     protected:
00078       static MBSimEnvironment *instance;
00079       
00083       MBSimEnvironment() : Environment() {}
00084 
00088       fmatvec::Vec3 grav;
00089   };
00090 
00091 }
00092 
00093 #endif /* _MBSIM_ENVIRONMENT_H_ */
00094