opensurgsim
CombiningOutputComponent.h
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013-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_INPUT_COMBININGOUTPUTCOMPONENT_H
17 #define SURGSIM_INPUT_COMBININGOUTPUTCOMPONENT_H
18 
19 #include <boost/thread/mutex.hpp>
20 #include <functional>
21 #include <memory>
22 #include <string>
23 #include <vector>
24 
25 #include "SurgSim/DataStructures/DataGroup.h"
26 #include "SurgSim/Input/OutputComponent.h"
27 
28 namespace SurgSim
29 {
30 namespace Input
31 {
32 
33 SURGSIM_STATIC_REGISTRATION(CombiningOutputComponent);
34 
41 {
42 public:
43  typedef std::function<bool(const std::vector<std::shared_ptr<SurgSim::Input::OutputComponent>>&,
45 
48  explicit CombiningOutputComponent(const std::string& name);
49 
51  virtual ~CombiningOutputComponent();
52 
54 
55  void setData(const SurgSim::DataStructures::DataGroup& dataGroup) override;
56 
58  std::vector<std::shared_ptr<SurgSim::Framework::Component>> getOutputs() const;
59 
62  void setOutputs(const std::vector<std::shared_ptr<SurgSim::Framework::Component>>& outputs);
63 
67  void setCombiner(FunctorType combiner);
68 
69  bool requestOutput(const std::string& device, SurgSim::DataStructures::DataGroup* outputData) override;
70 
71 private:
73  std::vector<std::weak_ptr<SurgSim::Input::OutputComponent>> m_outputs;
74 
77  FunctorType m_combiner;
78 
80  boost::mutex m_mutex;
81 };
82 
83 }; // namespace Input
84 }; // namespace SurgSim
85 
86 #endif
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
std::vector< std::shared_ptr< SurgSim::Framework::Component > > getOutputs() const
Definition: CombiningOutputComponent.cpp:103
void setData(const SurgSim::DataStructures::DataGroup &dataGroup) override
Sets the output data.
Definition: CombiningOutputComponent.cpp:98
bool requestOutput(const std::string &device, SurgSim::DataStructures::DataGroup *outputData) override
Asks the producer to provide output state to the device.
Definition: CombiningOutputComponent.cpp:137
OutputComponents connect SceneElements to devices, facilitating data transfer from a SceneElement to ...
Definition: OutputComponent.h:41
void setOutputs(const std::vector< std::shared_ptr< SurgSim::Framework::Component >> &outputs)
Definition: CombiningOutputComponent.cpp:117
void setCombiner(FunctorType combiner)
Set the function to do the combining.
Definition: CombiningOutputComponent.cpp:132
A collection of NamedData objects.
Definition: DataGroup.h:68
CombiningOutputComponent(const std::string &name)
Constructor.
Definition: CombiningOutputComponent.cpp:85
CombiningOutputComponents is-a OutputComponent that takes one or more OutputComponents and combines t...
Definition: CombiningOutputComponent.h:40
virtual ~CombiningOutputComponent()
Destructor.
Definition: CombiningOutputComponent.cpp:94