Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

Oid Class Reference

#include <oid.h>

Inheritance diagram for Oid:

[legend]
Collaboration diagram for Oid:
[legend]
List of all members.

Detailed Description

The Object Identifier Class.

The Object Identification (Oid) class is the encapsulation of an SMI object identifier. The SMI object is a data identifier for a data element found in a Management Information Base (MIB), as defined by a MIB definition. The SMI Oid, its related structures and functions, are a natural fit for object orientation. In fact, the Oid class shares many common features to the C++ String class. For those of you familiar with the C++ String class or Microsoft's Foundation Classes (MFC) CString class, the Oid class will be familiar and easy to use. The Oid class is designed to be efficient and fast. The Oid class allows definition and manipulation of object identifiers.

Definition at line 96 of file oid.h.

Public Member Functions

 Oid ()
 Construct an invalid Oid.

 Oid (const char *dotted_oid_string)
 Construct an Oid from a dotted string.

 Oid (const Oid &oid)
 Constructor using another oid object (copy constructor).

 Oid (const unsigned long *raw_oid, int oid_len)
 Constructor from array.

virtual ~Oid ()
 Destructor.

SmiUINT32 get_syntax () const
 Return the current syntax.

virtual Oidoperator= (const char *dotted_oid_string)
 Assignment from a string.

virtual Oidoperator= (const Oid &oid)
 Assign one Oid to another.

int get_asn1_length () const
 Return the space needed for serialization.

Oidoperator+= (const char *a)
 Append operator, appends the dotted oid string.

Oidoperator+= (const unsigned long i)
 Appends an int.

Oidoperator+= (const Oid &o)
 Appends an Oid.

unsigned long & operator[] (int position)
 Allows element access as an array.

unsigned long operator[] (int position) const
 Allows element access as an array for const objects.

SmiLPOID oidval ()
 Get the WinSnmp oid part.

void set_data (const unsigned long *raw_oid, const unsigned int oid_len)
 Set the data from raw form.

unsigned long len () const
 Get the length of the oid.

void trim (const unsigned long n=1)
 Trim off the rightmost values of an oid.

int nCompare (const unsigned long n, const Oid &o) const
 Compare two Oids from the left in direction left-to-right.

int RnCompare (const unsigned long n, const Oid &o) const
 Compare two Oids from the right in direction right-to left.

bool valid () const
 Return validity of the object.

const char * get_printable () const
 Get a printable ASCII string of the whole value.

const char * get_printable (const unsigned long n) const
 Get a printable ASCII string of the right part of the value.

const char * get_printable (const unsigned long start, const unsigned long n) const
 Get a printable ASCII string of a part of the value.

SnmpSyntaxclone () const
 Clone this object.

SnmpSyntaxoperator= (const SnmpSyntax &val)
 Map other SnmpSyntax objects to Oid.

void clear ()
 Clear the Oid.


Protected Member Functions

virtual int StrToOid (const char *string, SmiLPOID dstOid)
 Convert a string to an smi oid.

virtual int OidCopy (SmiLPOID srcOid, SmiLPOID dstOid)
 Clone an smi oid.

virtual int OidToStr (const SmiOID *srcOid, SmiUINT32 size, char *string) const
 Convert an smi oid to its string representation.

void delete_oid_ptr ()
 Free the internal oid pointer and set the pointer and the length to zero.


Protected Attributes

char * iv_str

Friends

DLLOPT friend int operator== (const Oid &lhs, const Oid &rhs)
 Overloaded equal operator.

DLLOPT friend int operator!= (const Oid &lhs, const Oid &rhs)
 Overloaded not equal operator.

DLLOPT friend int operator< (const Oid &lhs, const Oid &rhs)
 Overloaded less than < operator.

DLLOPT friend int operator<= (const Oid &lhs, const Oid &rhs)
 Overloaded less than <= operator.

DLLOPT friend int operator> (const Oid &lhs, const Oid &rhs)
 Overloaded greater than > operator.

DLLOPT friend int operator>= (const Oid &lhs, const Oid &rhs)
 Overloaded greater than >= operator.

DLLOPT friend int operator== (const Oid &lhs, const char *rhs)
 Overloaded equal operator operator.

DLLOPT friend int operator!= (const Oid &lhs, const char *rhs)
 Overloaded not equal operator.

DLLOPT friend int operator< (const Oid &lhs, const char *rhs)
 Overloaded less than < operator.

DLLOPT friend int operator<= (const Oid &lhs, char *rhs)
 Overloaded less than <= operator.

DLLOPT friend int operator> (const Oid &lhs, const char *rhs)
 Overloaded greater than > operator.

DLLOPT friend int operator>= (const Oid &lhs, const char *rhs)
 Overloaded greater than >= operator.

DLLOPT friend Oid operator+ (const Oid &lhs, const Oid &rhs)
 Overloaded operator +, Concatenate two Oids.


Constructor & Destructor Documentation

Oid::Oid  ) 
 

Construct an invalid Oid.

Oid::Oid const char *  dotted_oid_string  ) 
 

Construct an Oid from a dotted string.

Parameters:
dotted_oid_string - for example "1.3.1.6.1.10"

Oid::Oid const Oid oid  ) 
 

Constructor using another oid object (copy constructor).

Parameters:
oid - Source Oid

Oid::Oid const unsigned long *  raw_oid,
int  oid_len
 

Constructor from array.

Parameters:
raw_oid - array of oid values
oid_len - length of array

virtual Oid::~Oid  )  [virtual]
 

Destructor.


Member Function Documentation

void Oid::clear  )  [inline, virtual]
 

Clear the Oid.

Implements SnmpSyntax.

Definition at line 366 of file oid.h.

SnmpSyntax* Oid::clone  )  const [inline, virtual]
 

Clone this object.

Returns:
Pointer to the newly created object (allocated through new).

Implements SnmpSyntax.

Definition at line 356 of file oid.h.

void Oid::delete_oid_ptr  )  [inline, protected]
 

Free the internal oid pointer and set the pointer and the length to zero.

Definition at line 411 of file oid.h.

References SnmpSyntax::smival, and SmiVALUE::value.

int Oid::get_asn1_length  )  const [virtual]
 

Return the space needed for serialization.

Implements SnmpSyntax.

const char* Oid::get_printable const unsigned long  start,
const unsigned long  n
const
 

Get a printable ASCII string of a part of the value.

Parameters:
start - First position to print, starting with 1 (not zero!)
n - positions to print.
Returns:
Dotted oid string (for example "3.6.1.6")

const char* Oid::get_printable const unsigned long  n  )  const [inline]
 

Get a printable ASCII string of the right part of the value.

Parameters:
n - positions to print, counted from right.
Returns:
Dotted oid string (for example "6.0")

Definition at line 337 of file oid.h.

const char* Oid::get_printable  )  const [inline, virtual]
 

Get a printable ASCII string of the whole value.

Returns:
Dotted oid string (for example "1.3.6.1.6.0")

Implements SnmpSyntax.

Definition at line 327 of file oid.h.

SmiUINT32 Oid::get_syntax  )  const [inline, virtual]
 

Return the current syntax.

Returns:
always sNMP_SYNTAX_OID

Implements SnmpSyntax.

Definition at line 137 of file oid.h.

References SmiUINT32, and sNMP_SYNTAX_OID.

unsigned long Oid::len  )  const [inline]
 

Get the length of the oid.

Definition at line 288 of file oid.h.

Referenced by Pdu::get_notify_enterprise(), and Pdu::get_notify_id().

int Oid::nCompare const unsigned long  n,
const Oid o
const
 

Compare two Oids from the left in direction left-to-right.

Parameters:
n - Subvalues to compare
o - The Oid to compare with
Returns:
0 if equal / -1 if less / 1 if greater

virtual int Oid::OidCopy SmiLPOID  srcOid,
SmiLPOID  dstOid
[protected, virtual]
 

Clone an smi oid.

Parameters:
srcOid - source oid
dstOid - destination oid

virtual int Oid::OidToStr const SmiOID srcOid,
SmiUINT32  size,
char *  string
const [protected, virtual]
 

Convert an smi oid to its string representation.

Parameters:
srcOid - source oid
size - size of string
string - pointer to string

SmiLPOID Oid::oidval  )  [inline]
 

Get the WinSnmp oid part.

Note:
This method returns a pointer to internal data. If it is modified, the Oid changes too.
Returns:
pointer to the internal oid structure.

Definition at line 274 of file oid.h.

References SmiLPOID.

Oid& Oid::operator+= const Oid o  ) 
 

Appends an Oid.

Parameters:
o - Oid to add at the end

Oid& Oid::operator+= const unsigned long  i  ) 
 

Appends an int.

Parameters:
i - Value to add at the end of the Oid

Oid& Oid::operator+= const char *  a  ) 
 

Append operator, appends the dotted oid string.

Parameters:
a - dotted oid string, for example "5.192.14.6"

SnmpSyntax& Oid::operator= const SnmpSyntax val  )  [virtual]
 

Map other SnmpSyntax objects to Oid.

Reimplemented from SnmpSyntax.

virtual Oid& Oid::operator= const Oid oid  )  [virtual]
 

Assign one Oid to another.

virtual Oid& Oid::operator= const char *  dotted_oid_string  )  [virtual]
 

Assignment from a string.

Parameters:
dotted_oid_string - New value (for example "1.3.6.1.6.0");

unsigned long Oid::operator[] int  position  )  const [inline]
 

Allows element access as an array for const objects.

This method behaves like real array: if your position is out of bounds, you're lost!

Parameters:
position - valid position -- 0 to (len() - 1)
Returns:
Value on the given position

Definition at line 264 of file oid.h.

unsigned long& Oid::operator[] int  position  )  [inline]
 

Allows element access as an array.

This method behaves like real array: if your position is out of bounds, you're lost!

Parameters:
position - valid position -- 0 to (len() - 1)
Returns:
Value on the given position

Definition at line 252 of file oid.h.

int Oid::RnCompare const unsigned long  n,
const Oid o
const
 

Compare two Oids from the right in direction right-to left.

Parameters:
n - Subvalues to compare
o - The Oid to compare with
Returns:
0 if equal / -1 if less / 1 if greater

void Oid::set_data const unsigned long *  raw_oid,
const unsigned int  oid_len
 

Set the data from raw form.

Parameters:
raw_oid - Array of new values
oid_len - Length of the array raw_oid

virtual int Oid::StrToOid const char *  string,
SmiLPOID  dstOid
[protected, virtual]
 

Convert a string to an smi oid.

Parameters:
string - input string
dstOid - destination oid

void Oid::trim const unsigned long  n = 1  ) 
 

Trim off the rightmost values of an oid.

Parameters:
n - Trim off n values from the right (default is one)

bool Oid::valid  )  const [inline, virtual]
 

Return validity of the object.

Implements SnmpSyntax.

Definition at line 320 of file oid.h.


Friends And Related Function Documentation

DLLOPT friend int operator!= const Oid lhs,
const char *  rhs
[friend]
 

Overloaded not equal operator.

DLLOPT friend int operator!= const Oid lhs,
const Oid rhs
[friend]
 

Overloaded not equal operator.

DLLOPT friend Oid operator+ const Oid lhs,
const Oid rhs
[friend]
 

Overloaded operator +, Concatenate two Oids.

Definition at line 219 of file oid.h.

DLLOPT friend int operator< const Oid lhs,
const char *  rhs
[friend]
 

Overloaded less than < operator.

DLLOPT friend int operator< const Oid lhs,
const Oid rhs
[friend]
 

Overloaded less than < operator.

DLLOPT friend int operator<= const Oid lhs,
char *  rhs
[friend]
 

Overloaded less than <= operator.

DLLOPT friend int operator<= const Oid lhs,
const Oid rhs
[friend]
 

Overloaded less than <= operator.

DLLOPT friend int operator== const Oid lhs,
const char *  rhs
[friend]
 

Overloaded equal operator operator.

DLLOPT friend int operator== const Oid lhs,
const Oid rhs
[friend]
 

Overloaded equal operator.

DLLOPT friend int operator> const Oid lhs,
const char *  rhs
[friend]
 

Overloaded greater than > operator.

DLLOPT friend int operator> const Oid lhs,
const Oid rhs
[friend]
 

Overloaded greater than > operator.

DLLOPT friend int operator>= const Oid lhs,
const char *  rhs
[friend]
 

Overloaded greater than >= operator.

DLLOPT friend int operator>= const Oid lhs,
const Oid rhs
[friend]
 

Overloaded greater than >= operator.

Definition at line 424 of file oid.h.


Member Data Documentation

char* Oid::iv_str [protected]
 

Definition at line 403 of file oid.h.


The documentation for this class was generated from the following file:
Generated on Tue Jan 4 22:42:19 2005 for SNMP++ by doxygen 1.3.2