MBSim

Project Page
function.h
00001 /* Copyright (C) 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 
00018 #ifndef _MBSIM_FUNCTION_H_
00019 #define _MBSIM_FUNCTION_H_
00020 
00021 #include "mbsim/element.h"
00022 #include "fmatvec/function.h"
00023 #include <string>
00024 #include <xercesc/dom/DOMElement.hpp>
00025 
00026 namespace {
00027   std::string uniqueDummyName(void *p) {
00028     std::stringstream str;
00029     str<<"Function_"<<p;
00030     return str.str();
00031   }
00032 }
00033 
00034 namespace MBSim {
00035 
00037   class FunctionBase : public Element {
00038     public:
00041       FunctionBase() : Element(uniqueDummyName(this)) {}
00042   };
00043 
00047   template<typename Sig>
00048   class Function : public fmatvec::Function<Sig>, public FunctionBase {
00049     public:
00052       Function() : fmatvec::Function<Sig>(), FunctionBase() {}
00053 
00054       void initializeUsingXML(xercesc::DOMElement *element);
00055   };
00056 
00057   template<typename Sig>
00058   void Function<Sig>::initializeUsingXML(xercesc::DOMElement *element) {
00059     if(MBXMLUtils::E(element)->hasAttribute("name"))
00060       THROW_MBSIMERROR("No 'name' attribute allowed for Function's.");
00061   }
00062 
00063 }
00064 
00065 #endif