class Dependency

A class which relates objects and handles dependencies between them. More...

 
LOGO
 Annotated List  Files  Globals  Hierarchy  Index  Top

Public Types

Public Methods


Detailed Description

This class is a container of objects [pointers]. It relates string object names to the actual objects. Also, it has the ability to add and remove dependencies to that objects. A dependency is some entity which is using a specific object in the Dependency container. This entity is string represented.

For example, if a policy x uses set y, Set y will have x added in its dependencies. This means that x depends on y.

Having a consistent dependency list allows objects to be deleted correctly.

typedef list<string> DependencyList

DependencyList

typedef pair<T*,DependencyList> Pair

Pair

typedef map<string,Pair*> Map

Map

typedef set<string> KEYS

KEYS

ObjPair (struct)

ObjPair

DependencyError (class)

DependencyError

Such as deleting an object which has a non empty dependency list.

 Dependency ()

Dependency

 ~Dependency ()

~Dependency

void  clear ()

clear

bool  exists (const string& objectname)

exists

[const]

Checks if an object is present in the container.

Parameters:

objectnamename of the object.

Returns: true if object is contained. False otherwise.

bool  create (const string& objectname, T* object)

create

Attempts to create an object. If creation is successfull, the object ownership is transfered to this container. The caller should not modify / delete the object any more.

If object exists, creation fails.

Parameters:

objectnamename of the object.
objectthe actual object.

Returns: true if creation was successful. False otherwise.

void  remove (const string& objectname)

remove

Tries to remove and delete an object. Checks if object is in use [non empty dependency list].

Throws an exception on failure.

Parameters:

objectnameobject to remove and delete.
void  add_dependency (const string& objectname, const string& dep)

add_dependency

Adds dependencies to this object. A dependency is another object which uses this object.

Throws an exception if object does not exist.

Parameters:

objectnamename of object to which dependency should be added.
depname of object which depends on objectname.
void  del_dependency (const string& objectname, const string& dep)

del_dependency

Deletes a dependency on an object.

Throws an exception if object does not exist.

Parameters:

objectnamename of object to which dependency should be removed.
depname of dependency to remove.
T&  find (const string& objectname)

find

[const]

Returns the object being searched for.

Parameters:

objectnamename of object to return.

Returns: object requested.

T*  find_ptr (const string& objectname)

find_ptr

[const]

Returns a pointer the object being searched for.

Parameters:

objectnamename of object to return.

Returns: a pointer to the object requested if found, otherwise NULL.

void  get_deps (const string& objectname, set<string>& deps)

get_deps

[const]

Obtains the dependency list for an object.

Duplicates are removed, as it is a set.

Parameters:

objectnamename of object for which dependency list is requested.
depsset of strings filled with dependency list.
void  update_object (const string& objectname,T* obj)

update_object

Replaces an object. The previous one is deleted. Caller does not own object. Should not modify or delete it.

Throws an exception if object does not exist.

Parameters:

objectnamename of object to replace.
objthe new object.
typename Map::const_iterator  get_iterator ()

get_iterator

[const]

Obtain an iterator for this container.

Returns: iterator for Dependency container.

bool  has_next (const typename Map::const_iterator& i)

has_next

[const]

Checks if more objects are available with this iterator.

Parameters:

iiterator to use.

Returns: true if more objects are available. False otherwise.

ObjPair  next (typename Map::const_iterator& i)

next

[const]

Returns the next object pair and increments the iterator.

An object pair consists of the object name, and the actual object.

Parameters:

iiterator that points to object. Iterator is then incremented.

Returns: the object pair associated with the iterator.

void  keys (KEYS& out)

keys

[const]


Generated by: pavlin on kobe.xorp.net on Wed Jan 7 19:11:02 2009, using kdoc 2.0a54+XORP.