FunctionBehavior.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2016, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_BLOCKS_FUNCTIONBEHAVIOR_H
17 #define SURGSIM_BLOCKS_FUNCTIONBEHAVIOR_H
18 
19 #include <functional>
20 #include <string>
21 
23 
24 
25 namespace SurgSim
26 {
27 namespace Blocks
28 {
29 
30 SURGSIM_STATIC_REGISTRATION(FunctionBehavior);
31 
72 {
73 public:
76  explicit FunctionBehavior(const std::string& name);
77 
79 
82  void setFunction(std::function<void(double)> function);
83 
86  void setTargetManagerType(int type);
87 
88  int getTargetManagerType() const override;
89 
90  void update(double dt) override;
91 
92 private:
93  bool doInitialize() override;
94 
95  bool doWakeUp() override;
96 
99 
101  std::function<void(double)> m_function;
102 };
103 
104 };
105 };
106 
107 #endif // SURGSIM_BLOCKS_FUNCTIONBEHAVIOR_H
SurgSim::Blocks::FunctionBehavior::update
void update(double dt) override
Update the behavior.
Definition: FunctionBehavior.cpp:35
SurgSim::Blocks::FunctionBehavior::doWakeUp
bool doWakeUp() override
Interface to be implemented by derived classes.
Definition: FunctionBehavior.cpp:70
SurgSim::Blocks::FunctionBehavior::getTargetManagerType
int getTargetManagerType() const override
Specifies which manger will handle this behavior.
Definition: FunctionBehavior.cpp:47
SurgSim::Blocks::FunctionBehavior::m_function
std::function< void(double)> m_function
The function to run in update.
Definition: FunctionBehavior.h:101
SurgSim::Blocks::FunctionBehavior::doInitialize
bool doInitialize() override
Interface to be implemented by derived classes.
Definition: FunctionBehavior.cpp:58
SurgSim::Framework::Behavior
Behaviors perform actions.
Definition: Behavior.h:41
SurgSim::Blocks::FunctionBehavior::FunctionBehavior
FunctionBehavior(const std::string &name)
Constructor.
Definition: FunctionBehavior.cpp:28
SurgSim
Definition: CompoundShapeToGraphics.cpp:30
SurgSim::Blocks::FunctionBehavior::setFunction
void setFunction(std::function< void(double)> function)
Set the function to run in this behavior's update.
Definition: FunctionBehavior.cpp:52
SurgSim::Blocks::FunctionBehavior::setTargetManagerType
void setTargetManagerType(int type)
Set which manager will handle this behavior.
Definition: FunctionBehavior.cpp:40
SurgSim::Blocks::FunctionBehavior::m_targetManager
int m_targetManager
The manager type that will handle this behavior.
Definition: FunctionBehavior.h:98
SurgSim::Blocks::FunctionBehavior
A Behavior that can run any callable target in its update function.
Definition: FunctionBehavior.h:72
string
string(TOUPPER ${DEVICE} DEVICE_UPPER_CASE) option(BUILD_DEVICE_$
Definition: CMakeLists.txt:38
Behavior.h
SurgSim::Blocks::FunctionBehavior::SURGSIM_CLASSNAME
SURGSIM_CLASSNAME(SurgSim::Blocks::FunctionBehavior)