SNMP++  3.3.4
SnmpTarget Class Reference

Abstract class used to provide a virtual interface into Targets. More...

#include <target.h>

Inheritance diagram for SnmpTarget:
Collaboration diagram for SnmpTarget:

Public Types

enum  target_type { type_base, type_ctarget, type_utarget }
 Enum to identify a target object through SnmpTarget::get_type() method. More...
 

Public Member Functions

 SnmpTarget ()
 Create a SnmpTarget object with default values. More...
 
 SnmpTarget (const Address &address)
 Create a SnmpTarget object with the given Address. More...
 
virtual ~SnmpTarget ()
 Destructor that has nothing to do. More...
 
target_type get_type () const
 Return the type of the target object. More...
 
bool valid () const
 Returns the validity of the target object. More...
 
void set_retry (const int r)
 Set the retry value. More...
 
int get_retry () const
 Get the retry value. More...
 
void set_timeout (const unsigned long t)
 Set the timeout for requests. More...
 
unsigned long get_timeout () const
 Get the timeout. More...
 
virtual SnmpTargetclone () const
 Clone operator. More...
 
bool get_address (GenAddress &address) const
 Get the address object. More...
 
const GenAddressget_address () const
 Get the address object. More...
 
virtual bool set_address (const Address &address)
 Set the address object. More...
 
snmp_version get_version () const
 Get the SNMP version for this target. More...
 
void set_version (const snmp_version v)
 Set the SNMP version of this target. More...
 
int operator== (const SnmpTarget &rhs) const
 Overloeaded compare operator. More...
 
virtual void clear ()
 Reset the object. More...
 

Static Public Member Functions

static void set_default_timeout (const unsigned long t)
 Change the default timeout. More...
 
static void set_default_retries (const int r)
 Change the default retries vlaue. More...
 

Protected Attributes

bool validity
 Validity of the object. More...
 
unsigned long timeout
 xmit timeout in 10 milli secs More...
 
int retries
 number of retries More...
 
snmp_version version
 SNMP version to use. More...
 
target_type ttype
 Type of the target. More...
 
GenAddress my_address
 Address object. More...
 

Static Protected Attributes

static unsigned long default_timeout
 default timeout for new objects More...
 
static int default_retries
 default retries for new objects More...
 

Detailed Description

Abstract class used to provide a virtual interface into Targets.

Note
Although it is possible to create an object of this class, you won't be happy with that...

Definition at line 92 of file target.h.

Member Enumeration Documentation

Enum to identify a target object through SnmpTarget::get_type() method.

Enumerator
type_base 

It is a SnmpTarget object.

type_ctarget 

It is a CTarget object.

type_utarget 

It is a Utarget object.

Definition at line 99 of file target.h.

Constructor & Destructor Documentation

SnmpTarget::SnmpTarget ( )
inline

Create a SnmpTarget object with default values.

The validity of the target will be false.

Definition at line 110 of file target.h.

SnmpTarget::SnmpTarget ( const Address address)
inline

Create a SnmpTarget object with the given Address.

Definition at line 117 of file target.h.

virtual SnmpTarget::~SnmpTarget ( )
inlinevirtual

Destructor that has nothing to do.

Definition at line 125 of file target.h.

Member Function Documentation

virtual void SnmpTarget::clear ( )
virtual

Reset the object.

Reimplemented in UTarget, and CTarget.

virtual SnmpTarget* SnmpTarget::clone ( ) const
virtual

Clone operator.

Virtual clone operation for creating a new SnmpTarget from an existing SnmpTarget.

Note
The caller MUST use the delete operation on the return value when done.
Returns
A pointer to the new object on success, 0 on failure.

Reimplemented in UTarget, and CTarget.

bool SnmpTarget::get_address ( GenAddress address) const

Get the address object.

Parameters
address- GenAddress object to store the target address.
Returns
true on success.
const GenAddress& SnmpTarget::get_address ( ) const
inline

Get the address object.

Returns
The target address.

Definition at line 222 of file target.h.

int SnmpTarget::get_retry ( ) const
inline

Get the retry value.

Returns
The number of retries on timeout.

Definition at line 156 of file target.h.

unsigned long SnmpTarget::get_timeout ( ) const
inline

Get the timeout.

Returns
The timeout for requests sent using this target object.

Definition at line 173 of file target.h.

target_type SnmpTarget::get_type ( ) const
inline

Return the type of the target object.

If a SNMP message is received through a callback (that only passes a SnmpTarget pointer to the callback function), this method can be used to check the type of the object before doing a cast to CTarget or UTarget.

Definition at line 135 of file target.h.

snmp_version SnmpTarget::get_version ( ) const
inline

Get the SNMP version for this target.

Returns
The SNMP version of this target object.
See Also
enum snmp_version

Definition at line 238 of file target.h.

int SnmpTarget::operator== ( const SnmpTarget rhs) const

Overloeaded compare operator.

Two SnmpTarget objects are considered equal, if all member variables are equal.

Returns
1 if targets are equal, 0 if not.
virtual bool SnmpTarget::set_address ( const Address address)
virtual

Set the address object.

Parameters
address- The address that this target should use.
Returns
true on success.

Reimplemented in UTarget.

static void SnmpTarget::set_default_retries ( const int  r)
inlinestatic

Change the default retries vlaue.

Changing the default retries value will only have an effect for target objects that are created after setting this value.

Parameters
r- The new retries value

Definition at line 194 of file target.h.

static void SnmpTarget::set_default_timeout ( const unsigned long  t)
inlinestatic

Change the default timeout.

Changing the default timeout value will only have an effect for target objects that are created after setting this value.

Parameters
t- The new default timeout value

Definition at line 183 of file target.h.

void SnmpTarget::set_retry ( const int  r)
inline

Set the retry value.

Parameters
r- The number of retries if no response is received.

Definition at line 149 of file target.h.

void SnmpTarget::set_timeout ( const unsigned long  t)
inline

Set the timeout for requests.

The default timeout for requests is 1 second (100).

Parameters
t- Timeout in 10ms, so 100 will set the timeout to 1 second.

Definition at line 166 of file target.h.

void SnmpTarget::set_version ( const snmp_version  v)
inline

Set the SNMP version of this target.

Parameters
v- The SNMP version that should be used for sending messages.

Definition at line 245 of file target.h.

bool SnmpTarget::valid ( ) const
inline

Returns the validity of the target object.

Returns
true, if the target is valid.

Definition at line 142 of file target.h.

Member Data Documentation

int SnmpTarget::default_retries
staticprotected

default retries for new objects

Definition at line 271 of file target.h.

unsigned long SnmpTarget::default_timeout
staticprotected

default timeout for new objects

Definition at line 270 of file target.h.

GenAddress SnmpTarget::my_address
protected

Address object.

Definition at line 268 of file target.h.

int SnmpTarget::retries
protected

number of retries

Definition at line 265 of file target.h.

unsigned long SnmpTarget::timeout
protected

xmit timeout in 10 milli secs

Definition at line 264 of file target.h.

target_type SnmpTarget::ttype
protected

Type of the target.

Definition at line 267 of file target.h.

bool SnmpTarget::validity
protected

Validity of the object.

Definition at line 263 of file target.h.

snmp_version SnmpTarget::version
protected

SNMP version to use.

Definition at line 266 of file target.h.


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