Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

Qmms::Log::Hierarchy Class Reference

This class retrieves categories by name from a QDict and maintains the category hierarchy. More...

#include <log.hh>

List of all members.

Public Methods

CategorygetCatInstance (const QString name, const QString fqn)
 Use this to get a pointer to a named category. More...

void shutdown ()
 Shuts down the qmmslog system properly. More...

void testMe ()
 Used for testing purposes and will be removed in the near future. More...

QString getRootName () const
 Accessor method. More...

 ~Hierarchy ()
 Destructor. More...


Static Public Methods

RootCategorygetRootCat ()
 Use this to get a reference to _the_ RootCategory. More...

Hierarchy * instance ()
 Use this to get a reference to _the_ Hierarchy. More...


Private Methods

 Hierarchy ()
 Default constructor. Does nothing. More...

 Hierarchy (RootCategory *r)
 Constructor. More...

void updateParents (Category *cat)
 Updates the parents of the given Category, to fit it properly into the Hierarchy. More...

void updateChildren (ProvisionNode *pn, Category *cat)
 Updates the links for all the children that placed themselves in the provision node 'pn'. More...


Static Private Attributes

Hierarchy * theInstance
 Pointer to "the" instance of this class. More...

RootCategoryrootCat
 Pointer to the RootCategory object, also a singleton. More...

BaseDict hierDict
 Pointer-based dictionary of categories (the hierachy dict). More...

const uint DICTSIZE
 Initial size of dictionary, a suitably large prime number. More...


Detailed Description

This class retrieves categories by name from a QDict and maintains the category hierarchy.

This class is instantiated exactly once. Attempts to create more than one instance simply return a pointer to the existing instance.

The structure of the category hierarchy is maintained by the getCatInstance() method. The hierarchy is such that children point to their parents but parents have no pointers to their children. Categories can be created in any order -- in particular, descendant before ancestor.

In the case that a descendant is created before a particular ancestor, then the descendant creates a provision node for the ancestor and adds itself to the provision node. Other descendants of the same ancestor add themselves to the previously created provision node.

One cannot (easily) access the (sic) Hierarchy object directly, since doing so would imperil the hierarchy of categories. Methods to obtain access to all of the appropriate parts of the Hierarchy object can be found as static methods in Category. You have been sufficiently warned.


Constructor & Destructor Documentation

Qmms::Log::Hierarchy::Hierarchy   [private]
 

Default constructor. Does nothing.

Qmms::Log::Hierarchy::Hierarchy RootCategory   r [private]
 

Constructor.

This is a private method. An instance of this class can be gotten only by using the instance() method, which ensures that only one instance of this class can exist at any time.

Parameters:
r  the RootCategory for this Category.

Qmms::Log::Hierarchy::~Hierarchy  
 

Destructor.

Deletes the theInstance pointer.


Member Function Documentation

Category* Qmms::Log::Hierarchy::getCatInstance const QString    name,
const QString    fqn
 

Use this to get a pointer to a named category.

Parameters:
name  the name of the desired Category
fqn  the fully-qualified name of the Category (usually the FQN of the class the Category is watching.)
Returns:
pointer to the desired Category

RootCategory* Qmms::Log::Hierarchy::getRootCat   [static]
 

Use this to get a reference to _the_ RootCategory.

QString Qmms::Log::Hierarchy::getRootName   const
 

Accessor method.

Returns:
the name of the root category

Hierarchy* Qmms::Log::Hierarchy::instance   [static]
 

Use this to get a reference to _the_ Hierarchy.

void Qmms::Log::Hierarchy::shutdown  
 

Shuts down the qmmslog system properly.

Should not be called directly but only through the static method Category::shutdown().

void Qmms::Log::Hierarchy::testMe  
 

Used for testing purposes and will be removed in the near future.

void Qmms::Log::Hierarchy::updateChildren ProvisionNode   pn,
Category   cat
[private]
 

Updates the links for all the children that placed themselves in the provision node 'pn'.

The second argument 'cat' is a reference for the newly created Category, the new parent of all the children in 'pn'.

We loop on all the children 'c' in 'pn':

If the child 'c' has been already linked as a child of 'cat' then there is no need to update 'c';

Otherwise, we set cat's parent field to c's parent and set c's parent field to cat.

Parameters:
pn  pointer to ProvisionNode whose children we need to update
cat  pointer to Category that is the new Parent of all the children of pn

void Qmms::Log::Hierarchy::updateParents Category   cat [private]
 

Updates the parents of the given Category, to fit it properly into the Hierarchy.

Parameters:
cat  pointer to the Category to be added to the Hierarchy
This method loops through all the _potential_ parents of 'cat'. There 3 possible cases:

(1) No entry for the potential parent of 'cat' exists. Then we create a ProvisionNode for this potential parent and insert 'cat' in that provision node.

(2) There exists an entry of type Category for the potential parent. This entry is cat's nearest existing parent. We update cat's parent field with this entry. We also break from the loop because updating our parent's parent is our parent's responsibility.

(3) There exists an entry of type ProvisionNode for this potential parent. We add 'cat' to the list of children for this potential parent.


Member Data Documentation

const uint Qmms::Log::Hierarchy::DICTSIZE [static, private]
 

Initial size of dictionary, a suitably large prime number.

"Suitably large" means >= the maximum expected number of items in the dictionary.

BaseDict Qmms::Log::Hierarchy::hierDict [static, private]
 

Pointer-based dictionary of categories (the hierachy dict).

RootCategory* Qmms::Log::Hierarchy::rootCat [static, private]
 

Pointer to the RootCategory object, also a singleton.

Hierarchy* Qmms::Log::Hierarchy::theInstance [static, private]
 

Pointer to "the" instance of this class.

Used to make this a singleton class, i.e., can only be instantiated once.


The documentation for this class was generated from the following file:
Generated on Fri Jan 3 15:04:03 2003 for QmmsLog by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001