FilteredDevice.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, 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_DEVICES_DEVICEFILTERS_FILTEREDDEVICE_H
#define SURGSIM_DEVICES_DEVICEFILTERS_FILTEREDDEVICE_H
#include <boost/thread/shared_mutex.hpp>
#include <memory>
#include <string>
#include <vector>
#include "SurgSim/Input/DeviceInterface.h"
namespace SurgSim
{
namespace Input
{
class InputConsumerInterface;
class OutputProducerInterface;
}
namespace Devices
{
class DeviceFilter;
class FilteredDevice : public Input::DeviceInterface
{
public:
explicit FilteredDevice(const std::string& name);
SURGSIM_CLASSNAME(SurgSim::Devices::FilteredDevice);
virtual ~FilteredDevice();
std::string getName() const override;
bool initialize() override;
bool isInitialized() const override;
bool addInputConsumer(std::shared_ptr<Input::InputConsumerInterface> inputConsumer) override;
bool removeInputConsumer(std::shared_ptr<Input::InputConsumerInterface> inputConsumer) override;
void clearInputConsumers() override;
bool setOutputProducer(std::shared_ptr<Input::OutputProducerInterface> outputProducer) override;
bool removeOutputProducer(std::shared_ptr<Input::OutputProducerInterface> outputProducer) override;
bool hasOutputProducer() override;
void clearOutputProducer() override;
void setDevice(std::shared_ptr<Input::DeviceInterface> device);
void addFilter(std::shared_ptr<DeviceFilter> filter);
const std::vector<std::shared_ptr<Input::DeviceInterface>>& getDevices() const;
bool setDevices(const std::vector<std::shared_ptr<Input::DeviceInterface>>& devices);
private:
bool finalize() override;
void doFinalize();
std::string m_name;
bool m_initialized;
std::vector<std::shared_ptr<Input::DeviceInterface>> m_devices;
boost::shared_mutex m_deviceMutex;
std::shared_ptr<Framework::Logger> m_logger;
};
}; // namespace Devices
}; // namespace SurgSim
#endif // SURGSIM_DEVICES_DEVICEFILTERS_FILTEREDDEVICE_H
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Devices::FilteredDevice::m_name
std::string m_name
The name of this device.
Definition: FilteredDevice.h:90
SurgSim::Devices::FilteredDevice::m_devices
std::vector< std::shared_ptr< Input::DeviceInterface > > m_devices
The devices.
Definition: FilteredDevice.h:98
SurgSim::Devices::FilteredDevice::m_logger
std::shared_ptr< Framework::Logger > m_logger
The logger.
Definition: FilteredDevice.h:104
SurgSim::Devices::FilteredDevice::m_deviceMutex
boost::shared_mutex m_deviceMutex
The mutex to protect access to the devices.
Definition: FilteredDevice.h:101
SurgSim::Devices::FilteredDevice::m_initialized
bool m_initialized
true if initialized and not finalized.
Definition: FilteredDevice.h:93
SurgSim::Devices::FilteredDevice
A DeviceInterface connected in series with one or more DeviceFilters. Useful for serialization.
Definition: FilteredDevice.h:39
SURGSIM_CLASSNAME
#define SURGSIM_CLASSNAME(ClassName)
Declare the class name of a class with the appropriate function header, do not use quotes...
Definition: Macros.h:21
SurgSim::Input::DeviceInterface
Interface used to communicate with user-interface hardware devices.
Definition: DeviceInterface.h:41
DeviceInterface.h