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

Manage an SNMP table. More...

#include <Table.hpp>

Collaboration diagram for agentxcpp::Table:

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...
 

Private Attributes

QMap< QSharedPointer
< TableEntry >, Oid
entries
 The managed TableEntry objects. More...
 
MasterProxymyMasterProxy
 The used MasterProxy object. More...
 
Oid myOid
 The tables OID. 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.

Todo:
Table should detect index changes and re-add the variables accordingly. Suggestion: AbstractVariable should provide a valueChanged() signal, the Table object registers to this signal for all variables in an entry. If the signal is fired, the table checks whether the TableEntry index changed, and if so, re-adds the variables. I think QSignalMapper is needed.

Definition at line 67 of file Table.hpp.

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.

Definition at line 84 of file Table.hpp.

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.

Definition at line 29 of file Table.cpp.

References agentxcpp::MasterProxy::addVariables(), entries, agentxcpp::Oid::is_null(), myMasterProxy, and myOid.

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.

Definition at line 24 of file Table.cpp.

References entries.

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.

Definition at line 156 of file Table.hpp.

References myMasterProxy.

Oid agentxcpp::Table::oid ( )
inline

Get the table's OID.

Returns
The OID used for the table.
Exceptions
None.

Definition at line 123 of file Table.hpp.

References myOid.

Referenced by setOid().

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.

Definition at line 96 of file Table.cpp.

References entries, myMasterProxy, myOid, and agentxcpp::MasterProxy::removeVariables().

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.
Todo:
: Remove variables from master, re-add them at new master.

Definition at line 144 of file Table.hpp.

References myMasterProxy.

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.
Todo:
Provide a clear() method to cleanly remove all tableEntry's
Todo:
Re-add managed variables in case of OID change.

Definition at line 111 of file Table.hpp.

References myOid, and oid().

Member Data Documentation

QMap< QSharedPointer<TableEntry>, Oid > agentxcpp::Table::entries
private

The managed TableEntry objects.

For each entry the following data is stored:

  • a pointer to the TableEntry object and
  • the TableEntry's index at the time it was added to the table.

Definition at line 216 of file Table.hpp.

Referenced by addEntry(), contains(), and removeEntry().

MasterProxy* agentxcpp::Table::myMasterProxy
private

The used MasterProxy object.

May be NULL.

Definition at line 223 of file Table.hpp.

Referenced by addEntry(), masterProxy(), removeEntry(), and setMasterProxy().

Oid agentxcpp::Table::myOid
private

The tables OID.

Definition at line 228 of file Table.hpp.

Referenced by addEntry(), oid(), removeEntry(), and setOid().


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