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 "fmatvec/fmatvec.h"
00024 #include "fmatvec/atom.h"
00025 #include <xercesc/dom/DOMElement.hpp>
00026 #include <xercesc/dom/DOMNode.hpp>
00027 #include <boost/scoped_ptr.hpp>
00028 
00029 namespace MBSim {
00030 
00036   class Environment : virtual public fmatvec::Atom {
00037     public:
00038       /* INTERFACE FOR DERIVED CLASSES */
00043       virtual void initializeUsingXML(xercesc::DOMElement *element) {}
00044       virtual xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *parent)=0;
00045       /***************************************************/
00046     
00047     protected:
00051       Environment() : Atom() {};
00052 
00056       virtual ~Environment() {};
00057   };
00058 
00064   class MBSimEnvironment : public Environment {
00065     public:
00066       /* INHERITED INTERFACE */
00067       virtual void initializeUsingXML(xercesc::DOMElement *element);
00068       virtual xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *parent);
00069       /***************************************************/
00070 
00071       /* GETTER / SETTER */
00072       static MBSimEnvironment *getInstance() { return instance.get(); }
00073       void setAccelerationOfGravity(const fmatvec::Vec3 &grav_) { grav=grav_; }
00074       const fmatvec::Vec3& getAccelerationOfGravity() const { return grav; }
00075       /***************************************************/
00076     
00077     protected:
00081       static boost::scoped_ptr<MBSimEnvironment> instance;
00082       
00086       MBSimEnvironment() : Environment() {}
00087 
00091       fmatvec::Vec3 grav;
00092   };
00093 
00094 }
00095 
00096 #endif /* _MBSIM_ENVIRONMENT_H_ */
00097