The MibTable class is a container class for MibTableRow objects, but seen from the users view point a MibTable seems to contain only MibLeaf objects. A MibTable object must be initialised by adding to it a set of MibLeaf objects called columnar objects. This is best done in the constructor of your sub-class of MibTable by using the add_col member function (see section 5.5.1.3). Each columnar object is the master copy for any columnar object instance of its column. Whenever a new row is created MibTable will clone each columnar object once to build the new row. Hence, it is necessary to redefine the clone method of every class derivied from MibLeaf.
MibTable automatically sets the object identifiers of every object of a new row. If the columnar objects that are part of the index are scalar and the index has a fixed length MibTable can set the values of the index objects of a row accordingly to its index value. Figure 7 shows an example with a fixed index length of two, so the first two columnar objects are part of the index. Because each sub-identifier of the index corresponds to its scalar columnar object the automatic index generation can be used in the shown example.
As soon as all columnar objects have been added, rows can be added to the empty table by using the add_row member function. The add_row member function needs an object identifier representing the row´s index as single parameter. The MibLeaf objects cloned from the columnar objects are then responsible for answering SNMP requests (see section 5.3.1.3). Rows can be added automatically by SNMP SET requests if the MibTable object contains a snmpRowStatus columnar object. See section 5.8 for more information about the SMIv2 row status mechanism. Rows can be removed with the remove_row member function.
How a SNMP table can be coded to AGENT++ is shown in figures 8 and 9.
[IMAGE ]
Figure 7: Structure of MibLeaf objects contained in a
MibTable object
[IMAGE ]
Figure 8: Example for a Coffee-Percolator Scheduling Table (Constructors)
[IMAGE ]
Figure 9: Example for a Coffee-Percolator Scheduling Table (Method Routines)