AgentXcpp  Version:0.3
API Documentation
 All Classes Functions Variables Enumerations Enumerator Friends Pages
agentxcpp::IntegerVariable Class Reference

This class represents an Integer variable as described in RFC 2741. More...

#include <IntegerVariable.hpp>

Inheritance diagram for agentxcpp::IntegerVariable:
[legend]

Public Member Functions

 IntegerVariable (qint32 _value=0)
 Constructor. More...
 
virtual Oid toOid () const
 Convert the value to an OID. More...
 
void setValue (qint32 _value)
 Set the value. More...
 
virtual qint32 value ()
 Get the current value. More...
 
virtual void perform_get ()
 Perform a Get request. More...
 
virtual testset_result_t perform_testset (qint32 _v)
 Perform an SNMP TestSet request. More...
 
virtual void perform_cleanupset (qint32 _v)
 Perform an SNMP CleanupSet request. More...
 
virtual bool perform_commitset (qint32 _v)
 Perform an SNMP CommitSet request. More...
 
virtual bool perform_undoset (qint32 _v)
 Perform an SNMP UndoSet request. More...
 
- Public Member Functions inherited from agentxcpp::AbstractVariable
virtual ~AbstractVariable ()
 Virtual destructor. More...
 

Protected Attributes

qint32 v
 The current value. More...
 

Additional Inherited Members

- Public Types inherited from agentxcpp::AbstractVariable
enum  testset_result_t {
  noError = 0, genErr = 5, noAccess = 6, wrongType = 7,
  wrongLength = 8, wrongValue = 10, noCreation = 11, inconsistentValue = 12,
  resourceUnavailable = 13, notWritable = 17, inconsistentName = 18
}
 Result type for the TestSet validation. More...
 

Detailed Description

This class represents an Integer variable as described in RFC 2741.

The page The Variable Objects explains how to use variables.

Note
When an IntegerVariable is used as INDEX within a table, it should never hold the value 0. This is because the value is then used as part of an OID, where 0 is forbidden (or at least discouraged).

Constructor & Destructor Documentation

agentxcpp::IntegerVariable::IntegerVariable ( qint32  _value = 0)
inline

Constructor.

Creates an IntegerValue object.

Exceptions
None.

Member Function Documentation

virtual void agentxcpp::IntegerVariable::perform_cleanupset ( qint32  _v)
inlinevirtual

Perform an SNMP CleanupSet request.

This method is invoked when an SNMP CleanupSet request is received. It shall release any resources allocated by perform_testset().

The default implementation does nothing. If no action is required to perform the CleanupSet operation, this method need not be overridden.

Parameters
_vThe value to which the variable was (possibly) set.
virtual bool agentxcpp::IntegerVariable::perform_commitset ( qint32  _v)
inlinevirtual

Perform an SNMP CommitSet request.

This method is invoked when an SNMP CommitSet request is received. It shall perform the actual write operation.

The default implementation returns false to indicate that the operation failed. To implement a writeable SNMP variable this method must be overridden.

Parameters
_vThe value which shall be written.
Returns
True if the operation succeeded, false otherwise.
virtual void agentxcpp::IntegerVariable::perform_get ( )
inlinevirtual

Perform a Get request.

This method is invoked when an SNMP Get request is received. It should update the internal value v.

virtual testset_result_t agentxcpp::IntegerVariable::perform_testset ( qint32  _v)
inlinevirtual

Perform an SNMP TestSet request.

This method is invoked when an SNMP TestSet request is received. It shall check whether a Set operation is possible for the variable. It shall acquire the resources needed to perform the Set operation (but the Set operation shall not yet be performed).

The default implementation returns AbstractVariable::noAccess to indicate that this is a read-only variable. Thus, for read-only variables this method need not be overridden.

Parameters
_vThe new value provided by the master agent.
Returns
The result of the check (this is reported to the master agent).
virtual bool agentxcpp::IntegerVariable::perform_undoset ( qint32  _v)
inlinevirtual

Perform an SNMP UndoSet request.

This method is invoked when an SNMP UndoSet request is received. It shall undo whatever perform_commitset() performed. It shall also release all resources allocated by perform_testset(), because perform_cleanupset() will not be called afterwards.

The default implementation returns false to indicate that the operation failed. It is strongly recommended that writeable variables override this method.

Parameters
_vThe value just set by perform_commitset().
Returns
True on success, false otherwise.
void agentxcpp::IntegerVariable::setValue ( qint32  _value)
inline

Set the value.

Parameters
_valueThe new value.
virtual Oid agentxcpp::IntegerVariable::toOid ( ) const
inlinevirtual

Convert the value to an OID.

The conversion is done according to RFC 2578, 7.7. "Mapping of the INDEX clause". The value is converted to an Oid with a single subid. Note that INTEGER values are signed, while subids are not. A negative value with be converted to a big unsigned subid.

This method should not be overridden.

Note
If an INTEGER is used in an INDEX clause, the value 0 should be avoided according to RFC 2578, 7.7. "Mapping of the INDEX clause".

Implements agentxcpp::AbstractVariable.

virtual qint32 agentxcpp::IntegerVariable::value ( )
inlinevirtual

Get the current value.

Returns
The value.

Member Data Documentation

qint32 agentxcpp::IntegerVariable::v
protected

The current value.

This is the value which is sent to the master agent on SNMP Get requests. According to RFC 2578, INTEGER is a signed 32-bit number. The value can be obtained with value() and set with setValue().

The perform_get() method should update this member.

The methods perform_testset(), perform_commitset(), perform_cleanupset() and/or perform_undoset() may update this member, but it is not needed for proper function.