4S Device Communication Module Collection  Version 0.6-SNAPSHOT
Full documentation of the modules in the 4SDC collection (aimed at 4SDC module developers)
FSYS::Handle Class Reference

Class that holds and assigns handles. More...

#include <handle.h>

+ Inheritance diagram for FSYS::Handle:
+ Collaboration diagram for FSYS::Handle:

Public Member Functions

 Handle (void)
 Default constructor. More...
 
 Handle (Handle &ref)
 Copy constructor for handle object. More...
 
 Handle (const Handle &ref)
 Copy constructor for handle object. More...
 
Handleoperator= (Handle const &theOtherOne)
 
bool operator== (Handle const &compareTo) const
 Equality comparator. More...
 
bool operator!= (Handle const &compareTo) const
 Not equalify operator. More...
 
bool operator> (Handle const &compareTo) const
 Greater than operator ('>') More...
 
bool operator< (Handle const &compareTo) const
 Less than operator ('<') More...
 

Static Public Member Functions

static HandlebroadCastHandle (void)
 Generic broadcast handle. More...
 
static Handlenull (void)
 The null handle. More...
 

Private Member Functions

int64_t getNextHandle (void)
 Function to generate a unique handle. More...
 

Private Attributes

int64_t handle
 The actual value of the handle.
 

Detailed Description

If you instantiate this class with the default constructor then it will represent a unique handle, if you copy the object, the copy will contain the same handle.

It is possible to compare handles with the '!=', '==', '<' and '>' operators, you should not rely on any special meaning of the '<' and '>' operators, as future implemenations might change the order of created handles.

Two special handels are exposed by the class - the "null" and "broadcast" handles - you can not rely on how these two handles are ordered compared to other handles (e.g. null() will not always compare smaller to other handles, nor will null() compare equal to 0.

Constructor & Destructor Documentation

FSYS::Handle::Handle ( void  )
inline

Using the default constructor will assign a unique handle to this object.

If you do not wish to have new handle assigned, then you can get a more efficient program by initializing the handle to the null handle. This will prevent a global mutex lock to be taken.

FSYS::Handle myHandle(FSYS::null());
.
.
.
myHandle = arg.handle;

is more efficient than:

FSYS::Handle myHandle;
.
.
.
myHandle = arg.handle;

The most efficient is thou:

FSYS::Handle myHandle(arg.handle)

+ Here is the call graph for this function:

FSYS::Handle::Handle ( Handle ref)
inline
Parameters
refThe handle that should be copied
FSYS::Handle::Handle ( const Handle ref)
inline
Parameters
refThe handle that should be copied

Member Function Documentation

FSYS::Handle & FSYS::Handle::broadCastHandle ( void  )
static

The meaning of this handle is specified by its use, from the handle class's point of view, it is just a unique handle.

Returns
The broadcast handle

+ Here is the caller graph for this function:

int64_t FSYS::Handle::getNextHandle ( void  )
private

This function will generate a unique handle, it will do this by returning a 64 bit handle - after all ~10¹⁹ handles with a positive value are used the function will assert, if a millon handles are used a second, this is not estimated to happen within the lifetime of a single instance of the application.

Returns
A unique handle

+ Here is the caller graph for this function:

FSYS::Handle & FSYS::Handle::null ( void  )
static

The null handle is the handle that doesn't represent a valid handle.

Two null handles will compare equal to each other, and not equal to other handles.

The null handle does not compare equal to the integer value 0, you should consider it equally likely that it compares smaller or greater to any other specific handle, and because it compares smaller to one handle, it doesn't mean that it compares smaller to evey other handle.

The actuall value of the handle, will be dependend on a number of factors both compile time and excecution time wise.

Returns
The null handle

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool FSYS::Handle::operator!= ( Handle const &  compareTo) const
inline

Operator will return true if the two handles are different, e.g. not copies of each other.

Parameters
comparToThe handle this handle should be compared to
Returns
bool FSYS::Handle::operator< ( Handle const &  compareTo) const
inline
See also
operator>

If the greater than operator ('>') returns true for a relationship between A and B, then this function will return true when the arguments are swapped. So if A > B evaluates to true, then B < A will also evaluate to true.

Parameters
compareToThe handle that this handle should be compared to
Returns
true or false as described in the description of this function

+ Here is the call graph for this function:

bool FSYS::Handle::operator== ( Handle const &  compareTo) const
inline

Operator will return true if the two handles are copies of each other

Parameters
compareToThe handle this handle should be compared to
Returns
True if the two handles are copies, False if not.
bool FSYS::Handle::operator> ( Handle const &  compareTo) const
inline

While handles don't have any meaning relation ship between them, except equality or not equality it is still helpfull for certian algorithms / data structures to be able to order them.

You should not rely on any connection between the creation order of the handles and how they compare to each other.

The only thing you can rely on is that if we you have three handles A, B and C - and A > B evaluates to true and B > C evaluates to true then A > C will also evaluate to true and in that case B > A, C > B and C > A will also all evaluate to false.

Parameters
compareToThe handle that should be compared to this handle
Returns
true or false as descriped in the description of this function

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