INTRODUCTION
Overview
Download and Install
Documentation
Publications

REPOSITORY
Libraries

DEVELOPER
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         

gbxsickacfr::gbxiceutilacfr::Store< Type > Class Template Reference

Thread-safe storage for a single data objects. More...

#include <store.h>

List of all members.

Public Member Functions

bool isEmpty () const
bool isNewData () const
 Returns TRUE if the data in the Store has not been accessed with get yet.
void set (const Type &obj)
 Sets the contents of the Store.
void get (Type &obj) const
int getNext (Type &obj, int timeoutMs=-1) const
 Waits until the next update and returns the new value. If the Store is empty, getNext blocks until the Store is set and returns the new value. By default, there is no timeout (negative value). Returns 0 if successful.
void purge ()


Detailed Description

template<class Type>
class gbxsickacfr::gbxiceutilacfr::Store< Type >

Thread-safe storage for a single data objects.

This container is similar to a circular Buffer of size one but with two differences:

  • a copy of the data is always available, yet the user knows when new data has arrived by calling isNewData
  • getNext returns the new data arrives (not when the buffer is non-empty.

Write to it with set. Read its contents with get. Trying to read from an empty Store raises an gbxsickacfr::gbxutilacfr::Exception.

Note:
Replaces the deprecated Proxy class.
See also:
Buffer, Notify


Member Function Documentation

template<class Type>
void gbxsickacfr::gbxiceutilacfr::Store< Type >::get ( Type &  obj  )  const

Returns the contents of the Store. This operation makes the data in the Store "not new", i.e. isNewData returns FALSE. Calls to get when the Store is empty raises an gbxsickacfr::gbxutilacfr::Exception exception.

template<class Type>
int gbxsickacfr::gbxiceutilacfr::Store< Type >::getNext ( Type &  obj,
int  timeoutMs = -1 
) const

Waits until the next update and returns the new value. If the Store is empty, getNext blocks until the Store is set and returns the new value. By default, there is no timeout (negative value). Returns 0 if successful.

If timeout is set to a positive value (in milliseconds) and the wait times out, the function returns -1 and the object argument itself is not touched. In the rare event of spurious wakeup, the return value is 1.

template<class Type>
bool gbxsickacfr::gbxiceutilacfr::Store< Type >::isEmpty (  )  const

Returns TRUE if there's something in the Store. The Store starts its life empty but after the object is set once, it will be non-empty again until purge is called.

template<class Type>
void gbxsickacfr::gbxiceutilacfr::Store< Type >::purge (  ) 

Makes the Store empty.

See also:
isEmpty


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

Generated for GearBox by  doxygen 1.4.5