AgentXcpp  Revision:0.2
API Documentation
 All Classes Functions Variables Enumerations Enumerator Friends Pages
agentxcpp::Variable< T > Class Template Reference

Class template to implement primitive SNMP variables. More...

#include <Variable.hpp>

Inheritance diagram for agentxcpp::Variable< T >:
[legend]

Public Member Functions

virtual T get ()=0
 Handle a Get request.
virtual testset_result_t testset (shared_ptr< T > v)
 Handle a TestSet request.
virtual void cleanupset (shared_ptr< T > v)
 Handle a CleanupSet request.
virtual bool commitset (shared_ptr< T > v)
 Handle a CommitSet request.
virtual bool undoset (shared_ptr< T > v)
 Handle an UndoSet request.
- Public Member Functions inherited from agentxcpp::AbstractVariable
virtual ~AbstractVariable ()
 Destructor.

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

template<class T>
class agentxcpp::Variable< T >

Class template to implement primitive SNMP variables.

This class template is used as base class for primitive SNMP variable implementations. It is instanciated with the value type the variable provides. Then, some functions are overriden to provide the functionality. Example:

// An IntegerValue variable
class simpleCounter : public Variable<IntegerValue>
{
private:
// The internal counter
IntegerValue counter;
public:
// Handle SNMP get request
virtual IntegerValue get()
{
return counter;
}
// Increment the internal counter
void increment()
{
// Increment counter somehow
}
};

The get() method must be implemented. It is not allowed (and not possible) to implement write-only SNMP variables.

To support write access (which is optional), the methods testset() and commitset() must be implemented. The undoset() method should also be implemented in this case. The cleanupset() methon may be implemented if needed.

Member Function Documentation

template<class T >
virtual void agentxcpp::Variable< T >::cleanupset ( shared_ptr< T >  v)
inlinevirtual

Handle a CleanupSet request.

This method is called to handle an SNMP CleanupSet request. It shall release any ressources allocated by testset().

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

Parameters
vThe new value for the object.
template<class T >
virtual bool agentxcpp::Variable< T >::commitset ( shared_ptr< T >  v)
inlinevirtual

Handle a CommitSet request.

This method is called to handle an SNMP CommitSet request. It shall perform the actual write operation.

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

Parameters
vThe new value for the object.
Returns
True if the operation succeeded, false otherwise.
template<class T >
virtual T agentxcpp::Variable< T >::get ( )
pure virtual

Handle a Get request.

This method is called to handle an SNMP Get request. It shall return the current value of the variable.

Note
This method is pure virtual and thus must be implemented. It is not possible to implement write-only SNMP variables.
Returns
The value of the variable.
template<class T >
virtual testset_result_t agentxcpp::Variable< T >::testset ( shared_ptr< T >  v)
inlinevirtual

Handle a TestSet request.

This method is called to handle an SNMP TestSet request. 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).

The default implementation returns 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 for the object.
Returns
The result of the check.
template<class T >
virtual bool agentxcpp::Variable< T >::undoset ( shared_ptr< T >  v)
inlinevirtual

Handle an UndoSet request.

This method is called to handle an SNMP UndoSet request. It shall undo whatever commitset() performed. It shall also release all resources allocated by testset().

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

Parameters
vThe new value for the object.
Returns
True on success, false otherwise.