Yate
Public Member Functions | List of all members
SharedVars Class Reference

Atomic access and operations to shared variables. More...

#include <yatengine.h>

Inheritance diagram for SharedVars:
Mutex Lockable

Public Member Functions

 SharedVars ()
 
void get (const String &name, String &rval)
 
void set (const String &name, const char *val)
 
bool create (const String &name, const char *val=0)
 
void clear (const String &name)
 
bool exists (const String &name)
 
unsigned int inc (const String &name, unsigned int wrap=0)
 
unsigned int dec (const String &name, unsigned int wrap=0)
 
- Public Member Functions inherited from Mutex
 Mutex (bool recursive=false, const char *name=0)
 
 Mutex (const Mutex &original)
 
 ~Mutex ()
 
Mutexoperator= (const Mutex &original)
 
virtual bool lock (long maxwait=-1)
 
virtual bool unlock ()
 
virtual bool locked () const
 
const char * owner () const
 
bool recursive () const
 
- Public Member Functions inherited from Lockable
virtual ~Lockable ()
 
virtual bool check (long maxwait=-1)
 
virtual bool unlockAll ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Mutex
static int count ()
 
static int locks ()
 
static bool efficientTimedLock ()
 
- Static Public Member Functions inherited from Lockable
static void wait (unsigned long maxwait)
 
static unsigned long wait ()
 
static void startUsingNow ()
 
static void enableSafety (bool safe=true)
 
static bool safety ()
 

Detailed Description

Atomic access and operations to shared variables.

Class that implements atomic / locked access and operations to its shared variables

Constructor & Destructor Documentation

SharedVars ( )
inline

Constructor

Member Function Documentation

void clear ( const String name)

Clear a variable

Parameters
nameName of the variable to clear
bool create ( const String name,
const char *  val = 0 
)

Create and set a variable only if the variable is not already set

Parameters
nameName of the variable to set
valNew value to assign to a variable
Returns
True if a new variable was created
unsigned int dec ( const String name,
unsigned int  wrap = 0 
)

Atomically decrement a variable as unsigned integer

Parameters
nameName of the variable
wrapValue to wrap around at, zero disables (stucks at zero)
Returns
Value of the variable after decrement, zero if it was not defined or not numeric
bool exists ( const String name)

Check if a variable exists

Parameters
nameName of the variable
Returns
True if the variable exists
void get ( const String name,
String rval 
)

Get the string value of a variable

Parameters
nameName of the variable
rvalString to return the value into
unsigned int inc ( const String name,
unsigned int  wrap = 0 
)

Atomically increment a variable as unsigned integer

Parameters
nameName of the variable
wrapValue to wrap around at, zero disables
Returns
Value of the variable before increment, zero if it was not defined or not numeric
void set ( const String name,
const char *  val 
)

Set the string value of a variable

Parameters
nameName of the variable to set
valNew value to assign to a variable

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