class Dependancy

A class which relates objects and handles dependancies 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 dependancies to that objects. A dependancy is some entity which is using a specific object in the Dependancy container. This entity is string represented.

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

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

typedef list<string> DependancyList

DependancyList

typedef pair<T*,DependancyList> Pair

Pair

typedef map<string,Pair*> Map

Map

ObjPair (struct)

ObjPair

DependancyError (class)

DependancyError

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

 Dependancy ()

Dependancy

 ~Dependancy ()

~Dependancy

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

Throws an exception on failure.

Parameters:

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

add_dependancy

Adds dependancies to this object. A dependancy is another object which uses this object.

Throws an exception if object does not exist.

Parameters:

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

del_dependancy

Deletes a dependancy on an object.

Throws an exception if object does not exist.

Parameters:

objectnamename of object to which dependancy should be removed.
depname of dependancy 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 dependancy list for an object.

Duplicates are removed, as it is a set.

Parameters:

objectnamename of object for which dependancy list is requested.
depsset of strings filled with dependancy 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 Dependancy 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.


Generated by: bms on anglepoise.lon.incunabulum.net on Wed Jul 23 10:05:59 2008, using kdoc 2.0a54+XORP.