AgentXcpp  Revision:0.2
API Documentation
 All Classes Functions Variables Enumerations Enumerator Friends Pages
agentxcpp::AbstractVariable Class Reference

Base class for SNMP variables. More...

#include <AbstractVariable.hpp>

Inheritance diagram for agentxcpp::AbstractVariable:
[legend]

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 ()
 Destructor.
virtual shared_ptr< AbstractValuehandle_get ()=0
 Handle AgentX Get request.
virtual testset_result_t handle_testset (shared_ptr< AbstractValue >)=0
 Validate whether a Set operation would be successful.
virtual void handle_cleanupset ()=0
 Release resources after a Set operation.
virtual bool handle_commitset ()=0
 Actually perform the Set operation.
virtual bool handle_undoset ()=0
 Undo a Set operation which was already performed.

Detailed Description

Base class for SNMP variables.

This class is the base class for SNMP variable implementations. It provides the interface which is used internally by agentXcpp to perform operations on variables.

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

Constructor & Destructor Documentation

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

Destructor.

Member Function Documentation

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

Release resources after a Set operation.

This method is called when a CleanupSet request 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.

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

Actually perform the Set operation.

This method is called when a CommitSet request 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.
virtual shared_ptr<AbstractValue> agentxcpp::AbstractVariable::handle_get ( )
pure virtual

Handle AgentX Get request.

This method is called when a get request is received for the variable. It shall return the current value of the variable.

Returns
The current value of the variable.
Exceptions
generic_errorIf obtaining the current value fails. No other exception shall be thrown.
virtual testset_result_t agentxcpp::AbstractVariable::handle_testset ( shared_ptr< AbstractValue )
pure virtual

Validate whether a Set operation would be successful.

This method is called when a 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 shall not yet 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.
virtual bool agentxcpp::AbstractVariable::handle_undoset ( )
pure virtual

Undo a Set operation which was already performed.

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

Returns
True on success, false otherwise.