Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

rmBaseArray Class Template Reference

#include <rmBaseArray.h>

Inheritance diagram for rmBaseArray:

IBaseAccessor rmStatusArray rmRefArray List of all members.

Public Methods

 rmBaseArray ()
virtual ~rmBaseArray ()
 rmBaseArray (unsigned long aStartupID)
virtual size_t getCount () const
 returns the current number of elements in the table. More...

virtual T * getElement (unsigned long aID)
 returns a particular entry, not a const. More...

virtual const T * getConstElement (unsigned long aID)
 returns a particular entry as a const. More...

virtual int addElement (const T &aElement, unsigned long aID)
 insert an entry (element) into the table. More...

virtual int newElement (const T &aElement, unsigned long &aID)
 create a new element in the table without aID. More...

virtual int addDefaultElement (unsigned long aID)
 create a default new element. More...

virtual int removeElement (unsigned long aID)
 delete an element. More...

virtual int modifyElement (unsigned long aID, const T &aElement)
 modify an element. More...

virtual unsigned long getNewId (void)
 returns the ID value of the next new element. More...

virtual unsigned long getMaxId (void) const
 
Deprecated:
returns the maximum ID value issued so far.
More...


virtual int findId (unsigned long aID, map< unsigned long, T >::iterator *aPos=0)
 test if an ID is a valid element of the table. More...

virtual int getNextId (unsigned long aID, unsigned long &aNextID)
 find the next valid ID in the table based on the input. More...

virtual int init ()
 initize the table. More...

virtual bool elementIsReady (const T &aElement) const
virtual int getInteger32 (RMAttribute aName, unsigned long aID, long &aValue)
virtual int setInteger32 (RMAttribute aName, unsigned long aID, long aValue)
virtual int getUnsigned (RMAttribute aName, unsigned long aID, unsigned long &aValue)
virtual int setUnsigned (RMAttribute aName, unsigned long aID, unsigned long aValue)
virtual int getUnsigned64 (RMAttribute aName, unsigned long aID, u_int64_t &aValue)
virtual int setUnsigned64 (RMAttribute aName, unsigned long aID, u_int64_t aValue)
virtual int getUUIDString (RMAttribute aName, unsigned long aID, char *aUUIDStr)
virtual int setUUIDString (RMAttribute aName, unsigned long aID, char *aUUIDStr)
virtual int getUUID (RMAttribute aName, unsigned long aID, uuid_t aUUID)
virtual int getString (RMAttribute aName, unsigned long aID, char *&aBuf)
virtual int setString (RMAttribute aName, unsigned long aID, char *aBuf)
virtual int getBinary (RMAttribute aName, unsigned long aID, char *&aBuf, unsigned long &aLength)
virtual int findExactId (unsigned long aID)

Protected Attributes

map< unsigned long, T > mElementArray
 the table which holds all the elements. mElementArray is an associative array (STL map). So the key is the unique ID for every element in this array. More...

unsigned long mMaxId
 the maximum ID issued so far. can be wrapped around. More...

map< unsigned long, T >::iterator mPos
 the last referenced element. This is stored as a cache hoping that subsequent access are to the same element. More...


Detailed Description

template<class T>
class rmBaseArray< T >

The base class template for the ResourceMonitor client library.

This template defines some basic operations that can be performed on entries (elements) in a table.

Each entry (element) is an instance of a certain data type. Elements are referenced by their unique ID number.

Definition at line 69 of file rmBaseArray.h.


Constructor & Destructor Documentation

template<class T>
rmBaseArray< T >::rmBaseArray   [inline]
 

Definition at line 72 of file rmBaseArray.h.

template<class T>
virtual rmBaseArray< T >::~rmBaseArray   [inline, virtual]
 

Definition at line 73 of file rmBaseArray.h.

template<class T>
rmBaseArray< T >::rmBaseArray unsigned long    aStartupID [inline]
 

Definition at line 75 of file rmBaseArray.h.


Member Function Documentation

template<class T>
int rmBaseArray< T >::addDefaultElement unsigned long    aID [virtual]
 

create a default new element.

Implements IBaseAccessor.

Reimplemented in eventQuery.

Definition at line 317 of file rmBaseArray.h.

References addElement.

template<class T>
int rmBaseArray< T >::addElement const T &    aElement,
unsigned long    aID
[virtual]
 

insert an entry (element) into the table.

Add an element, aElement, into the table. Using aID as the unique id number (key value).

Parameters:
aID  A unisgned integer that represents the unique id number of an element.
aElement  a reference to a element whose type is defined by the user.
Precondition:
aID must be unique and less than mMaxId. otherwise this function will fail. aID is obtained through getNewId().
Returns:
0 if successful. RMCLIENT_ERROR_BASE_INSERT if insertion failed.
See also:
getNewId()

Reimplemented in rmRefArray.

Definition at line 259 of file rmBaseArray.h.

References mElementArray, mMaxId, RMCLIENT_ERROR_BASE_ID, RMCLIENT_ERROR_BASE_INSERT, and RMCLIENT_SUCCESS.

Referenced by rmStatusArray::addDefaultElement, addDefaultElement, and newElement.

template<class T>
virtual bool rmBaseArray< T >::elementIsReady const T &    aElement const [inline, virtual]
 

Reimplemented in eventQuery.

Definition at line 125 of file rmBaseArray.h.

Referenced by rmStatusArray::updateStatus.

template<class T>
virtual int rmBaseArray< T >::findExactId unsigned long    aID [inline, virtual]
 

Implements IBaseAccessor.

Definition at line 190 of file rmBaseArray.h.

template<class T>
int rmBaseArray< T >::findId unsigned long    aID,
map< unsigned long, T >::iterator *    aPos = 0
[virtual]
 

test if an ID is a valid element of the table.

Test if aID is a valid id number in this table by searching through the table and find an element which id == aID.

Parameters:
aID  The Unique ID value of this element.
Returns:
0 if successful. RMCLIENT_ERROR_BASE_ID if aID is not valid.
Remarks:
This function also caches the position of the element to mPos.

Definition at line 392 of file rmBaseArray.h.

References mElementArray, mPos, RMCLIENT_ERROR_BASE_ID, and RMCLIENT_SUCCESS.

Referenced by rmRefArray::addRef, rmBaseArray< Monitor >::findExactId, getElement, rmRefArray::modifyElement, modifyElement, rmRefArray::release, rmRefArray::removeElement, and removeElement.

template<class T>
virtual int rmBaseArray< T >::getBinary RMAttribute    aName,
unsigned long    aID,
char *&    aBuf,
unsigned long &    aLength
[inline, virtual]
 

Implements IBaseAccessor.

Definition at line 185 of file rmBaseArray.h.

template<class T>
virtual const T* rmBaseArray< T >::getConstElement unsigned long    aID [inline, virtual]
 

returns a particular entry as a const.

Definition at line 84 of file rmBaseArray.h.

template<class T>
virtual size_t rmBaseArray< T >::getCount   const [inline, virtual]
 

returns the current number of elements in the table.

Implements IBaseAccessor.

Definition at line 78 of file rmBaseArray.h.

template<class T>
T * rmBaseArray< T >::getElement unsigned long    aID [virtual]
 

returns a particular entry, not a const.

Returns the element which (id == aID)

Parameters:
aID  A unisgned integer that represents the unique id number of an element. The returned element is not a const and can be modified.
Returns:
A point to the element in the table, or NULL, if aID is not valid.

Definition at line 228 of file rmBaseArray.h.

References findId.

Referenced by rmBaseArray< Monitor >::getConstElement.

template<class T>
virtual int rmBaseArray< T >::getInteger32 RMAttribute    aName,
unsigned long    aID,
long &    aValue
[inline, virtual]
 

Implements IBaseAccessor.

Reimplemented in eventQuery.

Definition at line 130 of file rmBaseArray.h.

template<class T>
virtual unsigned long rmBaseArray< T >::getMaxId void    const [inline, virtual]
 

Deprecated:
returns the maximum ID value issued so far.

Definition at line 111 of file rmBaseArray.h.

template<class T>
virtual unsigned long rmBaseArray< T >::getNewId void    [inline, virtual]
 

returns the ID value of the next new element.

Implements IBaseAccessor.

Definition at line 105 of file rmBaseArray.h.

Referenced by newElement.

template<class T>
int rmBaseArray< T >::getNextId unsigned long    aID,
unsigned long &    aNextID
[virtual]
 

find the next valid ID in the table based on the input.

Finds the next valid element after the specified id value. Basically, the first element int the table whose id > aID.

This function combined with getConstElement() above can be used as an iterator. For example:

 unsigned long id(0), nid(0);

 while(!getNextId(id, nid)) {
   id = nid;

   const T * element = getConstElement(id);

   \\ do stuff with it here.
 }
Parameters:
aID  The Unique ID value of this element.
aNextID  The pointer to the next valid ID value. If failure, aNextID would be set to 0.
Returns:
0 if successful. RMCLIENT_ERROR_BASE_ID if aID is not valid.
Remarks:
This function also caches the position of the element to mPos.

Implements IBaseAccessor.

Definition at line 448 of file rmBaseArray.h.

References mElementArray, mPos, RMCLIENT_ERROR_BASE_ID, and RMCLIENT_SUCCESS.

template<class T>
virtual int rmBaseArray< T >::getString RMAttribute    aName,
unsigned long    aID,
char *&    aBuf
[inline, virtual]
 

Implements IBaseAccessor.

Reimplemented in eventQuery.

Definition at line 175 of file rmBaseArray.h.

template<class T>
virtual int rmBaseArray< T >::getUnsigned RMAttribute    aName,
unsigned long    aID,
unsigned long &    aValue
[inline, virtual]
 

Implements IBaseAccessor.

Reimplemented in rmGenericMonitorConfig.

Definition at line 140 of file rmBaseArray.h.

template<class T>
virtual int rmBaseArray< T >::getUnsigned64 RMAttribute    aName,
unsigned long    aID,
u_int64_t &    aValue
[inline, virtual]
 

Implements IBaseAccessor.

Reimplemented in rmThresholdMonitorConfig.

Definition at line 150 of file rmBaseArray.h.

template<class T>
virtual int rmBaseArray< T >::getUUID RMAttribute    aName,
unsigned long    aID,
uuid_t    aUUID
[inline, virtual]
 

Implements IBaseAccessor.

Reimplemented in rmGenericMonitorControl.

Definition at line 170 of file rmBaseArray.h.

template<class T>
virtual int rmBaseArray< T >::getUUIDString RMAttribute    aName,
unsigned long    aID,
char *    aUUIDStr
[inline, virtual]
 

Implements IBaseAccessor.

Reimplemented in rmGenericMonitorControl.

Definition at line 160 of file rmBaseArray.h.

template<class T>
virtual int rmBaseArray< T >::init   [inline, virtual]
 

initize the table.

Reimplemented in rmMonitor.

Definition at line 123 of file rmBaseArray.h.

template<class T>
int rmBaseArray< T >::modifyElement unsigned long    aID,
const T &    aElement
[virtual]
 

modify an element.

Modify the element whose id == aID by assigning a new element to this id.

Parameters:
aID  The Unique ID value of this element.
aElement  the element whose data type is defined by the user.
Returns:
0 if successful. RMCLIENT_ERROR_BASE_ID if aID is not valid.

Reimplemented in rmRefArray.

Definition at line 364 of file rmBaseArray.h.

References findId, and RMCLIENT_SUCCESS.

template<class T>
int rmBaseArray< T >::newElement const T &    aElement,
unsigned long &    aID
[virtual]
 

create a new element in the table without aID.

Add an new element (aElement) into the table without sepcifing a ID number. If the pointer aID is provided, then the id value of the newly created element is recorded.

Parameters:
aElement  a reference to a element whose type is defined by the user.
aID  ID value of the new element. This is optional.
Returns:
0 if successful. RMCLIENT_ERROR_BASE_INSERT if insertion failed.
Remarks:
This function is internal to the rmclient library only. It is not exported through the library interface (rmclient.h).

Definition at line 306 of file rmBaseArray.h.

References addElement, and getNewId.

template<class T>
int rmBaseArray< T >::removeElement unsigned long    aID [virtual]
 

delete an element.

Remove the element whose id == aID from the table.

Parameters:
aID  The Unique ID value of this element.
Returns:
0 if successful. RMCLIENT_ERROR_BASE_ID if aID is not valid.

Implements IBaseAccessor.

Reimplemented in eventQuery.

Definition at line 336 of file rmBaseArray.h.

References findId, mElementArray, mPos, and RMCLIENT_SUCCESS.

template<class T>
virtual int rmBaseArray< T >::setInteger32 RMAttribute    aName,
unsigned long    aID,
long    aValue
[inline, virtual]
 

Implements IBaseAccessor.

Reimplemented in eventQuery.

Definition at line 135 of file rmBaseArray.h.

template<class T>
virtual int rmBaseArray< T >::setString RMAttribute    aName,
unsigned long    aID,
char *    aBuf
[inline, virtual]
 

Implements IBaseAccessor.

Reimplemented in eventQuery.

Definition at line 180 of file rmBaseArray.h.

template<class T>
virtual int rmBaseArray< T >::setUnsigned RMAttribute    aName,
unsigned long    aID,
unsigned long    aValue
[inline, virtual]
 

Implements IBaseAccessor.

Reimplemented in rmGenericMonitorConfig.

Definition at line 145 of file rmBaseArray.h.

template<class T>
virtual int rmBaseArray< T >::setUnsigned64 RMAttribute    aName,
unsigned long    aID,
u_int64_t    aValue
[inline, virtual]
 

Implements IBaseAccessor.

Reimplemented in rmThresholdMonitorConfig.

Definition at line 155 of file rmBaseArray.h.

template<class T>
virtual int rmBaseArray< T >::setUUIDString RMAttribute    aName,
unsigned long    aID,
char *    aUUIDStr
[inline, virtual]
 

Implements IBaseAccessor.

Reimplemented in rmGenericMonitorControl.

Definition at line 165 of file rmBaseArray.h.


Member Data Documentation

template<class T>
map<unsigned long, T> rmBaseArray::mElementArray [protected]
 

the table which holds all the elements. mElementArray is an associative array (STL map). So the key is the unique ID for every element in this array.

Definition at line 207 of file rmBaseArray.h.

Referenced by rmRefArray::addElement, addElement, findId, rmBaseArray< Monitor >::getCount, getNextId, rmRefArray::removeElement, removeElement, and rmBaseArray< Monitor >::rmBaseArray.

template<class T>
unsigned long rmBaseArray::mMaxId [protected]
 

the maximum ID issued so far. can be wrapped around.

Definition at line 210 of file rmBaseArray.h.

Referenced by rmRefArray::addElement, addElement, rmBaseArray< Monitor >::getMaxId, rmBaseArray< Monitor >::getNewId, and rmBaseArray< Monitor >::rmBaseArray.

template<class T>
map<unsigned long, T>::iterator rmBaseArray::mPos [protected]
 

the last referenced element. This is stored as a cache hoping that subsequent access are to the same element.

Definition at line 214 of file rmBaseArray.h.

Referenced by findId, getNextId, rmRefArray::removeElement, removeElement, and rmBaseArray< Monitor >::rmBaseArray.


The documentation for this class was generated from the following file:
Generated on Tue Sep 10 16:46:34 2002 for ResourceMonitorSNMPSubagent by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002