/usr/include/SurgSim/Devices/MultiAxis/RawMultiAxisScaffold.h is in libopensurgsim-dev 0.7.0-6ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | // 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_MULTIAXIS_RAWMULTIAXISSCAFFOLD_H
#define SURGSIM_DEVICES_MULTIAXIS_RAWMULTIAXISSCAFFOLD_H
#include <memory>
#include <vector>
#include "SurgSim/Framework/Logger.h"
#include "SurgSim/DataStructures/DataGroup.h"
namespace SurgSim
{
namespace Devices
{
class RawMultiAxisDevice;
class RawMultiAxisThread;
class SystemInputDeviceHandle;
/// A class that implements the behavior of RawMultiAxisDevice objects.
///
/// \sa SurgSim::Devices::RawMultiAxisDevice
class RawMultiAxisScaffold
{
public:
/// Constructor.
RawMultiAxisScaffold();
/// Destructor.
~RawMultiAxisScaffold();
/// Gets or creates the scaffold shared by all RawMultiAxisDevice instances.
/// The scaffold is managed using a SharedInstance object, so it will be destroyed when all devices are released.
/// \return the scaffold object.
static std::shared_ptr<RawMultiAxisScaffold> getOrCreateSharedInstance();
private:
/// Internal shared state data type.
struct StateData;
/// Interal per-device information.
struct DeviceData;
friend class RawMultiAxisDevice;
friend class RawMultiAxisThread;
friend struct StateData;
/// Registers the specified device object.
/// If successful, the device object will become connected to an unused hardware device.
///
/// \param device The device object to be used, which should have a unique name.
/// \return True if the initialization succeeds, false if it fails.
bool registerDevice(RawMultiAxisDevice* device);
/// Unregisters the specified device object.
/// The corresponding hardware device will become unused, and can be re-registered later.
///
/// \param device The device object.
/// \return true on success, false on failure.
bool unregisterDevice(const RawMultiAxisDevice* device);
/// Sets the position scale for this device.
void setPositionScale(const RawMultiAxisDevice* device, double scale);
/// Sets the orientation scale for this device.
void setOrientationScale(const RawMultiAxisDevice* device, double scale);
/// Turns on or off the axis dominance setting for this device.
void setAxisDominance(const RawMultiAxisDevice* device, bool onOff);
/// Executes the operations for a single input frame for a single device.
/// Should only be called from the context of the input loop thread.
/// \param info The internal device data.
/// \return true on success.
bool runInputFrame(DeviceData* info);
/// Executes the operations after the last input frame, as the device input loop thread is shutting down.
/// Should only be called from the context of the input loop thread.
/// \param info The internal device data.
/// \return true on success.
bool runAfterLastFrame(DeviceData* info);
/// Updates the device information for a single device.
/// \return true on success.
bool updateDevice(DeviceData* info);
/// Scans hardware that is present in the system, and if an unused device is found, register an object for it.
///
/// \param device The device object to register if an unused device is found.
/// \param [out] numUsedDevicesSeen The number of devices that were found during the scan but were already
/// in use. Can be used if the scan fails to determine the error message that should be displayed.
/// \return true on success.
bool findUnusedDeviceAndRegister(RawMultiAxisDevice* device, int* numUsedDevicesSeen);
/// Register a device object given a device path, if the same path is not already in use.
///
/// \param path A unique system path that can be used to communicate with the device.
/// \param device The device object to register if the index pair is in fact unused.
/// \param [in,out] numUsedDevicesSeen The number of devices that were found during the scan but were
/// already in use; incremented when an unused device is seen.
/// \return true on success.
bool registerIfUnused(const std::string& path, RawMultiAxisDevice* device, int* numUsedDevicesSeen);
/// Creates the input loop thread.
/// \return true on success.
bool createPerDeviceThread(DeviceData* data);
/// Destroys the input loop thread.
/// \return true on success.
bool destroyPerDeviceThread(DeviceData* data);
/// Opens the specified device.
/// \return The system-specific wrapper for the device.
std::unique_ptr<SystemInputDeviceHandle> openDevice(const std::string& path);
/// Builds the data layout for the application input (i.e. device output).
static SurgSim::DataStructures::DataGroup buildDeviceInputData();
/// Logger used by the scaffold and all devices.
std::shared_ptr<SurgSim::Framework::Logger> m_logger;
/// Internal scaffold state.
std::unique_ptr<StateData> m_state;
};
}; // namespace Devices
}; // namespace SurgSim
#endif // SURGSIM_DEVICES_MULTIAXIS_RAWMULTIAXISSCAFFOLD_H
|