Class template to implement primitive SNMP variables. More...
#include <Variable.hpp>
Public Member Functions | |
| virtual shared_ptr< AbstractValue > | handle_get () |
| Handle a Get Request. | |
| virtual T | get ()=0 |
| Handle a Get request. | |
| virtual testset_result_t | handle_testset (shared_ptr< AbstractValue > v) |
| Handle a TestSet request. | |
| virtual testset_result_t | testset (shared_ptr< T > v) |
| Handle a TestSet request. | |
| virtual void | handle_cleanupset () |
| Handle a CleanupSet request. | |
| virtual void | cleanupset (shared_ptr< T > v) |
| Handle a CleanupSet request. | |
| virtual bool | handle_commitset () |
| Handle a CommitSet request. | |
| virtual bool | commitset (shared_ptr< T > v) |
| Handle a CommitSet request. | |
| virtual bool | handle_undoset () |
| Handle a UndoSet request. | |
| virtual bool | undoset (shared_ptr< T > v) |
| Handle an UndoSet request. | |
Public Member Functions inherited from agentxcpp::AbstractVariable | |
| virtual | ~AbstractVariable () |
| Destructor. | |
Private Attributes | |
| shared_ptr< T > | new_value |
| The new value for the variable in a Set operation. | |
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... | |
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:
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.
This class template implements the methods of agentxcpp::variable in such a way that they call methods for the more specific value types. Example:
As can be seen, handle_testset() receives a pointer to a 'value' object. This pointer is casted to 'V' (the template parameter) before giving it to the testset() method. The testset() method is the one which is implemented by the agentXcpp user.
This class template remembers the new value and gives it to the functions testset(), commitset(), cleanupset() and undoset(). Also, type conversion is done (see the example) and an error is generated on type mismatch.
Definition at line 101 of file Variable.hpp.
|
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.
| v | The new value for the object. |
Definition at line 224 of file Variable.hpp.
Referenced by agentxcpp::Variable< T >::handle_cleanupset().
|
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.
| v | The new value for the object. |
Definition at line 256 of file Variable.hpp.
Referenced by agentxcpp::Variable< T >::handle_commitset().
|
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.
|
inlinevirtual |
Handle a CleanupSet request.
This function calls cleanupset() with the value from the last handle_testset() invokation.
Implements agentxcpp::AbstractVariable.
Definition at line 207 of file Variable.hpp.
References agentxcpp::Variable< T >::cleanupset(), and agentxcpp::Variable< T >::new_value.
|
inlinevirtual |
Handle a CommitSet request.
This function calls commitset() with the value from the last handle_testset() Invocation and returns its return value.
Implements agentxcpp::AbstractVariable.
Definition at line 237 of file Variable.hpp.
References agentxcpp::Variable< T >::commitset(), and agentxcpp::Variable< T >::new_value.
|
inlinevirtual |
Handle a Get Request.
This function calls this->get() to obtain the new value, converts it to shared_ptr<value> and returns it.
Implements agentxcpp::AbstractVariable.
Definition at line 124 of file Variable.hpp.
|
inlinevirtual |
Handle a TestSet request.
This function converts the argument to shared_ptr<V>() and calls testset() with the converted value. If conversion fails, testset() is not called. This function also stores the given value to the new_value member.
| v | The new value for the variable. |
Implements agentxcpp::AbstractVariable.
Definition at line 162 of file Variable.hpp.
References agentxcpp::Variable< T >::new_value, agentxcpp::Variable< T >::testset(), and agentxcpp::AbstractVariable::wrongType.
|
inlinevirtual |
Handle a UndoSet request.
This function calls undoset() with the value from the last handle_testset() invocation and returns its return value.
Implements agentxcpp::AbstractVariable.
Definition at line 270 of file Variable.hpp.
References agentxcpp::Variable< T >::new_value, and agentxcpp::Variable< T >::undoset().
|
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.
| v | The new value for the object. |
Definition at line 194 of file Variable.hpp.
References agentxcpp::AbstractVariable::noAccess.
Referenced by agentxcpp::Variable< T >::handle_testset().
|
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.
A default implementation is provided to allow implementing read-only variables.
| v | The new value for the object. |
Definition at line 297 of file Variable.hpp.
Referenced by agentxcpp::Variable< T >::handle_undoset().
|
private |
The new value for the variable in a Set operation.
The Set operation is performed in up to four steps (testset, commitset, cleanupset, undoset). Only the testset step actually receives the new value. This value is stored here so that it can be delivered to commitset(), undoset() and cleanupset().
Definition at line 112 of file Variable.hpp.
Referenced by agentxcpp::Variable< T >::handle_cleanupset(), agentxcpp::Variable< T >::handle_commitset(), agentxcpp::Variable< T >::handle_testset(), and agentxcpp::Variable< T >::handle_undoset().