AGENT++  4.0.3
Public Member Functions | Protected Attributes | List of all members
MibContext Class Reference

#include <mib_context.h>

Inheritance diagram for MibContext:
ThreadManager Synchronized

Public Member Functions

 MibContext ()
 Default constructor.
 
 MibContext (const NS_SNMP OctetStr &)
 Create a given context.
 
virtual ~MibContext ()
 Destructor.
 
virtual bool init_from (const NS_SNMP OctetStr &)
 Initialize context, thus load initialize groups with data from persistent storage.
 
virtual bool load_from (const NS_SNMP OctetStr &)
 Loads persistent data from the supplied path.
 
virtual bool save_to (const NS_SNMP OctetStr &)
 Save management data to persistent storage.
 
OidxPtr key ()
 Return a key value for the receiver context.
 
virtual MibEntryadd (MibEntry *)
 Register a MIB object for the context.
 
virtual MibEntryremove (const Oidx &)
 Unregister a MIB object from the context.
 
virtual MibEntryget (const Oidx &)
 Get the MIB object with a given object id.
 
virtual MibEntryseek (const Oidx &)
 Get the MIB entry with a given object id if such an entry exists or otherwise an object near to the given oid.
 
virtual int find (const Oidx &, MibEntryPtr &)
 Find a MIB entry with a given oid.
 
virtual int find_lower (const Oidx &, MibEntryPtr &)
 Find a MIB entry with an oid less or equal to a given oid.
 
virtual int find_upper (const Oidx &, MibEntryPtr &)
 Find a MIB entry with an oid greater or equal to a given oid.
 
virtual MibEntryfind_next (const Oidx &)
 Find the successor of a given MibEntry.
 
OidListCursor< MibEntryget_content ()
 Get a OidListCursor at the first element of the receiver.
 
OidListCursor< MibGroupget_groups ()
 Get a Cursor at the first element of registered groups.
 
virtual MibGroupfind_group (const Oidx &)
 Find a group with a given OID.
 
virtual bool remove_group (const Oidx &)
 Remove a group and all its entries from the context.
 
virtual MibGroupfind_group_of (const Oidx &)
 Find the MibGroup that contains a MibEntry with a given object ID.
 
NS_SNMP OctetStr get_name ()
 Get the name of the context.
 
unsigned int get_num_groups () const
 Get the number of MibGroup instances in this context.
 
MibGroupget_group (int n)
 Get the nth group of the MibGroup instances in this context.
 
unsigned int get_num_entries () const
 Get the number of entries in this context.
 
- Public Member Functions inherited from ThreadManager
 ThreadManager ()
 Default constructor.
 
virtual ~ThreadManager ()
 Destructor.
 
void start_synch ()
 Start synchronized execution.
 
void end_synch ()
 End synchronized execution.
 
- Public Member Functions inherited from Synchronized
 Synchronized ()
 
 ~Synchronized ()
 
void wait ()
 Causes current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object.
 
bool wait (unsigned long timeout)
 Causes current thread to wait until either another thread invokes the notify() method or the notifyAll() method for this object, or a specified amount of time has elapsed.
 
void notify ()
 Wakes up a single thread that is waiting on this object's monitor.
 
void notify_all ()
 Wakes up all threads that are waiting on this object's monitor.
 
bool lock ()
 Enter a critical section.
 
TryLockResult trylock ()
 Try to enter a critical section.
 
bool unlock ()
 Leave a critical section.
 

Protected Attributes

OidList< MibEntrycontent
 
OidList< MibGroupgroups
 
Oidx contextKey
 
NS_SNMP OctetStr context
 
NS_SNMP OctetStr * persistencyPath
 

Additional Inherited Members

- Public Types inherited from Synchronized
enum  TryLockResult { LOCKED = 1, BUSY = 0, OWNED = -1 }
 
- Static Public Member Functions inherited from ThreadManager
static void start_global_synch ()
 Start global synchronized execution.
 
static void end_global_synch ()
 End global synchronized execution.
 

Constructor & Destructor Documentation

MibContext::MibContext ( )

Default constructor.

Creates a default context.

MibContext::MibContext ( const NS_SNMP OctetStr &  )

Create a given context.

Parameters
contextan OctetStr instance identifying the context to be created.
virtual MibContext::~MibContext ( )
virtual

Destructor.

Member Function Documentation

virtual MibEntry* MibContext::add ( MibEntry )
virtual

Register a MIB object for the context.

(SYNCHRONIZED)

Parameters
itema pointer to a MibEntry object (i.e., MibLeaf, MibTable, MibGroup, ...).
Returns
the input pointer, or 0 if the object could not be registered.
virtual int MibContext::find ( const Oidx ,
MibEntryPtr  
)
virtual

Find a MIB entry with a given oid.

Parameters
oidan object identifier.
entrychanged to a pointer to the found entry or unchanged if the return value is different from SNMP_ERROR_SUCCESS.
Returns
SNMP_ERROR_SUCCESS if an entry has been found and SNMP_ERROR_NO_SUCH_NAME otherwise.
virtual MibGroup* MibContext::find_group ( const Oidx )
virtual

Find a group with a given OID.

(NOT SYNCHRONIZED)

Parameters
oida group's oid.
Returns
a pointer a MibGroup instance, or 0 if no such group exists.
virtual MibGroup* MibContext::find_group_of ( const Oidx )
virtual

Find the MibGroup that contains a MibEntry with a given object ID.

Parameters
oida object identifier.
Returns
a pointer to the MibGroup instance that contains an instance with the given oid, or 0 otherwise.
virtual int MibContext::find_lower ( const Oidx ,
MibEntryPtr  
)
virtual

Find a MIB entry with an oid less or equal to a given oid.

Parameters
oidan object identifier.
entrychanged to a pointer to the found entry or unchanged if the return value is different from SNMP_ERROR_SUCCESS.
Returns
SNMP_ERROR_SUCCESS if an entry has been found and SNMP_ERROR_NO_SUCH_NAME otherwise.
virtual MibEntry* MibContext::find_next ( const Oidx )
virtual

Find the successor of a given MibEntry.

Parameters
oidan object identifier of an existing MibEntry. If the receiver doesnot contain such an object, 0 will be returned.
Returns
a pointer to the successor MibEntry if the specified object could be found, 0 otherwise.
virtual int MibContext::find_upper ( const Oidx ,
MibEntryPtr  
)
virtual

Find a MIB entry with an oid greater or equal to a given oid.

Parameters
oidan object identifier.
entrychanged to a pointer to the found entry or unchanged if the return value is different from SNMP_ERROR_SUCCESS.
Returns
SNMP_ERROR_SUCCESS if an entry has been found and SNMP_ERROR_NO_SUCH_NAME otherwise.
virtual MibEntry* MibContext::get ( const Oidx )
virtual

Get the MIB object with a given object id.

Parameters
keyan object identifier
Returns
a pointer to a MibEntry instance if an object with the given key could be found or 0 otherwise.
OidListCursor<MibEntry> MibContext::get_content ( )

Get a OidListCursor at the first element of the receiver.

Returns
an OidListCursor instance.
MibGroup* MibContext::get_group ( int  n)
inline

Get the nth group of the MibGroup instances in this context.

Parameters
na 0-based index to the MibGroup to return.
Returns
a pointer to the n-th MibGroup of this context or 0 if n is out of range.
OidListCursor<MibGroup> MibContext::get_groups ( )

Get a Cursor at the first element of registered groups.

Returns
a ListCursor instance.
NS_SNMP OctetStr MibContext::get_name ( )
inline

Get the name of the context.

Returns
an OctetStr instance.
unsigned int MibContext::get_num_entries ( ) const
inline

Get the number of entries in this context.

Returns
the number of entries in this context.
unsigned int MibContext::get_num_groups ( ) const
inline

Get the number of MibGroup instances in this context.

Returns
the number of MibGroups in this context.
virtual bool MibContext::init_from ( const NS_SNMP OctetStr &  )
virtual

Initialize context, thus load initialize groups with data from persistent storage.

Parameters
pathwhere data should be loaded from.
Returns
TRUE if initialization was successful, FALSE otherwise.
OidxPtr MibContext::key ( )

Return a key value for the receiver context.

Returns
a pointer to an Oidx instance.
virtual bool MibContext::load_from ( const NS_SNMP OctetStr &  )
virtual

Loads persistent data from the supplied path.

Any previously existing data will be deleted before loading.

Parameters
pathwhere data should be loaded from.
Returns
TRUE if initialization was successful, FALSE otherwise.
virtual MibEntry* MibContext::remove ( const Oidx )
virtual

Unregister a MIB object from the context.

This method does not work for MibGroups, instead you have to remove each MibGroup's MIB object seperately. (SYNCHRONIZED)

Parameters
oidthe oid of the object to be removed.
Returns
a pointer to the removed object, or 0 if such an object could not be found.
virtual bool MibContext::remove_group ( const Oidx )
virtual

Remove a group and all its entries from the context.

(SYNCHRONIZED)

Parameters
oida group's oid.
Returns
TRUE if such a group could be found (and removed), FALSE otherwise.
virtual bool MibContext::save_to ( const NS_SNMP OctetStr &  )
virtual

Save management data to persistent storage.

NOTE: This method is called by the receiver's destructor with the path used by init_from.

Parameters
pathwhere data should be written to.
Returns
TRUE if data could be saved successfully, FALSE otherwise.
virtual MibEntry* MibContext::seek ( const Oidx )
virtual

Get the MIB entry with a given object id if such an entry exists or otherwise an object near to the given oid.

Parameters
keyan object identifier
Returns
a pointer to a MibEntry instance if an object could be found or 0 otherwise.

Member Data Documentation

OidList<MibEntry> MibContext::content
protected
NS_SNMP OctetStr MibContext::context
protected
Oidx MibContext::contextKey
protected
OidList<MibGroup> MibContext::groups
protected
NS_SNMP OctetStr* MibContext::persistencyPath
protected

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