table data manipulation query
McWilliams, Gary
gmcwilliams____cccnetsys.com
Wed Aug 16 15:19:00 CEST 2000
I have a table of elements (obviously).
My 'own app' provides status information to the SNMP MIB, thus I need to be
able to make my app update the values of data held within the table within
the mib.
I have been using the following code (this is simplified, but hopefully
explains the structure)
* my app calls a 'update state' method
* updatestate() has access to the pSnmpTable (MibTable *)
* What I need to do now is find the 'matching row' within the table. I need
to walk through each row and compare some data elements, until I find the
one matching my criteria.
* I do
// get a copy of the table
List<MibTableRow> *rows = pSnmpTable->get_rows_cloned()
ListCursor<MibTableRow> rowCur
for ( rowCur.init(rows); rowCur.get(); rowCur.next() ) {
//compare stuff, until I find my row
if ( rowCur.get()->get_nth(colId)->get_value(var) == something ) {
pSnmpTable->find_index( rowCur.get()->get_index()
)->get_nth(colIndex)->set_value(newState)
// so now I have poked back into the 'real' table and updated my state
variable
}
}
This has been working for some time, however the latest version of agent++ I
have (3.4c) has had a dramatic effect. It now takes about 1 second for the
get_rows_cloned() to return - it did not do this before (although it could
also be something else that is causing this problem, I know).
So, I'm looking at this again, and am having some problems.
1. Why do I call get_rows_cloned() instead of just finding the row within
the table?
well, if I replace the above code with
List<MibTableRow> rows = pSnmpTable->get_rows()
// get a copy of the table
ListCursor<MibTableRow> rowCur
for ( rowCur.init(&rows); rowCur.get(); rowCur.next() ) {
//compare stuff, until I find my row
if ( rowCur.get()->get_nth(colId)->get_value(var) == something ) {
pSnmpTable->find_index( rowCur.get()->get_index()
)->get_nth(colIndex)->set_value(newState)
// so now I have poked back into the 'real' table and updated my state
variable
}
}
then I get an access violation when calling the rowCur.get() for the
comparison test. Don't quite understand what the difference between calling
the cloned() and non-cloned methods is (they both return a list of pointers
right?).
The table rows are static - they get created upon application startup and
rows do not get dynamically added or removed during the running of the app.
Any ideas?
2. Is there a better way of searching the table for my row (note that I
cannot just use an OID or index element to find the data - my app has no
notion of these SNMP things, which is all managed by a seperate class
library)?
3. Did something change within 3.4c?
I notice that 3.4 now includes 'thread support' for NT (which is my platform
here). I have my own thread guards around some of this processing - would
these get in the way. The documentation of get_rows_cloned() states that
"this method is synchronised on its receiver". What does this mean exactly?
--
Gary McWilliams
Principal Engineer
CCC Network Systems Ltd, R&D facility Belfast
http://www.cccnetsys.com
More information about the AGENTPP
mailing list