INTRODUCTION
Overview
Download and Install
Documentation
Publications

REPOSITORY
Libraries

DEVELOPER
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         

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)
void peek (Type &obj) const
int getNext (Type &obj, int timeoutMs=-1)
 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 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.

You can use this container for storing smart pointers (e.g. IceUtil smart pointers). In this case the container will only store the pointer and will not perform a deep copy.

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

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

Member Function Documentation

template<class Type>
void gbxiceutilacfr::Store< Type >::get ( Type &  obj  )  [inline]

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 gbxutilacfr::Exception exception.

Referenced by gbxsmartbatteryacfr::OceanServer::getData(), and gbxsmartbatteryacfr::OceanServer::walk().

template<class Type>
int gbxiceutilacfr::Store< Type >::getNext ( Type &  obj,
int  timeoutMs = -1 
) [inline]

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 gbxiceutilacfr::Store< Type >::isEmpty (  )  const [inline]

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.

Referenced by gbxsmartbatteryacfr::OceanServer::getData(), gbxsmartbatteryacfr::OceanServer::haveData(), and gbxsmartbatteryacfr::OceanServer::walk().

template<class Type>
void gbxiceutilacfr::Store< Type >::peek ( Type &  obj  )  const [inline]

Returns the contents of the Store. This operation does not modify anything, i.e. the contents of the store remain "new" (unlike get()). Calls to peek() when the Store is empty raises an gbxutilacfr::Exception exception.

template<class Type >
void gbxiceutilacfr::Store< Type >::purge (  )  [inline]

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