|
xorp
|
An interface to VarRW which deals with memory management. More...
#include <single_varrw.hh>
Classes | |
| class | SingleVarRWErr |
| Exception thrown on error, such as reading unsupported variable. More... | |
Public Member Functions | |
| const Element & | read (const Id &id) |
| Implementation of VarRW read. | |
| void | write (const Id &id, const Element &e) |
| Implementation of VarRW write. | |
| void | sync () |
| Implementation of VarRW sync. | |
| void | initialize (const Id &id, Element *e) |
| Register a variable for read access with SingleVarRW. | |
| void | initialize (PolicyTags &pt) |
| virtual void | start_read () |
| If any reads are performed, this is a marker which informs the derived class that reads will now start. | |
| virtual void | start_write () |
| If any writes were performed, this is a marker which informs the derived class that writes will start. | |
| virtual void | single_write (const Id &id, const Element &e)=0 |
| Write of a variable. | |
| virtual Element * | single_read (const Id &id)=0 |
| Read of a variable. | |
| virtual void | end_write () |
| Marks the end of writes in case there were any modified fields. | |
Private Attributes | |
| Element * | _trash [16] |
| unsigned | _trashc |
| const Element * | _elems [VAR_MAX] |
| bool | _modified [VAR_MAX] |
| bool | _did_first_read |
| PolicyTags * | _pt |
An interface to VarRW which deals with memory management.
Read and writes are cached, so they are done only once on the route, not matter how many time the filter requests or writes the variable.
Because of this caching, the SingleVarRW is usuable only once. After it has done its work once, it has to be re-created.
| void SingleVarRW::initialize | ( | const Id & | id, |
| Element * | e | ||
| ) |
Register a variable for read access with SingleVarRW.
SingleVarRW owns the element, so derived classes do not need to worry about deleting objects.
All supported variables must be registered, even the ones not present in the current route. For example v6 nexthops must be set to ElemNull on v4 routes. [assuming the protocol itself supports v6].
| id | identifier of variable that may be read. |
| e | value of variable. |
| const Element & SingleVarRW::read | ( | const Id & | id | ) | [virtual] |
| virtual Element* SingleVarRW::single_read | ( | const Id & | id | ) | [pure virtual] |
Read of a variable.
The VarRW needs to read a particular element. This may return NULL indicating ElemNull---i.e. variable not present in THIS route.
Implemented in BGPVarRW< A >, OlsrVarRW, Fib2mribVarRW, OspfVarRW< A >, RIBVarRW< A >, RIPVarRW< A >, StaticRoutesVarRW, and BGPVarRW< IPv4 >.
| virtual void SingleVarRW::single_write | ( | const Id & | id, |
| const Element & | e | ||
| ) | [pure virtual] |
Write of a variable.
The write MUST be performed now, as the element pointer may become invalid after this call. Also, a single write will be called for each modified element.
| id | identifier of variable to be written to. |
| e | value of variable. |
Implemented in BGPVarRW< A >, OlsrVarRW, Fib2mribVarRW, OspfVarRW< A >, RIBVarRW< A >, RIPVarRW< A >, StaticRoutesVarRW, BGPVarRW< IPv4 >, OspfVarRW< A >, and OspfVarRW< A >.
| void SingleVarRW::sync | ( | ) | [virtual] |
| void SingleVarRW::write | ( | const Id & | id, |
| const Element & | e | ||
| ) | [virtual] |