AgentXcpp  Revision:4ac4848
Internals Documentation
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends
agentxcpp::oid Class Reference

Represents an SNMP object identifier (OID) More...

#include <oid.hpp>

Inheritance diagram for agentxcpp::oid:
[legend]
Collaboration diagram for agentxcpp::oid:
[legend]

List of all members.

Public Member Functions

 oid (uint32_t c1=0, uint32_t c2=0, uint32_t c3=0, uint32_t c4=0, uint32_t c5=0, uint32_t c6=0, uint32_t c7=0, uint32_t c8=0, uint32_t c9=0, uint32_t c10=0, uint32_t c11=0, uint32_t c12=0, uint32_t c13=0, uint32_t c14=0, uint32_t c15=0, uint32_t c16=0, uint32_t c17=0, uint32_t c18=0, uint32_t c19=0, uint32_t c20=0)
 Initialize an oid object with a sequence of up to 20 subidentifiers.
 oid (const oid &o, uint32_t c1=0, uint32_t c2=0, uint32_t c3=0, uint32_t c4=0, uint32_t c5=0, uint32_t c6=0, uint32_t c7=0, uint32_t c8=0, uint32_t c9=0, uint32_t c10=0, uint32_t c11=0, uint32_t c12=0, uint32_t c13=0, uint32_t c14=0, uint32_t c15=0, uint32_t c16=0, uint32_t c17=0, uint32_t c18=0, uint32_t c19=0)
 Initialize an oid object with another oid plus a sequence of up to 19 subidentifiers.
oidoperator= (const oid &oid)
 Assignment operator.
bool get_include ()
 get the current include value
void set_include (bool i)
 set the include value
data_t serialize () const
 Encode an OID object as described in RFC 2741, section 5.1.
 oid (data_t::const_iterator &pos, const data_t::const_iterator &end, bool big_endian=true)
 Construct the object from input stream.
bool operator< (const oid &o) const
 The less-than operator.
bool operator== (const oid &o) const
 The equal-operator.
bool operator!= (const oid &o) const
 The not-equal-operator for oids.
bool operator> (const oid &o) const
 The greater-than operator.

Private Attributes

bool include
 the 'include' field.

Friends

std::ostream & operator<< (std::ostream &, const agentxcpp::oid &)
 The output operator for the oid class.

Detailed Description

Represents an SNMP object identifier (OID)

This class represents an OID. OID's are sequences of integers. This class inherits from std:vector<>, which means that an oid object can be manipulated much the same way as a std::vector<> can be manipulated.

In addition, the OID class provides constructors taking a number of integers to ease creatng such objects. For example, this works:

 oid myCompany = oid(1,3,6,1,4,1,355);

Also a constructor is provided which takes an oid and a number of integers, so this works also:

 oid myObject = oid(myCompany,1,1,3,42);

In addition, some common oid's are provided as constants, e.g. 'enterprises', so the following will also work:

 oid myCompany = oid(enterprises,355);

Definition at line 58 of file oid.hpp.


Constructor & Destructor Documentation

oid::oid ( uint32_t  c1 = 0,
uint32_t  c2 = 0,
uint32_t  c3 = 0,
uint32_t  c4 = 0,
uint32_t  c5 = 0,
uint32_t  c6 = 0,
uint32_t  c7 = 0,
uint32_t  c8 = 0,
uint32_t  c9 = 0,
uint32_t  c10 = 0,
uint32_t  c11 = 0,
uint32_t  c12 = 0,
uint32_t  c13 = 0,
uint32_t  c14 = 0,
uint32_t  c15 = 0,
uint32_t  c16 = 0,
uint32_t  c17 = 0,
uint32_t  c18 = 0,
uint32_t  c19 = 0,
uint32_t  c20 = 0 
)

Initialize an oid object with a sequence of up to 20 subidentifiers.

This constructor takes up to 20 subidentifiers which forms up the object identifier. More subidentifiers can be added using functions from the vector<> class.

The 'include' field is initialized to 'false'.

This is also the default constructor.

Note:
Zero (0) is not allowed for a subidentifier, i.e. the first subidentifier with value 0 and all its successors are ignored.

Definition at line 28 of file oid.cpp.

References include.

oid::oid ( const oid o,
uint32_t  c1 = 0,
uint32_t  c2 = 0,
uint32_t  c3 = 0,
uint32_t  c4 = 0,
uint32_t  c5 = 0,
uint32_t  c6 = 0,
uint32_t  c7 = 0,
uint32_t  c8 = 0,
uint32_t  c9 = 0,
uint32_t  c10 = 0,
uint32_t  c11 = 0,
uint32_t  c12 = 0,
uint32_t  c13 = 0,
uint32_t  c14 = 0,
uint32_t  c15 = 0,
uint32_t  c16 = 0,
uint32_t  c17 = 0,
uint32_t  c18 = 0,
uint32_t  c19 = 0 
)

Initialize an oid object with another oid plus a sequence of up to 19 subidentifiers.

The 'include' field is copied from o.

This is also the copy constructor.

Note:
Zero (0) is not allowed for a subidentifier, i.e. the first subidentifier with value 0 and all its successors are ignored.

Definition at line 63 of file oid.cpp.

oid::oid ( data_t::const_iterator &  pos,
const data_t::const_iterator &  end,
bool  big_endian = true 
)

Construct the object from input stream.

This constructor parses the serialized form of the object. It takes an iterator, starts parsing at the position of the iterator and advances the iterator to the position right behind the object.

The constructor expects valid data from the stream; if parsing fails, parse_error is thrown. In this case, the iterator is left at an undefined position.

Parameters:
posIterator pointing to the current stream position. The iterator is advanced while reading the header.
endIterator pointing one element past the end of the current stream. This is needed to mark the end of the buffer.
big_endianWhether the input stream is in big endian format
Exceptions:
parse_errorIf parsing fails. In this case, the iterator is left at an undefined position.

Definition at line 197 of file oid.cpp.

References include.


Member Function Documentation

bool agentxcpp::oid::get_include ( ) [inline]

get the current include value

The include value is present in the serialized form of an OID. If an OID object is created by parsing a AgentX message, the 'include' member is set accordingly.

See RFC 2741, sections 5.1 and 5.2 for details.

Definition at line 131 of file oid.hpp.

References include.

bool agentxcpp::oid::operator!= ( const oid o) const [inline]

The not-equal-operator for oids.

See operator<() for a more detailed description about comparing OIDs.

Definition at line 234 of file oid.hpp.

bool oid::operator< ( const oid o) const

The less-than operator.

An OID is less than another OID if either the first not-identical part is lesser or if all parts are identical and it has lesser parts.

Example:
1.3.6.1.4.1.42.3.3.1
is less than
1.3.6.1.4.1.42.3.4.1
Note the next to last number.

Also,
1.3.6.1.4.1.42.3.3.1
is less than
1.3.6.1.4.1.42.3.3.1.1
because it is shorter.

However,
1.3.6.1.4.1.42.3.3.1
is greater than
1.3.6.1.4.1.42.3.2.1.1
because the 9th number is greater (although the first OID has less numbers than the second).

Definition at line 266 of file oid.cpp.

oid & oid::operator= ( const oid oid)

Assignment operator.

Definition at line 343 of file oid.cpp.

References include.

bool oid::operator== ( const oid o) const

The equal-operator.

See operator<() for a more detailed description about comparing OIDs.

Definition at line 309 of file oid.cpp.

bool agentxcpp::oid::operator> ( const oid o) const [inline]

The greater-than operator.

See operator<() for a more detailed description about comparing OIDs.

Definition at line 245 of file oid.hpp.

data_t oid::serialize ( ) const [virtual]

Encode an OID object as described in RFC 2741, section 5.1.

Implements variable.

Definition at line 126 of file oid.cpp.

References include.

Referenced by agentxcpp::UnregisterPDU::serialize(), agentxcpp::varbind::serialize(), and agentxcpp::RegisterPDU::serialize().

void agentxcpp::oid::set_include ( bool  i) [inline]

set the include value

The include value is present in the serialized form of an OID. If an OID object is serialized, the include field is encoded into the stream.

See RFC 2741, sections 5.1 and 5.2 for details.

Definition at line 147 of file oid.hpp.

References include.


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  ,
const agentxcpp::oid  
) [friend]

The output operator for the oid class.

Object identifiers (oid objects) can be output as follows:

 oid led_state(enterprise,1,3,3,1);
 cout << "LED state OID: " << led_state << endl;

The last line will output "LED state OID: .1.3.6.1.4.1.3.3.1".


Member Data Documentation

bool agentxcpp::oid::include [private]

the 'include' field.

Definition at line 65 of file oid.hpp.

Referenced by get_include(), oid(), operator=(), serialize(), and set_include().


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