AgentXcpp  Version:0.3
Internals Documentation
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Pages
agentxcpp::AbstractVariable Class Referenceabstract

Base class for SNMP variables. More...

#include <AbstractVariable.hpp>

Inheritance diagram for agentxcpp::AbstractVariable:
Collaboration diagram for agentxcpp::AbstractVariable:

Public Types

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...
 

Public Member Functions

virtual ~AbstractVariable ()
 Virtual destructor. More...
 
virtual void handle_get ()=0
 Handle AgentX Get request. More...
 
virtual testset_result_t handle_testset (QSharedPointer< AbstractVariable >)=0
 Validate whether a Set operation would be successful. More...
 
virtual void handle_cleanupset ()=0
 Release resources after a Set operation. More...
 
virtual bool handle_commitset ()=0
 Actually perform the Set operation. More...
 
virtual bool handle_undoset ()=0
 Undo a Set operation which was already performed. More...
 
virtual binary serialize () const =0
 Serialize the variable. More...
 
virtual Oid toOid () const =0
 Convert an INDEX variable to an Oid part. More...
 

Detailed Description

Base class for SNMP variables.

This class is the base class for SNMP variable implementations. It provides the interface which is used by agentXcpp (namely by the MasterProxy class) to perform operations on variables. An overiew on variable handling in agentxcpp is given in The Variable Objects.

Note
This class should never be inherited by non-agentXcpp code.

Definition at line 40 of file AbstractVariable.hpp.

Member Enumeration Documentation

Result type for the TestSet validation.

A value of this type is returned during a TestSet operation according to RFC 2741, 7.2.4.1. "Subagent Processing of the agentx-TestSet-PDU".

Note
The value 'wrongEncoding' is not used within the agentXcpp implementation and is therefore not part of this enumeration.

The numeric values are given in RFC 2741, 7.2.4.1. "Subagent Processing of the agentx-TestSet-PDU".

Note
These values must be in sync with the corresponding errors defined in agentxcpp::ResponsePDU::error_t.
Enumerator
noError 

Validation succeeded.

genErr 

The variable could not be set, and there is no other enumeration value to express the reason.

noAccess 

Access denied (i.e. the object is read-only).

wrongType 

The object cannot be set to the requested type because it has the wrong type (e.g. an OctetString variable cannot be set to an Integer value).

wrongLength 

The requested new value has the wrong length. E.g. an OctetString variable may be restricted to 8 characters, but the requested new string has 15 characters.

wrongValue 

The requested value could under no circumstances be assigned to the variable (although the variable is read-write). For example, certain values may be disallowed for a specific Integer variable.

noCreation 

The variable does not exist and could not ever be created.

inconsistentValue 

The requested value could under other circumstances be held by the variable, but is presently inconsistent or otherwise unable to be assigned to the variable.

resourceUnavailable 

A resource which is required to perform the actual Set operation is unavailable. A Set operation would fail because of this reason.

notWritable 

The object doesn't exist and cannot be created on-the-fly, or the variable exists but cannot be modified.

Note
Use noAccess for read-only variables.
inconsistentName 

The variable does not exist and can not be created under the present circumstances (even though it could be created under other circumstances).

Definition at line 90 of file AbstractVariable.hpp.

Constructor & Destructor Documentation

virtual agentxcpp::AbstractVariable::~AbstractVariable ( )
inlinevirtual

Virtual destructor.

Definition at line 48 of file AbstractVariable.hpp.

Member Function Documentation

virtual void agentxcpp::AbstractVariable::handle_cleanupset ( )
pure virtual

Release resources after a Set operation.

This method is called when the SNMP request "CleanupSet" is received. It shall release all resources previously allocated by handle_testset() (if any). If no resources were allocated, this method is not required to do anything.

Exceptions
Thefunction shall not throw.

Implemented in agentxcpp::IntegerVariable, agentxcpp::IpAddressVariable, agentxcpp::OidVariable, agentxcpp::OctetStringVariable, agentxcpp::Gauge32Variable, agentxcpp::OpaqueVariable, agentxcpp::TimeTicksVariable, agentxcpp::Counter64Variable, and agentxcpp::Counter32Variable.

virtual bool agentxcpp::AbstractVariable::handle_commitset ( )
pure virtual

Actually perform the Set operation.

This method is called when the SNMP request "CommitSet" is received for the variable. It shall perform the Set operation. It shall report whether the operation succeeded.

Note
The new value is given to handle_testset() prior to calling handle_commitset().
Returns
True on success, false otherwise.
Exceptions
Thefunction shall not throw.

Implemented in agentxcpp::IntegerVariable, agentxcpp::IpAddressVariable, agentxcpp::OidVariable, agentxcpp::OctetStringVariable, agentxcpp::Gauge32Variable, agentxcpp::OpaqueVariable, agentxcpp::TimeTicksVariable, agentxcpp::Counter64Variable, and agentxcpp::Counter32Variable.

virtual void agentxcpp::AbstractVariable::handle_get ( )
pure virtual

Handle AgentX Get request.

This method is called by the MasterProxy object when the SNMP request "Get" is received for the variable. It should update the internal state.

Note
Any exception thrown by this method results in sending a generic error to the master agent.
Exceptions
generic_errorIf obtaining the current value fails. No other exception shall be thrown.

Implemented in agentxcpp::IntegerVariable, agentxcpp::IpAddressVariable, agentxcpp::OidVariable, agentxcpp::OctetStringVariable, agentxcpp::OpaqueVariable, agentxcpp::Gauge32Variable, agentxcpp::TimeTicksVariable, agentxcpp::Counter32Variable, and agentxcpp::Counter64Variable.

virtual testset_result_t agentxcpp::AbstractVariable::handle_testset ( QSharedPointer< AbstractVariable )
pure virtual

Validate whether a Set operation would be successful.

This method is called when the SNMP request "TestSet" 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 shall not yet be performed).

Note
This is the only method which receives the new value to be set. An implementation must save the new value for subsequent operations (i.e. handle_commitset()).
Returns
The result of the validation.
Exceptions
Thefunction shall not throw.

Implemented in agentxcpp::IntegerVariable, agentxcpp::IpAddressVariable, agentxcpp::OidVariable, agentxcpp::OctetStringVariable, agentxcpp::OpaqueVariable, agentxcpp::Gauge32Variable, agentxcpp::TimeTicksVariable, agentxcpp::Counter32Variable, and agentxcpp::Counter64Variable.

virtual bool agentxcpp::AbstractVariable::handle_undoset ( )
pure virtual

Undo a Set operation which was already performed.

This method is called when the SNMP request "UndoSet" is received. It shall undo the operation performed by handle_commitset().

Returns
True on success, false otherwise.
Exceptions
Thefunction shall not throw.

Implemented in agentxcpp::IntegerVariable, agentxcpp::IpAddressVariable, agentxcpp::OidVariable, agentxcpp::OctetStringVariable, agentxcpp::Gauge32Variable, agentxcpp::OpaqueVariable, agentxcpp::TimeTicksVariable, agentxcpp::Counter64Variable, and agentxcpp::Counter32Variable.

virtual binary agentxcpp::AbstractVariable::serialize ( ) const
pure virtual

Serialize the variable.

This function shall generate a serialized form of the internal variable (i.e. the network representation of the variable).

Returns
The serialized form of the variable.
Exceptions
Thefunction shall not throw.

Implemented in agentxcpp::OidVariable, agentxcpp::IntegerVariable, agentxcpp::Gauge32Variable, agentxcpp::TimeTicksVariable, agentxcpp::IpAddressVariable, agentxcpp::Counter32Variable, agentxcpp::Counter64Variable, agentxcpp::OpaqueVariable, and agentxcpp::OctetStringVariable.

virtual Oid agentxcpp::AbstractVariable::toOid ( ) const
pure virtual

Convert an INDEX variable to an Oid part.

If an SNMP variable is used as INDEX within a table, then its value is used as part of the Oid for that table entry. Therefore, such variables must be convertible to Oid's. This method provides this conversion.

Not all variable types are allowed to be used as INDEX and are therefore not convertible to Oid. For variables which are not convertible, this method shall return the null Oid.

Returns
The Oid representing the variables value, or the null Oid if the variable don't support such conversion.
Exceptions
Thismethod shall not throw.

Implemented in agentxcpp::Gauge32Variable, agentxcpp::OpaqueVariable, agentxcpp::TimeTicksVariable, agentxcpp::Counter64Variable, agentxcpp::Counter32Variable, agentxcpp::IpAddressVariable, agentxcpp::IntegerVariable, agentxcpp::OidVariable, and agentxcpp::OctetStringVariable.


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