Go to the documentation of this file.
16 #ifndef SURGSIM_DATASTRUCTURES_NAMEDDATA_H
17 #define SURGSIM_DATASTRUCTURES_NAMEDDATA_H
28 namespace DataStructures
38 static const char*
const BUTTON_0 =
"button0";
39 static const char*
const BUTTON_1 =
"button1";
40 static const char*
const BUTTON_2 =
"button2";
41 static const char*
const BUTTON_3 =
"button3";
42 static const char*
const BUTTON_4 =
"button4";
43 static const char*
const TOOLDOF =
"toolDof";
45 static const char*
const POSE =
"pose";
46 static const char*
const INPUT_POSE =
"inputPose";
48 static const char*
const ANGULAR_VELOCITY =
"angularVelocity";
49 static const char*
const LINEAR_VELOCITY =
"linearVelocity";
50 static const char*
const INPUT_ANGULAR_VELOCITY =
"inputAngularVelocity";
51 static const char*
const INPUT_LINEAR_VELOCITY =
"inputLinearVelocity";
53 static const char*
const FORCE =
"force";
54 static const char*
const TORQUE =
"torque";
56 static const char*
const DAMPER_JACOBIAN =
"damperJacobian";
57 static const char*
const SPRING_JACOBIAN =
"springJacobian";
59 static const char*
const IS_HOMED =
"isHomed";
60 static const char*
const IS_ORIENTATION_HOMED =
"isOrientationHomed";
61 static const char*
const IS_POSITION_HOMED =
"isPositionHomed";
63 static const char*
const DIGITAL_INPUT_PREFIX =
"digitalInput";
64 static const char*
const DIGITAL_OUTPUT_PREFIX =
"digitalOutput";
65 static const char*
const TIMER_INPUT_PREFIX =
"timerInput";
66 static const char*
const TIMER_OUTPUT_PREFIX =
"timerOutput";
67 static const char*
const ANALOG_INPUT_PREFIX =
"analogInput";
68 static const char*
const ANALOG_OUTPUT_PREFIX =
"analogOutput";
70 static const char*
const PROJECTION_MATRIX =
"projectionMatix";
71 static const char*
const LEFT_PROJECTION_MATRIX =
"leftProjectionMatix";
72 static const char*
const RIGHT_PROJECTION_MATRIX =
"rightProjectionMatix";
74 static const char*
const KEY =
"key";
101 template <
typename T>
112 inline explicit NamedData(std::shared_ptr<const IndexDirectory> directory);
118 inline explicit NamedData(
const std::vector<std::string>& names);
177 inline std::shared_ptr<const IndexDirectory>
getDirectory()
const;
194 inline bool hasEntry(
int index)
const;
210 inline bool hasData(
int index)
const;
229 inline bool get(
int index, T* value)
const;
247 inline bool set(
int index,
const T& value);
256 inline bool set(
int index, T&& value);
279 inline bool reset(
int index);
293 inline size_t size()
const;
304 template <
typename N>
330 #endif // SURGSIM_DATASTRUCTURES_NAMEDDATA_H
int getIndex(const std::string &name) const
Given a name, return the corresponding index (or -1).
Definition: NamedData-inl.h:133
size_t size() const
Check the number of existing entries.
Definition: NamedData-inl.h:318
NamedData & operator=(const NamedData &namedData)
Copy the data from another object.
Definition: NamedData-inl.h:62
void resetAll()
Invalidate all entries— mark everything as not containing any valid data.
Definition: NamedData-inl.h:312
Definition: CompoundShapeToGraphics.cpp:29
std::shared_ptr< const IndexDirectory > getDirectory() const
Return the object's layout directory, which is its collection of names and indices.
Definition: NamedData-inl.h:127
A templated dictionary in which data can be accessed by name or index, with immutable names & indices...
Definition: NamedData.h:102
NamedData()
Create an empty object, with no associated names and indices yet.
Definition: NamedData-inl.h:30
void copy(const NamedData< N > &source, const NamedDataCopyMap &map)
Copy the data from another NamedData, based on a map of indices.
Definition: NamedData-inl.h:331
bool hasData(int index) const
Check whether the entry with the specified index contains valid data.
Definition: NamedData-inl.h:169
std::vector< bool > m_isDataValid
The array storing whether the data is currently valid.
Definition: NamedData.h:320
std::unordered_map< int, int > NamedDataCopyMap
The type used for copying values between two NamedData objects that cannot assign to each other.
Definition: NamedData.h:32
std::shared_ptr< const IndexDirectory > m_directory
The mapping between names and indices.
Definition: NamedData.h:314
bool set(int index, const T &value)
Record the data for an entry specified by an index.
Definition: NamedData-inl.h:220
bool hasEntry(int index) const
Check whether the object contains an entry with the specified index.
Definition: NamedData-inl.h:153
std::vector< T > m_data
The array of values.
Definition: NamedData.h:317
bool get(int index, T *value) const
Given an index, get the corresponding value.
Definition: NamedData-inl.h:190
int getNumEntries() const
Check the number of existing entries.
Definition: NamedData-inl.h:324
std::string getName(int index) const
Given an index, return the corresponding name (or "").
Definition: NamedData-inl.h:143
bool isValid() const
Check if the object has been initialized, which means it has a set of entries (i.e....
Definition: NamedData-inl.h:121
void cacheIndex(const std::string &name, int *index) const
Caches an entry's index if it is not already cached.
Definition: NamedData-inl.h:349
string(TOUPPER ${DEVICE} DEVICE_UPPER_CASE) option(BUILD_DEVICE_$
Definition: CMakeLists.txt:38
bool reset(int index)
Invalidate an entry— mark it as not containing any valid data.
Definition: NamedData-inl.h:282