CombiningOutputComponent.h
Go to the documentation of this file.
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 
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 
78 
80  boost::mutex m_mutex;
81 };
82 
83 }; // namespace Input
84 }; // namespace SurgSim
85 
86 #endif
SurgSim::Input::CombiningOutputComponent::m_outputs
std::vector< std::weak_ptr< SurgSim::Input::OutputComponent > > m_outputs
The OutputComponents that will be combined.
Definition: CombiningOutputComponent.h:73
SurgSim::Input::CombiningOutputComponent::~CombiningOutputComponent
virtual ~CombiningOutputComponent()
Destructor.
Definition: CombiningOutputComponent.cpp:94
SurgSim::Input::CombiningOutputComponent
CombiningOutputComponents is-a OutputComponent that takes one or more OutputComponents and combines t...
Definition: CombiningOutputComponent.h:40
SurgSim::Input::CombiningOutputComponent::SURGSIM_CLASSNAME
SURGSIM_CLASSNAME(SurgSim::Input::CombiningOutputComponent)
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Input::CombiningOutputComponent::setCombiner
void setCombiner(FunctorType combiner)
Set the function to do the combining.
Definition: CombiningOutputComponent.cpp:132
SurgSim::Input::CombiningOutputComponent::CombiningOutputComponent
CombiningOutputComponent(const std::string &name)
Constructor.
Definition: CombiningOutputComponent.cpp:85
SurgSim::DataStructures::DataGroup
A collection of NamedData objects.
Definition: DataGroup.h:68
OutputComponent.h
SurgSim::Input::CombiningOutputComponent::m_mutex
boost::mutex m_mutex
The mutex that protects the outputs.
Definition: CombiningOutputComponent.h:80
SurgSim::Input::OutputComponent
OutputComponents connect SceneElements to devices, facilitating data transfer from a SceneElement to ...
Definition: OutputComponent.h:39
DataGroup.h
SurgSim::Input::CombiningOutputComponent::requestOutput
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
SurgSim::Input::CombiningOutputComponent::getOutputs
std::vector< std::shared_ptr< SurgSim::Framework::Component > > getOutputs() const
Definition: CombiningOutputComponent.cpp:103
SurgSim::Input::CombiningOutputComponent::FunctorType
std::function< bool(const std::vector< std::shared_ptr< SurgSim::Input::OutputComponent >> &, SurgSim::DataStructures::DataGroup *)> FunctorType
Definition: CombiningOutputComponent.h:44
SurgSim::Input::CombiningOutputComponent::setOutputs
void setOutputs(const std::vector< std::shared_ptr< SurgSim::Framework::Component >> &outputs)
Definition: CombiningOutputComponent.cpp:117
SurgSim::Input::CombiningOutputComponent::setData
void setData(const SurgSim::DataStructures::DataGroup &dataGroup) override
Sets the output data.
Definition: CombiningOutputComponent.cpp:98
SurgSim::Input::CombiningOutputComponent::m_combiner
FunctorType m_combiner
The function that takes the OutputComponents and returns a DataGroup and a bool that specifies whethe...
Definition: CombiningOutputComponent.h:77