CombiningOutputComponent.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013-2016, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_INPUT_COMBININGOUTPUTCOMPONENT_H
#define SURGSIM_INPUT_COMBININGOUTPUTCOMPONENT_H
#include <boost/thread/mutex.hpp>
#include <functional>
#include <memory>
#include <string>
#include <vector>
#include "SurgSim/DataStructures/DataGroup.h"
#include "SurgSim/Input/OutputComponent.h"
namespace SurgSim
{
namespace Input
{
SURGSIM_STATIC_REGISTRATION(CombiningOutputComponent);
class CombiningOutputComponent : public SurgSim::Input::OutputComponent
{
public:
typedef std::function<bool(const std::vector<std::shared_ptr<SurgSim::Input::OutputComponent>>&,
SurgSim::DataStructures::DataGroup*)> FunctorType;
explicit CombiningOutputComponent(const std::string& name);
virtual ~CombiningOutputComponent();
SURGSIM_CLASSNAME(SurgSim::Input::CombiningOutputComponent);
void setData(const SurgSim::DataStructures::DataGroup& dataGroup) override;
std::vector<std::shared_ptr<SurgSim::Framework::Component>> getOutputs() const;
void setOutputs(const std::vector<std::shared_ptr<SurgSim::Framework::Component>>& outputs);
void setCombiner(FunctorType combiner);
bool requestOutput(const std::string& device, SurgSim::DataStructures::DataGroup* outputData) override;
private:
std::vector<std::weak_ptr<SurgSim::Input::OutputComponent>> m_outputs;
FunctorType m_combiner;
boost::mutex m_mutex;
};
}; // namespace Input
}; // namespace SurgSim
#endif
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
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Input::CombiningOutputComponent::getOutputs
std::vector< std::shared_ptr< SurgSim::Framework::Component > > getOutputs() const
Definition: CombiningOutputComponent.cpp:103
DataGroup.h
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
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::setData
void setData(const SurgSim::DataStructures::DataGroup &dataGroup) override
Sets the output data.
Definition: CombiningOutputComponent.cpp:98
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::OutputComponent
OutputComponents connect SceneElements to devices, facilitating data transfer from a SceneElement to ...
Definition: OutputComponent.h:39
SurgSim::Input::CombiningOutputComponent::setOutputs
void setOutputs(const std::vector< std::shared_ptr< SurgSim::Framework::Component >> &outputs)
Definition: CombiningOutputComponent.cpp:117
SurgSim::Input::CombiningOutputComponent::setCombiner
void setCombiner(FunctorType combiner)
Set the function to do the combining.
Definition: CombiningOutputComponent.cpp:132
SurgSim::DataStructures::DataGroup
A collection of NamedData objects.
Definition: DataGroup.h:68
SurgSim::Input::CombiningOutputComponent::SURGSIM_CLASSNAME
SURGSIM_CLASSNAME(SurgSim::Input::CombiningOutputComponent)
SurgSim::Input::CombiningOutputComponent::m_mutex
boost::mutex m_mutex
The mutex that protects the outputs.
Definition: CombiningOutputComponent.h:80
OutputComponent.h
SurgSim::Input::CombiningOutputComponent::CombiningOutputComponent
CombiningOutputComponent(const std::string &name)
Constructor.
Definition: CombiningOutputComponent.cpp:85
SurgSim::Input::CombiningOutputComponent
CombiningOutputComponents is-a OutputComponent that takes one or more OutputComponents and combines t...
Definition: CombiningOutputComponent.h:40
SurgSim::Input::CombiningOutputComponent::~CombiningOutputComponent
virtual ~CombiningOutputComponent()
Destructor.
Definition: CombiningOutputComponent.cpp:94