AgentXcpp  Version:0.3
API Documentation
 All Classes Functions Variables Enumerations Enumerator Friends Pages
agentxcpp::Table Class Reference

Manage an SNMP table. More...

#include <Table.hpp>

Public Member Functions

 Table (Oid oid=Oid(), MasterProxy *master=0)
 Constructor. More...
 
void setOid (Oid oid)
 Set the OID of the table. More...
 
Oid oid ()
 Get the table's OID. More...
 
void setMasterProxy (MasterProxy *master)
 Set the MasterProxy object used by this table. More...
 
MasterProxymasterProxy ()
 Get the MasterProxy object associated with this table. More...
 
bool addEntry (QSharedPointer< TableEntry > entry)
 Add an entry to the table. More...
 
bool contains (QSharedPointer< TableEntry > entry) const
 Check whether the table contains a given entry. More...
 
bool removeEntry (QSharedPointer< TableEntry > entry)
 Remove an entry from the table. More...
 

Detailed Description

Manage an SNMP table.

This class manages a sequence of TableEntry objects. Unlike normal variables (which inherit from AbstractVariable), the table cannot be registered with a MasterProxy object. Instead, the table itself holds a pointer to a MasterProxy object and adds and removes its variables dynamically.

To implement an SNMP table, a Table object is created and provided with

  • its own OID (which is the "root node" of all contained variables) and
  • a MasterProxy object. As long as the MasterProxy object is not provided, no entries can be added or removed from the table.

Each TableEntry object has an index, which must be unique within a table. The Table class ensures this when adding a TableEntry.

The OID's of the variables within a table are derived from the index of their TableEntry, which in turn is derived from the contents of the index variables of that very entry. The index variables are normal SNMP variables which can be changed (either programatically or by an SNMP set operation). In such a case, the TableEntry's index would change. However, the Table object is currently not able to detect such a change, i.e. variables will keep their OID instead of changing it according to the new index.

Constructor & Destructor Documentation

agentxcpp::Table::Table ( Oid  oid = Oid(),
MasterProxy master = 0 
)
inline

Constructor.

Create a Table object, assign it an OID and associate it with a MasterProxy object. If master is 0, no TableEntry's may be added.

Parameters
oidThe tables OID.
masterThe MasterProxy which is used by the table to add variables.
Exceptions
None.

Member Function Documentation

bool Table::addEntry ( QSharedPointer< TableEntry entry)

Add an entry to the table.

This method adds all variables of the entry to the MasterProxy.

This function fails in the following cases:

  • no MasterProxy is currently associated with the table
  • the entry was already added.
Parameters
entryThe TableEntry object to add.
Returns
true on success, false otherwise.
Exceptions
None.
bool Table::contains ( QSharedPointer< TableEntry entry) const

Check whether the table contains a given entry.

Parameters
entryThe entry to search for.
Returns
True if the table contains the entry, false otherwise.
Exceptions
None.
MasterProxy* agentxcpp::Table::masterProxy ( )
inline

Get the MasterProxy object associated with this table.

Returns
The MasterProxy used for by table. May be the NULL pointer.
Exceptions
None.
Oid agentxcpp::Table::oid ( )
inline

Get the table's OID.

Returns
The OID used for the table.
Exceptions
None.
bool Table::removeEntry ( QSharedPointer< TableEntry entry)

Remove an entry from the table.

This method removes all variables of the entry from the MasterProxy.

This function fails in the following cases:

  • no MasterProxy is currently associated with the table
  • the entry is not known to the table (it was not added, or it was already removed).
Parameters
entryThe TableEntry object to remove.
Returns
true on success, false otherwise.
Exceptions
None.
void agentxcpp::Table::setMasterProxy ( MasterProxy master)
inline

Set the MasterProxy object used by this table.

Parameters
masterThe new MasterProxy object.
Note
The MasterProxy should not be changed while TableEntry objects are managed by the Table object. If this happens, the old MasterProxy will provide access to the variables added before infinitely. The only way to remove those variables is to do so manually, using e.g. MasterProxy::remove_variable().
Exceptions
None.
void agentxcpp::Table::setOid ( Oid  oid)
inline

Set the OID of the table.

This OID is used to build up the full OID of the variables contained in the table.

Note
The OID should not be changed while TableEntry objects are managed by the Table object. If this happens, the MasterProxy will provide access to the variables added before the OID change infinitely. The only way to remove those variables is to do so manually, using e.g. MasterProxy::remove_variable().
Parameters
oidThe new table OID.
Exceptions
None.