Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

CClassFactory Class Reference

Class Factorys using XML. More...

#include <ClassFactory.h>

List of all members.

Public Methods

 CClassFactory ()
 Default constructor. More...

virtual ~CClassFactory ()
 Default destructor. More...

void clearClasDef ()
 Clear current classes definitions. More...

void clearCurContext ()
 Clear current context. More...

bool addClass (const char *className, const char *extends)
 add a new Class Definitions to the class Factory. More...

TiXmlNode * findClass (const char *className)
 find a particular class in the clasess Definitions of the class Factory. More...

bool deleteClass (const char *className)
 delete a particular class in the clasess Definitions. More...

bool addAttribute (const char *className, const char *attributeName)
 add a new Attribute to a giving class. More...

bool deleteAttribute (const char *className, const char *attributeName)
 delete an Attribute from a giving class. More...

bool newInstance (const char *className, const char *instanceName)
 Make a new object instace of a giving class name. More...

TiXmlNode * findInstance (const char *instanceName)
 find an object instace of a giving class name. More...

bool deleteInstace (const char *instanceName)
 delete an object instace of a giving instance name. More...

bool setValue (const char *instanceName, const char *attributeName, const char *value)
 Set the value of an attribute in a giving object instance. More...

CString getValue (const char *instanceName, const char *attributeName)
 Get the value of an attribute in a giving object instance. More...

bool loadClassDef (const char *filename)
 Load classes definitions from a XML / Text file. More...

bool saveClassDef (const char *filename)
 Save classes definitions from a XML / Text file. More...

bool loadContext (const char *filename)
 Load object instances context from a XML / Text file. More...

bool saveContext (const char *filename)
 Save object instances context from a XML / Text file. More...

TiXmlDocument * getClassDef ()
 Get the full classes definitions as an xml dom document. More...

TiXmlDocument * getCurContext ()
 Get the full objects instances as an xml dom document. More...


Private Methods

bool addAttributesToInstance (TiXmlElement *element, TiXmlNode *classNode)
 Add the attributes of a class to a instance (INTERNAL USE). More...

void error (char message[],...)
 Display an Error Message. More...


Private Attributes

TiXmlDocument classesDefinitions
 XML Document with classes definitions. More...

TiXmlDocument currentContext
 XML Document with objects instances. More...


Detailed Description

Class Factorys using XML.

This class its a implementation of something like class factory.

Definition at line 107 of file ClassFactory.h.


Constructor & Destructor Documentation

CClassFactory::CClassFactory  
 

Default constructor.

Default constructor

Definition at line 8 of file ClassFactory.cpp.

CClassFactory::~CClassFactory   [virtual]
 

Default destructor.

Default destructor

Definition at line 13 of file ClassFactory.cpp.

References clearClasDef(), and clearCurContext().


Member Function Documentation

bool CClassFactory::addAttribute const char *    className,
const char *    attributeName
 

add a new Attribute to a giving class.

You should call this method to add a new attribute to a giving class.

Parameters:
className  = class name that holds the attribute
attributeName  = attribute name for the new attribute
Returns:
true if the operations was valid
See also:
deleteAttribute

Definition at line 377 of file ClassFactory.cpp.

References error(), and findClass().

bool CClassFactory::addAttributesToInstance TiXmlElement *    element,
TiXmlNode *    classNode
[private]
 

Add the attributes of a class to a instance (INTERNAL USE).

This function add the attributes of desired class to a giving instance, this method work in recursive way to add all the attribute of uppers classes to the instance.

Parameters:
element  = TiXmlElement pointer represents the Instance
classNode  = TiXmlElement pointer represents the class definition
Returns:
true if operation it's valid

Definition at line 278 of file ClassFactory.cpp.

References error(), and findClass().

Referenced by newInstance().

bool CClassFactory::addClass const char *    className,
const char *    extends
 

add a new Class Definitions to the class Factory.

You should call this method to add new Class Definition to the Class Factory.

Parameters:
className  = class name for the new class definition
extends  = parent class, NULL if we dont set it
Returns:
true if the operations was valid
See also:
deleteClass , findClass

Definition at line 324 of file ClassFactory.cpp.

References classesDefinitions, error(), and findClass().

void CClassFactory::clearClasDef  
 

Clear current classes definitions.

Clear current classes definitions

Definition at line 20 of file ClassFactory.cpp.

References classesDefinitions.

Referenced by ~CClassFactory().

void CClassFactory::clearCurContext  
 

Clear current context.

Clear current context

Definition at line 27 of file ClassFactory.cpp.

References currentContext.

Referenced by ~CClassFactory().

bool CClassFactory::deleteAttribute const char *    className,
const char *    attributeName
 

delete an Attribute from a giving class.

You should call this method to delete an attribute from a giving class.

Parameters:
className  = class name that holds the attribute
attributeName  = attribute name for delete
Returns:
true if the operations was valid
See also:
addAttribute

Definition at line 448 of file ClassFactory.cpp.

References error(), and findClass().

bool CClassFactory::deleteClass const char *    className
 

delete a particular class in the clasess Definitions.

You should call this method to delete a class definition giving a class name.

Parameters:
className  = class name that you want to delete
Returns:
true if the operations was valid
See also:
addClass , findClass

Definition at line 431 of file ClassFactory.cpp.

References classesDefinitions, error(), and findClass().

bool CClassFactory::deleteInstace const char *    instanceName
 

delete an object instace of a giving instance name.

You should call this method to delete an object instance of a giving instace name.

Parameters:
instanceName  = instance name to be delete
Returns:
true if the operations was valid
See also:
newInstance , findInstance

Definition at line 162 of file ClassFactory.cpp.

References currentContext, error(), and findInstance().

void CClassFactory::error char    message[],
...   
[private]
 

Display an Error Message.

Nasty function to display errors

Parameters:
errorString  = String with the error

Definition at line 495 of file ClassFactory.cpp.

Referenced by addAttribute(), addAttributesToInstance(), addClass(), deleteAttribute(), deleteClass(), deleteInstace(), getValue(), loadClassDef(), loadContext(), newInstance(), saveClassDef(), saveContext(), and setValue().

TiXmlNode * CClassFactory::findClass const char *    className
 

find a particular class in the clasess Definitions of the class Factory.

You should call this method to find a class definition giving a class name.

Parameters:
className  = class name that you searching for
Returns:
an TiXmlNode pointer represents the class, NULL if we couldn't find it
See also:
addClass , deleteClass

Definition at line 128 of file ClassFactory.cpp.

References classesDefinitions.

Referenced by addAttribute(), addAttributesToInstance(), addClass(), deleteAttribute(), deleteClass(), and newInstance().

TiXmlNode * CClassFactory::findInstance const char *    instanceName
 

find an object instace of a giving class name.

You should call this method to find an object instance of a giving instace name.

Parameters:
instanceName  = instance name to be find
Returns:
an TiXmlNode pointer represents the instance, NULL if we couldn't find it
See also:
deleteInstace , newInstance

Definition at line 179 of file ClassFactory.cpp.

References currentContext.

Referenced by deleteInstace(), getValue(), and setValue().

TiXmlDocument* CClassFactory::getClassDef   [inline]
 

Get the full classes definitions as an xml dom document.

You should call this method to get the classes definitions in a TiXmlDocument.

Returns:
an TiXmlDocument pointer to the classes definitions
See also:
getCurContext

Definition at line 344 of file ClassFactory.h.

References classesDefinitions.

TiXmlDocument* CClassFactory::getCurContext   [inline]
 

Get the full objects instances as an xml dom document.

You should call this method to get the objects instances in a TiXmlDocument.

Returns:
an TiXmlDocument pointer to the objects instances
See also:
getClassDef

Definition at line 356 of file ClassFactory.h.

References currentContext.

CString CClassFactory::getValue const char *    instanceName,
const char *    attributeName
 

Get the value of an attribute in a giving object instance.

You should call this method to get the value of an attribute in a givging object instace

Parameters:
instanceName  = instance name of the object instance
attributeName  = attribute name in the object instance
Returns:
the value of the attribute, "" if isn't have any
See also:
setValue

Definition at line 251 of file ClassFactory.cpp.

References error(), and findInstance().

bool CClassFactory::loadClassDef const char *    filename
 

Load classes definitions from a XML / Text file.

You should call this method to load the full classes definitions from a XML FILE

Parameters:
filename  = file to load
Returns:
true if operation it's valid
See also:
saveClassDef

Definition at line 60 of file ClassFactory.cpp.

References classesDefinitions, and error().

bool CClassFactory::loadContext const char *    filename
 

Load object instances context from a XML / Text file.

You should call this method to load the full object instances context from a XML FILE

Parameters:
filename  = file to load
Returns:
true if operation it's valid
See also:
saveContext

Definition at line 33 of file ClassFactory.cpp.

References currentContext, and error().

bool CClassFactory::newInstance const char *    className,
const char *    instanceName
 

Make a new object instace of a giving class name.

You should call this method to add a new object instance of a giving name. This method olso creates the values of the atributes of this class, and uppers classes following the hirearchy..

Parameters:
className  = class name that we want to instance it
instanceName  = instance name for the new instance
Returns:
true if the operations was valid
See also:
deleteInstace , findInstance

Definition at line 86 of file ClassFactory.cpp.

References addAttributesToInstance(), currentContext, error(), and findClass().

bool CClassFactory::saveClassDef const char *    filename
 

Save classes definitions from a XML / Text file.

You should call this method to save the full classes definitions to a XML FILE

Parameters:
filename  = file to save
Returns:
true if operation it's valid
See also:
loadClassDef

Definition at line 73 of file ClassFactory.cpp.

References classesDefinitions, and error().

bool CClassFactory::saveContext const char *    filename
 

Save object instances context from a XML / Text file.

You should call this method to save the full object instances context to a XML FILE

Parameters:
filename  = file to save
Returns:
true if operation it's valid
See also:
loadContext

Definition at line 47 of file ClassFactory.cpp.

References currentContext, and error().

bool CClassFactory::setValue const char *    instanceName,
const char *    attributeName,
const char *    value
 

Set the value of an attribute in a giving object instance.

You should call this method to set the value of an attribute in a givging object instace

Parameters:
instanceName  = instance name of the object instance
attributeName  = attribute name in the object instance
value  = value to set
Returns:
true if the operations was valid
See also:
getValue

Definition at line 213 of file ClassFactory.cpp.

References error(), and findInstance().


Member Data Documentation

TiXmlDocument CClassFactory::classesDefinitions [private]
 

XML Document with classes definitions.

XML Document with classes definitions

Definition at line 367 of file ClassFactory.h.

Referenced by addClass(), clearClasDef(), deleteClass(), findClass(), getClassDef(), loadClassDef(), and saveClassDef().

TiXmlDocument CClassFactory::currentContext [private]
 

XML Document with objects instances.

XML Document with objects instances

Definition at line 373 of file ClassFactory.h.

Referenced by clearCurContext(), deleteInstace(), findInstance(), getCurContext(), loadContext(), newInstance(), and saveContext().


The documentation for this class was generated from the following files:
Generated on Wed Oct 2 10:33:38 2002 for XML Class Factory by doxygen1.2.15