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

rmRefArray Class Template Reference

#include <rmRefArray.h>

Inheritance diagram for rmRefArray:

rmStatusArray rmBaseArray IBaseAccessor List of all members.

Public Methods

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

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

virtual int removeElement (unsigned long aID)
 remove an element from the table. More...

virtual long addRef (unsigned long aID)
 increment the refCnt. More...

virtual long release (unsigned long aID)
 decrement the refCnt. More...


Detailed Description

template<class T>
class rmRefArray< T >

A template class which inheriets most of its method from rmBaseArray and whose elements are all reference counted.

the data type for this class must have an member called 'refcnt'. refcnt is a integer that records the number of time an element is being used by other elements. the idea is that if an element whose (refcnt > 0), then this element is 'read-only'. it can neither be modified, nor removed. The refCnt can still go up, or down, depending on how many other elements are currently referencing this particular element. The element is only changable when the refCnt is 0.

Definition at line 21 of file rmRefArray.h.


Constructor & Destructor Documentation

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

Definition at line 24 of file rmRefArray.h.

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

Definition at line 25 of file rmRefArray.h.


Member Function Documentation

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

add an element into the table.

Add an element into the table and set refCnt to 0.

Parameters:
aElement  The element whose data type is defined by user.
aID  The unique ID valud of this element.
Precondition:
Call getNewId() to get the id value for this element.
See also:
getNewId()
Returns:
RMCLIENT_SUCCESS is successful. or RMCLIENT_ERROR_BASE_INSERT if failure.
Remarks:
This function overrides the base addElement function.

Reimplemented from rmBaseArray.

Definition at line 59 of file rmRefArray.h.

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

template<class T>
long rmRefArray< T >::addRef unsigned long    aID [virtual]
 

increment the refCnt.

Increment the refCnt of an element whose (id == aID) by 1.

Parameters:
aID  The unique ID valud of this element.
Returns:
refCnt is successful. or -1 if aID is invalid.

Reimplemented in rmGenericMonitorControl.

Definition at line 152 of file rmRefArray.h.

References ACTIVE, and rmBaseArray::findId.

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

modify an element in the table.

Modify an element in the table if refCnt is 0.

Parameters:
aElement  A reference to the element whose data type is defined by user.
aID  The unique ID valud of this element.
Returns:
RMCLIENT_SUCCESS is successful. or RMCLIENT_ERROR_BASE_ID if aID is invalid, or RMCLIENT_ERROR_CC_REFCNT if (refCnt != 0).
Remarks:
This function overrides the base modifyElement function.

Reimplemented from rmBaseArray.

Definition at line 94 of file rmRefArray.h.

References rmBaseArray::findId, RMCLIENT_ERROR_CC_REFCNT, and RMCLIENT_SUCCESS.

template<class T>
long rmRefArray< T >::release unsigned long    aID [virtual]
 

decrement the refCnt.

Decrement the refCnt of an element whose (id == aID) by 1.

Parameters:
aID  The unique ID valud of this element.
Returns:
refCnt is successful. or -1 if aID is invalid.

Definition at line 177 of file rmRefArray.h.

References ACTIVE, and rmBaseArray::findId.

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

remove an element from the table.

Remove an element in the table if refCnt is 0.

Parameters:
aID  The unique ID valud of this element.
Returns:
RMCLIENT_SUCCESS is successful. or RMCLIENT_ERROR_BASE_ID if aID is invalid, or RMCLIENT_ERROR_CC_REFCNT if (refCnt != 0).
Remarks:
This function overrides the base removeElement function.

Reimplemented from rmBaseArray.

Reimplemented in eventQuery.

Definition at line 124 of file rmRefArray.h.

References rmBaseArray::findId, rmBaseArray::mElementArray, rmBaseArray::mPos, RMCLIENT_ERROR_CC_REFCNT, and RMCLIENT_SUCCESS.

Referenced by rmGenericMonitorControl::removeElement, rmGenericMonitorConfig::removeElement, and eventQuery::removeElement.


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