opensurgsim
FunctionBehavior.h
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 
22 #include "SurgSim/Framework/Behavior.h"
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 
78  SURGSIM_CLASSNAME(SurgSim::Blocks::FunctionBehavior);
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 
98  int m_targetManager;
99 
101  std::function<void(double)> m_function;
102 };
103 
104 };
105 };
106 
107 #endif // SURGSIM_BLOCKS_FUNCTIONBEHAVIOR_H
int getTargetManagerType() const override
Specifies which manger will handle this behavior.
Definition: FunctionBehavior.cpp:47
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
A Behavior that can run any callable target in its update function.
Definition: FunctionBehavior.h:71
FunctionBehavior(const std::string &name)
Constructor.
Definition: FunctionBehavior.cpp:28
void setFunction(std::function< void(double)> function)
Set the function to run in this behavior&#39;s update.
Definition: FunctionBehavior.cpp:52
void setTargetManagerType(int type)
Set which manager will handle this behavior.
Definition: FunctionBehavior.cpp:40
Behaviors perform actions.
Definition: Behavior.h:40
void update(double dt) override
Update the behavior.
Definition: FunctionBehavior.cpp:35