MibLeaf Class Reference

An instance of the class MibLeaf represents a leaf object in the managed object registration tree. More...

#include <mib.h>

Inheritance diagram for MibLeaf:

MibEntry ThreadManager Synchronized agentppSimDeleteRow agentppSimDeleteTableContents agentppSimMode DateAndTime OctetStrMinMax SimMibLeaf SnmpDisplayString snmpEnableAuthenTraps SnmpEngineID snmpInASNParseErrs snmpInBadCommunityNames snmpInBadCommunityUses snmpInBadValues snmpInBadVersions snmpInGenErrs snmpInGetNexts snmpInGetRequests snmpInGetResponses snmpInNoSuchNames snmpInPkts snmpInReadOnlys snmpInSetRequests SnmpInt32MinMax snmpInTooBigs snmpInTotalReqVars snmpInTotalSetVars snmpInTraps snmpOutBadValues snmpOutGenErrs snmpOutGetNexts snmpOutGetRequests snmpOutGetResponses snmpOutNoSuchNames snmpOutPkts snmpOutSetRequests snmpOutTooBigs snmpOutTraps snmpProxyDrops snmpRowStatus snmpSilentDrops SnmpTagList SnmpTagValue snmpTargetAddrParams snmpTargetAddrTAddress snmpTargetAddrTDomain SnmpUnavailableContexts SnmpUnknownContexts StorageType sysObjectID sysORLastChange sysServices sysUpTime TestAndIncr TimeStamp

List of all members.

Public Member Functions

 MibLeaf ()
 Default constructor.
 MibLeaf (const Oidx &, mib_access, NS_SNMP SmiUINT32)
 Construct a MibLeaf object.
 MibLeaf (const Oidx &, mib_access, NS_SNMP SnmpSyntax *)
 Construct a MibLeaf object.
 MibLeaf (const Oidx &, mib_access, NS_SNMP SnmpSyntax *, int)
 Construct a MibLeaf object.
 MibLeaf (const MibLeaf &)
 Copy Constructor.
virtual ~MibLeaf ()
 Destructor.
virtual void init (NS_SNMP SnmpSyntax *, boolean)
 Initialize a MibLeaf object.
virtual mib_type type () const
 Return the type of the receiver.
virtual MibEntryPtr clone ()
 Clone the receiver object.
virtual boolean serialize (char *&, int &)
 Serialize the value of the receiver.
virtual boolean deserialize (char *, int &)
 Read the value of the receiver from a byte stream.
virtual NS_SNMP SmiUINT32 get_syntax () const
 Get the syntax of the receiver's value.
virtual Vbx get_value () const
 Get the value of the receiver.
virtual int get_value (NS_SNMP SnmpSyntax &s) const
 Get the value of the receiver.
virtual int get_value (int &i) const
 Get the value of the receiver.
virtual int get_value (long &i) const
 Get the value of the receiver.
virtual int get_value (unsigned long &i) const
 Get the value of the receiver.
virtual int get_value (char *c) const
 Get the value of the receiver.
virtual void set_value (const NS_SNMP SnmpSyntax &)
 Set the value of the receiver by value.
virtual void set_value (const unsigned long)
 Set the unsigned integer value of the receiver.
virtual int set_value (const Vbx &)
 Set the value of the receiver from a variable binding and checks for validity of the variable binding and compatible syntax and oid.
virtual void replace_value (NS_SNMP SnmpSyntax *s)
 Set the value of the receiver by reference.
virtual OidxPtr max_key ()
 Return the immediate successor of the greatest object identifier within the receiver's scope.
virtual void get_request (Request *, int)
 Interface methods dispatch table <-> instrumentation.
virtual void get_next_request (Request *, int)
 Let the receiver process a SNMP GETNEXT subrequest.
virtual int commit_set_request (Request *, int)
 Let the receiver commit a SNMP SET subrequest.
virtual int prepare_set_request (Request *, int &)
 Let the receiver prepare a SNMP SET subrequest.
virtual int undo_set_request (Request *, int &)
 Let the receiver undo a SNMP SET subrequest.
virtual void cleanup_set_request (Request *, int &)
 Clean up resources used for performing (or undoing) set requests.
virtual boolean value_ok (const Vbx &)
 Check whether the receiver's value may be set to the given new value.
virtual int set (const Vbx &vb)
 Set the receiver's value and backup its old value for a later undo.
virtual int unset ()
 Undo a previous set.
MibTableget_reference_to_table ()
 Return a pointer to the table the receiver belongs to.
MibTableRowget_reference_to_row ()
 Return a pointer to the row the receiver belongs to.
int valid ()
 Gets the flags (bits) that determine the type/stage of validity of the leaf's value.
boolean has_default ()
 Return whether the receiver has a default value.
boolean is_locked ()
 Return whether the receiver has a default value.
void set_reference_to_table (MibTable *t)
 Set the receiver's reference to its table.
void set_reference_to_row (MibTableRow *r)
 Set the receiver's reference to its row.
void set_access (mib_access a)
 Set the maximum access rights of the receiver.
Oidx get_oid () const
 Get the instance OID of the MibLeaf object.

Protected Member Functions

int get_value_mode ()
 Return the value handle mode.
void set_validity (int flags)
 Sets the flags (bits) that determine the type/stage of validity of the leaf's value.
void set_syntax (NS_SNMP SmiUINT32)
 Set the syntax of the receiver's value and delete the old value.
void free_value ()
 Frees the receiver's value and sets it to NULL.

Protected Attributes

NS_SNMP SnmpSyntax * value
NS_SNMP SnmpSyntax * undo
int value_mode
int validity
 Set of flags (bits) that determine the type/stage of validity of the leaf's value.
MibTablemy_table
MibTableRowmy_row

Friends

class MibTable
class MibTableRow


Detailed Description

An instance of the class MibLeaf represents a leaf object in the managed object registration tree.

MibLeaf objects can be used to model scalar managed objects as well as objects of SNMP tables. The objects of a table are defined by defining their corresponding columnar objects. The instances of each columnar object (which is itself not accessible) are then cloned from it.

In order to save memory space, from version 3.4.7 on the key() method does no longer return the complete OID (instance OID) of columnar MibLeaf objects (thus MibLeaf objects that are part of a table). Instead, MibLeaf::key() only returns the last subid that identifies the column the MibLeaf is part of. From v3.4.7 on, there is the get_oid() method that returns the entiry OID value for columnar objects as well as for other MibLeaf objects. For columnar objects this method computes the OID value from the table's OID plus the MibLeaf's column (key()), and the row's index value.

MibLeaf is a sub-class of the abstract MibEntry class. As MibLeaf represents a managed object instance a MibLeaf object contains management information. So each MibLeaf object contains a pointer "value" to that management information which can be any object derived from SnmpSyntax.

Author:
Frank Fock
Version:
3.4.7

Constructor & Destructor Documentation

MibLeaf::MibLeaf (  ) 

Default constructor.

MibLeaf::MibLeaf ( const Oidx ,
mib_access  ,
NS_SNMP  SmiUINT32 
)

Construct a MibLeaf object.

Parameters:
o - The object identifier of the managed object. If it is part of a table, only the column subidentifier is given. If it is a scalar object the object identifier given includes the full registration oid including the suffix ".0".
a - The maximum access rights for the managed object.
s - The syntax of the managed object.
See also:
Oidx, mib_access

MibLeaf::MibLeaf ( const Oidx ,
mib_access  ,
NS_SNMP SnmpSyntax *   
)

Construct a MibLeaf object.

Parameters:
o - The object identifier of the managed object. If it is part of a table, only the column subidentifier is given. If it is a scalar object the object identifier given includes the full registration oid including the suffix ".0".
a - The maximum access rights for the managed object.
s - A pointer to the SnmpSyntax object to be used for storing the value of the managed object. NOTE: Do not delete this pointer from outside MibLeaf. It will be deleted by ~MibLeaf
See also:
Oidx, mib_access

MibLeaf::MibLeaf ( const Oidx ,
mib_access  ,
NS_SNMP SnmpSyntax *  ,
int   
)

Construct a MibLeaf object.

Parameters:
oid the object identifier of the managed object. If it is part of a table, only the column subidentifier is given. If it is a scalar object the object identifier given includes the full registration oid including the suffix ".0".
access the maximum access rights for the managed object.
value a pointer to the SnmpSyntax object to be used for storing the value of the managed object. NOTE: Do not delete this pointer from outside MibLeaf. It will be deleted by ~MibLeaf
valueMode contains an ored value of one or more of the following modes: VMODE_DEFAULT: the value of the object pointed by value will be used as default value, otherwise the managed object has no default value. VMODE_LOCKED: value is locked (cannot be modified) while the row status of the receiver's row is active(1). This mode has no effect, if the the leaf is a scalar or otherwise if the receiver's row has no snmpRowStatus.

MibLeaf::MibLeaf ( const MibLeaf  ) 

Copy Constructor.

virtual MibLeaf::~MibLeaf (  )  [virtual]

Destructor.


Member Function Documentation

virtual void MibLeaf::init ( NS_SNMP SnmpSyntax *  ,
boolean   
) [virtual]

Initialize a MibLeaf object.

This method is typically called either from a constructor with value or when loading a value from persistent storage.

Parameters:
initialValue a pointer to a SnmpSyntax object which will hold the value of this MibLeaf object.
valueMode contains an ored value of one or more of the following modes: VMODE_DEFAULT: the value of the object pointed by value will be used as default value, otherwise the managed object has no default value. VMODE_LOCKED: value is locked (cannot be modified) while the row status of the receiver's row is active(1). This mode has no effect, if the the leaf is a scalar or otherwise if the receiver's row has no snmpRowStatus.

Reimplemented in agentppSimMode.

virtual mib_type MibLeaf::type (  )  const [virtual]

Return the type of the receiver.

Returns:
LEAF

Reimplemented from MibEntry.

virtual MibEntryPtr MibLeaf::clone (  )  [virtual]

virtual boolean MibLeaf::serialize ( char *&  ,
int &   
) [virtual]

Serialize the value of the receiver.

Parameters:
buf - A pointer to byte stream buffer returned.
sz - The size of the buffer returned.
Returns:
TRUE if serialization was successful, FALSE otherwise.

Reimplemented from MibEntry.

virtual boolean MibLeaf::deserialize ( char *  ,
int &   
) [virtual]

Read the value of the receiver from a byte stream.

Parameters:
buf a pointer to the input byte stream.
sz the size of the input buffer. On output it contains the size remaining unread in the input buffer.
Returns:
TRUE if deserialization was successful, FALSE otherwise.

Reimplemented from MibEntry.

virtual NS_SNMP SmiUINT32 MibLeaf::get_syntax (  )  const [virtual]

Get the syntax of the receiver's value.

Returns:
The syntax of a MibLeaf object's value or sNMP_SYNTAX_NULL, if the object has no value.

virtual Vbx MibLeaf::get_value (  )  const [virtual]

Get the value of the receiver.

Returns:
A variable binding that holds the object identifier and the value of the receiver.

virtual int MibLeaf::get_value ( NS_SNMP SnmpSyntax &  s  )  const [inline, virtual]

Get the value of the receiver.

Parameters:
s - A reference to a SnmpSyntax object to hold a copy of the receiver's value.
Returns:
SNMP_ERROR_SUCCESS on success.

virtual int MibLeaf::get_value ( int &  i  )  const [inline, virtual]

Get the value of the receiver.

Parameters:
i - A reference to an int the receiver's value will be copied in.
Returns:
SNMP_ERROR_SUCCESS on success.

virtual int MibLeaf::get_value ( long &  i  )  const [inline, virtual]

Get the value of the receiver.

Parameters:
i - A reference to a long the receiver's value will be copied in.
Returns:
SNMP_ERROR_SUCCESS on success.

virtual int MibLeaf::get_value ( unsigned long &  i  )  const [inline, virtual]

Get the value of the receiver.

Parameters:
i - A reference to an unsigned long the receiver's value will be copied in.
Returns:
SNMP_ERROR_SUCCESS on success.

virtual int MibLeaf::get_value ( char *  c  )  const [inline, virtual]

Get the value of the receiver.

Parameters:
c - A pointer to a string the receiver's value will be copied in.
Returns:
SNMP_ERROR_SUCCESS on success.

virtual void MibLeaf::set_value ( const NS_SNMP SnmpSyntax &   )  [virtual]

Set the value of the receiver by value.

Parameters:
v - The value.

virtual void MibLeaf::set_value ( const unsigned  long  )  [virtual]

Set the unsigned integer value of the receiver.

Caution: The syntax of this MibLeaf instance will be set to sNMP_SYNTAX_INT32! Thus, it should be only used for objects with an INTEGER syntax.

Parameters:
l - The new integer value.
Deprecated:
Use set_value(const SnmpSyntax&) instead.

virtual int MibLeaf::set_value ( const Vbx  )  [virtual]

Set the value of the receiver from a variable binding and checks for validity of the variable binding and compatible syntax and oid.

Parameters:
vb - The variable binding including the new value.
Returns:
SNMP_ERROR_SUCCESS if the new value has been set, SNMP_ERROR_WRONG_TYPE or SNMP_ERROR_BAD_VALUE otherwise.

virtual void MibLeaf::replace_value ( NS_SNMP SnmpSyntax *  s  )  [virtual]

Set the value of the receiver by reference.

Parameters:
v - A pointer to the new value.

virtual OidxPtr MibLeaf::max_key (  )  [inline, virtual]

Return the immediate successor of the greatest object identifier within the receiver's scope.

Returns:
a pointer to the non including upper bound of the receiver's scope

Reimplemented from MibEntry.

virtual void MibLeaf::get_request ( Request ,
int   
) [virtual]

virtual void MibLeaf::get_next_request ( Request ,
int   
) [virtual]

Let the receiver process a SNMP GETNEXT subrequest.

Parameters:
req - A pointer to the whole SNMP GETNEXT request.
ind - The index of the subrequest to be processed.

Reimplemented from MibEntry.

virtual int MibLeaf::commit_set_request ( Request ,
int   
) [virtual]

Let the receiver commit a SNMP SET subrequest.

Parameters:
req - A pointer to the whole SNMP SET request.
ind - The index of the subrequest to be processed.
Returns:
SNMP_ERROR_SUCCESS on success and SNMP_ERROR_COMITFAIL on failure.

Reimplemented from MibEntry.

Reimplemented in agentppSimDeleteRow, and agentppSimDeleteTableContents.

virtual int MibLeaf::prepare_set_request ( Request ,
int &   
) [virtual]

Let the receiver prepare a SNMP SET subrequest.

Parameters:
req - A pointer to the whole SNMP SET request.
ind - The index of the subrequest to be processed.
Returns:
SNMP_ERROR_SUCCESS on success and SNMP_ERROR_WRONG_VALUE, SNMP_ERROR_WRONG_TYPE, or SNMP_ERROR_NOT_WRITEABLE on failure.

Reimplemented from MibEntry.

Reimplemented in agentppSimDeleteRow, agentppSimDeleteTableContents, snmpRowStatus, snmpTargetAddrTAddress, snmpTargetAddrParams, SnmpDisplayString, SnmpEngineID, SnmpTagValue, TestAndIncr, and OctetStrMinMax.

virtual int MibLeaf::undo_set_request ( Request ,
int &   
) [virtual]

Let the receiver undo a SNMP SET subrequest.

Parameters:
req - A pointer to the whole SNMP SET request.
ind - The index of the subrequest to be processed.
Returns:
SNMP_ERROR_SUCCESS on success and SNMP_ERROR_UNDO_FAIL on failure.

Reimplemented from MibEntry.

virtual void MibLeaf::cleanup_set_request ( Request ,
int &   
) [virtual]

Clean up resources used for performing (or undoing) set requests.

Parameters:
req - A pointer to the whole SNMP SET request.
ind - The index of the subrequest to be processed.

Reimplemented from MibEntry.

virtual boolean MibLeaf::value_ok ( const Vbx  )  [inline, virtual]

Check whether the receiver's value may be set to the given new value.

Note:
Override this mehtod in subclasses.
Parameters:
v - A new value.
Returns:
TRUE if the new value is valid, otherwise FALSE.

Reimplemented in agentppSimMode, snmpRowStatus, snmpEnableAuthenTraps, snmpTargetAddrTDomain, snmpTargetAddrParams, SnmpDisplayString, SnmpTagValue, SnmpTagList, TestAndIncr, StorageType, and SnmpInt32MinMax.

virtual int MibLeaf::set ( const Vbx vb  )  [virtual]

Set the receiver's value and backup its old value for a later undo.

Note:
Override this mehtod in subclasses.
Parameters:
vb - The variable binding that holds the new value.
Returns:
SNMP_ERROR_SUCCESS if the new value has been set, SNMP_ERROR_WRONG_TYPE or SNMP_ERROR_BAD_VALUE otherwise.

Reimplemented in agentppSimMode, snmpRowStatus, TestAndIncr, and VacmViewTreeFamilyTableStatus.

virtual int MibLeaf::unset (  )  [virtual]

Undo a previous set.

Returns:
SNMP_ERROR_SUCCESS on success and SNMP_ERROR_UNDO_FAIL on failure.

Reimplemented in snmpRowStatus.

MibTable* MibLeaf::get_reference_to_table (  )  [inline]

Return a pointer to the table the receiver belongs to.

Returns:
A Pointer to the table the receiver is in, if the receiver is a scalar managed object return 0.

MibTableRow* MibLeaf::get_reference_to_row (  )  [inline]

Return a pointer to the row the receiver belongs to.

Returns:
A Pointer to the row the receiver is in, if the receiver is a scalar managed object return 0.

int MibLeaf::valid (  )  [inline]

Gets the flags (bits) that determine the type/stage of validity of the leaf's value.

If any bit is set the leaf is supposed to contain a valid value. AGENT++ only uses the first 4 bits (0-3). The other bits can be used by the API programmer to track internal states of the leaf.

Returns:
an integer value != 0 if the receiver has a valid value.

boolean MibLeaf::has_default (  )  [inline]

Return whether the receiver has a default value.

Returns:
TRUE if the receiver has a default value, FALSE otherwise.

boolean MibLeaf::is_locked (  )  [inline]

Return whether the receiver has a default value.

Returns:
TRUE if the receiver has a default value, FALSE otherwise.

void MibLeaf::set_reference_to_table ( MibTable t  )  [inline]

Set the receiver's reference to its table.

Parameters:
t - A pointer to a MibTable instance.

void MibLeaf::set_reference_to_row ( MibTableRow r  )  [inline]

Set the receiver's reference to its row.

Parameters:
t - A pointer to a MibTableRow instance.

void MibLeaf::set_access ( mib_access  a  )  [inline]

Set the maximum access rights of the receiver.

Parameters:
a - The maximum access rights.

Oidx MibLeaf::get_oid (  )  const

Get the instance OID of the MibLeaf object.

If the leaf object is a columnar object then the instancce OID will be computed from the table's OID, plus the subidentifier of the leaf's column, and the row's index OID.

Returns:
the instance OID of the leaf object.

int MibLeaf::get_value_mode (  )  [inline, protected]

Return the value handle mode.

Returns:
a integer value describing how to handle the receiver's value.
See also:
constructor for details

void MibLeaf::set_validity ( int  flags  )  [inline, protected]

Sets the flags (bits) that determine the type/stage of validity of the leaf's value.

If any bit is set the leaf is supposed to contain a valid value. AGENT++ only uses the first 4 bits (0-3). The other bits can be used by the API programmer to track internal states of the leaf.

Parameters:
flags an integer value representing the validity of the receiver.

void MibLeaf::set_syntax ( NS_SNMP  SmiUINT32  )  [protected]

Set the syntax of the receiver's value and delete the old value.

Parameters:
syntax - The syntax of a MibLeaf object's value.

void MibLeaf::free_value (  )  [protected]

Frees the receiver's value and sets it to NULL.


Friends And Related Function Documentation

friend class MibTable [friend]

friend class MibTableRow [friend]


Member Data Documentation

NS_SNMP SnmpSyntax* MibLeaf::value [protected]

NS_SNMP SnmpSyntax* MibLeaf::undo [protected]

int MibLeaf::value_mode [protected]

int MibLeaf::validity [protected]

Set of flags (bits) that determine the type/stage of validity of the leaf's value.

If any bit is set the leaf is supposed to contain a valid value. AGENT++ only uses the first 4 bits (0-3). The other bits can be used by the API programmer to track internal states of the leaf.


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

Generated on Fri May 29 22:36:54 2009 for AGENT++ by  doxygen 1.5.6