#include <log.hh>
Public Methods | |
Category * | getCatInstance (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 | |
RootCategory * | getRootCat () |
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... | |
RootCategory * | rootCat |
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... |
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.
|
Default constructor. Does nothing.
|
|
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.
|
|
Destructor.
Deletes the |
|
Use this to get a pointer to a named category.
|
|
Use this to get a reference to _the_ RootCategory.
|
|
Accessor method.
|
|
Use this to get a reference to _the_ Hierarchy.
|
|
Shuts down the qmmslog system properly. Should not be called directly but only through the static method Category::shutdown(). |
|
Used for testing purposes and will be removed in the near future.
|
|
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.
|
|
Updates the parents of the given Category, to fit it properly into 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. |
|
Initial size of dictionary, a suitably large prime number. "Suitably large" means >= the maximum expected number of items in the dictionary. |
|
Pointer-based dictionary of categories (the hierachy dict).
|
|
Pointer to the RootCategory object, also a singleton.
|
|
Pointer to "the" instance of this class. Used to make this a singleton class, i.e., can only be instantiated once. |