xorp

SingleVarRW Class Reference

An interface to VarRW which deals with memory management. More...

#include <single_varrw.hh>

Inheritance diagram for SingleVarRW:
NONCOPYABLE VarRW BGPVarRW< A > Fib2mribVarRW OlsrVarRW OspfVarRW< A > RIBVarRW< A > RIPVarRW< A > StaticRoutesVarRW BGPVarRWExport< A >

List of all members.

Classes

class  SingleVarRWErr
 Exception thrown on error, such as reading unsupported variable. More...

Public Member Functions

const Elementread (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 Elementsingle_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

Detailed Description

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.


Member Function Documentation

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

Parameters:
ididentifier of variable that may be read.
evalue of variable.
const Element & SingleVarRW::read ( const Id &  id) [virtual]

Implementation of VarRW read.

Returns:
variable requested.
Parameters:
ididentifier of variable to be read.

Implements VarRW.

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.

Returns:
variable requested.
Parameters:
idthe id of the variable.

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.

Parameters:
ididentifier of variable to be written to.
evalue 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]

Implementation of VarRW sync.

Writes are performed now, as cached Element* pointers may become invalid afterwards.a

trash is also emptied upon completion.

Reimplemented from VarRW.

void SingleVarRW::write ( const Id &  id,
const Element e 
) [virtual]

Implementation of VarRW write.

Parameters:
ididentifier of variable to be written to.
evalue of variable to be written to.

Implements VarRW.


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations