OutputComponent.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_OUTPUTCOMPONENT_H
#define SURGSIM_INPUT_OUTPUTCOMPONENT_H
#include <string>
#include <memory>
#include "SurgSim/DataStructures/DataGroup.h"
#include "SurgSim/Framework/LockedContainer.h"
#include "SurgSim/Framework/Representation.h"
#include "SurgSim/Input/OutputProducerInterface.h"
namespace SurgSim
{
namespace Input
{
class DeviceInterface;
SURGSIM_STATIC_REGISTRATION(OutputComponent);
class OutputComponent : public SurgSim::Framework::Representation, public OutputProducerInterface
{
public:
explicit OutputComponent(const std::string& name);
virtual ~OutputComponent();
SURGSIM_CLASSNAME(SurgSim::Input::OutputComponent);
void setDeviceName(const std::string& deviceName);
std::string getDeviceName() const;
virtual void setData(const SurgSim::DataStructures::DataGroup& dataGroup);
virtual bool doInitialize();
virtual bool doWakeUp();
bool requestOutput(const std::string& device, SurgSim::DataStructures::DataGroup* outputData) override;
private:
std::string m_deviceName;
SurgSim::Framework::LockedContainer<SurgSim::DataStructures::DataGroup> m_lastOutput;
bool m_haveData;
};
}; // namespace Input
}; // namespace SurgSim
#endif
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Input::OutputComponent::doWakeUp
virtual bool doWakeUp()
Overridden from Component, do nothing.
Definition: OutputComponent.cpp:59
DataGroup.h
SurgSim::Input::OutputProducerInterface
Interface for a producer that generates device output updates (forces, status LED state...
Definition: OutputProducerInterface.h:33
SurgSim::Input::OutputComponent::~OutputComponent
virtual ~OutputComponent()
Destructor.
Definition: OutputComponent.cpp:37
SurgSim::Input::OutputComponent::getDeviceName
std::string getDeviceName() const
Gets device name.
Definition: OutputComponent.cpp:64
SurgSim::Input::OutputComponent::requestOutput
bool requestOutput(const std::string &device, SurgSim::DataStructures::DataGroup *outputData) override
Asks the producer to provide output state to the device.
Definition: OutputComponent.cpp:69
SurgSim::Input::OutputComponent::setDeviceName
void setDeviceName(const std::string &deviceName)
Set name of the device of output component.
Definition: OutputComponent.cpp:41
LockedContainer.h
SurgSim::Input::OutputComponent::setData
virtual void setData(const SurgSim::DataStructures::DataGroup &dataGroup)
Sets the output data.
Definition: OutputComponent.cpp:48
Representation.h
SurgSim::Input::OutputComponent::m_haveData
bool m_haveData
True if there is data available.
Definition: OutputComponent.h:78
SurgSim::Input::OutputComponent::OutputComponent
OutputComponent(const std::string &name)
Constructor.
Definition: OutputComponent.cpp:29
SurgSim::Input::OutputComponent
OutputComponents connect SceneElements to devices, facilitating data transfer from a SceneElement to ...
Definition: OutputComponent.h:39
SurgSim::Input::OutputComponent::doInitialize
virtual bool doInitialize()
Overridden from Component, do nothing.
Definition: OutputComponent.cpp:54
SurgSim::Input::OutputComponent::m_lastOutput
SurgSim::Framework::LockedContainer< SurgSim::DataStructures::DataGroup > m_lastOutput
Thread safe container of most recent output data.
Definition: OutputComponent.h:75
SurgSim::Input::OutputComponent::SURGSIM_CLASSNAME
SURGSIM_CLASSNAME(SurgSim::Input::OutputComponent)
SurgSim::DataStructures::DataGroup
A collection of NamedData objects.
Definition: DataGroup.h:68
OutputProducerInterface.h
SurgSim::Input::OutputComponent::m_deviceName
std::string m_deviceName
Name of the device to which this output component connects.
Definition: OutputComponent.h:72
SurgSim::Framework::LockedContainer< SurgSim::DataStructures::DataGroup >
SurgSim::Framework::Representation
Representations are manifestations of a SceneElement.
Definition: Representation.h:33