SurgSim::DataStructures::BufferedValue< T > Class Template Reference

BufferedValue is a class to enable a representation of two values for one variable, where both values need to be accessible at the same time, one in a thread safe, single threaded context, the other in a thread unsafe context. More...

`#include <SurgSim/DataStructures/BufferedValue.h>`

## Public Member Functions

| BufferedValue ()
| BufferedValue (const T &value)
| ~BufferedValue ()
| Destructor. More...
void | publish ()
| Make the current value the one returned by calls to safeGet. More...
T & | unsafeGet ()
| Get the value. More...
std::shared_ptr< const T > | safeGet () const
| Get the buffered value. More...

## Private Types

typedef boost::shared_lock< boost::shared_mutex > | SharedLock
typedef boost::unique_lock< boost::shared_mutex > | UniqueLock

## Private Attributes

T | m_value
| The raw value. More...
std::shared_ptr< const T > | m_safeValue
| The buffered value. More...
boost::shared_mutex | m_mutex
| The mutex used to lock for reading and writing. More...

## Detailed Description

### template<class T>
class SurgSim::DataStructures::BufferedValue< T >

BufferedValue is a class to enable a representation of two values for one variable, where both values need to be accessible at the same time, one in a thread safe, single threaded context, the other in a thread unsafe context.

Template Parameters

  T | Type that is used for the value.

## Member Typedef Documentation

## SharedLock

template<class T>

typedef boost::shared_lock<boost::shared_mutex> SurgSim::DataStructures::BufferedValue< T >::SharedLock

private

## UniqueLock

template<class T>

typedef boost::unique_lock<boost::shared_mutex> SurgSim::DataStructures::BufferedValue< T >::UniqueLock

private

## Constructor & Destructor Documentation

## BufferedValue() [1/2]

template<class T >

SurgSim::DataStructures::BufferedValue< T >::BufferedValue | ( |  | ) |

## BufferedValue() [2/2]

template<class T>

SurgSim::DataStructures::BufferedValue< T >::BufferedValue | ( | const T & | value | ) |

explicit

Parameters

  value | Default value.

## ~BufferedValue()

template<class T >

SurgSim::DataStructures::BufferedValue< T >::~BufferedValue | ( |  | ) |

Destructor.

## Member Function Documentation

## publish()

template<class T >

void SurgSim::DataStructures::BufferedValue< T >::publish | ( |  | ) |

Make the current value the one returned by calls to safeGet.

## safeGet()

template<class T >

std::shared_ptr< const T > SurgSim::DataStructures::BufferedValue< T >::safeGet | ( |  | ) | const

Get the buffered value.

Returns
  The value at the last call to publish.

## unsafeGet()

template<class T >

T & SurgSim::DataStructures::BufferedValue< T >::unsafeGet | ( |  | ) |

Get the value.

Returns
  A reference to the value.

## Member Data Documentation

## m_mutex

template<class T>

boost::shared_mutex SurgSim::DataStructures::BufferedValue< T >::m_mutex

mutable private

The mutex used to lock for reading and writing.

## m_safeValue

template<class T>

std::shared_ptr<const T> SurgSim::DataStructures::BufferedValue< T >::m_safeValue

private

The buffered value.

## m_value

template<class T>

T SurgSim::DataStructures::BufferedValue< T >::m_value

private

The raw value.

The documentation for this class was generated from the following files:

- SurgSim/DataStructures/BufferedValue.h
- SurgSim/DataStructures/BufferedValue-inl.h