mbsim 4.0.0 MBSim Kernel

function.h
1 /* Copyright (C) MBSim Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17
18 #ifndef _MBSIM_FUNCTION_H_
19 #define _MBSIM_FUNCTION_H_
20
21 #include "mbsim/element.h"
22 #include "fmatvec/function.h"
23 #include <string>
24 #include <xercesc/dom/DOMElement.hpp>
25 #include "mbsim/utils/initconfigenum.h"
26
27 namespace {
28 inline std::string uniqueDummyName(void *p) {
29 std::stringstream str;
30 str<<"Function_"<<p;
31 return str.str();
32 }
33 }
34
35 namespace MBSim {
36
37 extern const InitConfigEnum noDer;
38 extern const InitConfigEnum noDerDer; // this implies noDer
39
41 class FunctionBase : public Element {
42 public:
45 FunctionBase() : Element(uniqueDummyName(this)) { plotFeature[plotRecursive]=false; }
46 virtual Element* getDependency() const { return nullptr; }
47 };
48
52 template<typename Sig>
53 class Function : public virtual fmatvec::Function<Sig>, public FunctionBase {
54 public:
57 Function() : fmatvec::Function<Sig>(), FunctionBase() {}
58
59 void initializeUsingXML(xercesc::DOMElement *element) override;
60 };
61
62 template<typename Sig>
63 void Function<Sig>::initializeUsingXML(xercesc::DOMElement *element) {
64 FunctionBase::initializeUsingXML(element);
65 if(MBXMLUtils::E(element)->hasAttribute("name"))
66 throw MBXMLUtils::DOMEvalException("No 'name' attribute allowed for Function's.", element);
67 }
68
69 }
70
71 #endif
MBSim::Element::plotFeature
PlotFeatureMap plotFeature
plot feature
Definition: element.h:309
MBSim::Element
basic class of MBSim mainly for plotting
Definition: element.h:56
MBXMLUtils::DOMEvalException
MBSim::Function
Definition: contact_kinematics.h:32
MBSim::Function::Function
Function()
Definition: function.h:57
MBSim::FunctionBase::FunctionBase
FunctionBase()
Definition: function.h:45
MBSim::FunctionBase
Definition: function.h:41
MBSim
namespace MBSim
Definition: bilateral_constraint.cc:30