gSAFE  1.3.8
Signals | Public Member Functions | List of all members
HFactory Class Reference

#include <hfactory.h>

Inherits QObject, and QXmlDefaultHandler.

Signals

void errorSignal (QString err)
 

Public Member Functions

 HFactory (QString rdata="")
 
 ~HFactory (void)
 
void appendTemplateData (QString rdata)
 
bool characters (const QString &ch)
 
void clearTemplateData (void)
 
bool endDocument (void)
 
bool endElement (const QString &ns, const QString &ln, const QString &name)
 
bool error (const QXmlParseException &exception)
 
QString errorString (void)
 
bool fatalError (const QXmlParseException &exception)
 
HListgenHList (QString part, QString inRole="")
 
HTablegenHTable (QString part, QString inRole="")
 
HTableBasegenTable (QString part, int mode=TABLE)
 
int readFromFile (QFile *f)
 
int readFromFile (QString fn)
 
QString sqlCreateString (QString part)
 
bool startDocument (void)
 
bool startElement (const QString &ns, const QString &ln, const QString &name, const QXmlAttributes &atts)
 
bool warning (const QXmlParseException &exception)
 

Detailed Description

HFactory is a meta-data/meta-object generator class.
The gSAFE works with meta-data object which are in datalib. This base meta data objects are HTableBase and the two descendats HTable and HList.
You can build these meta-data objects by api functions, or you can use the HFactory to build this object from an XML data. In the XML data yu can describe almost all information about the meta-data groups, so the HFactory can build the necessary data objects from it.

The format of the XML data is described here: http://hyperprog.com/gsafe/doc/TEMPLATEDOC.txt
You can find the XML Schema (XSD) file here: http://hyperprog.com/gsafe/doc/gsafemetadata.xsd

hfactory.png

You can define this meta data objects, with api functions of HTableBase like this:

...
HTable *table = new HTable("excerc");
table->addField(new HKey("id","Identifier","Id",""));
table->addField(new HLargeText("excer","Task to do","Task","")->asColored(200,100,100));
table->addField(new HCheck("finished","Finished","Finished","",
"false","Yes, It is done!","No, it is unfinished."));
table->addField(new HNumber("price","Cost","Cost","usd",""));
table->addField(new HDate("deadline","Deadline","Deadline","NOW",false,false));
...

You can use HFactory to generate this meta data object from XML file. The XML definition which describe the code above look like this:

<templates>
...
<element name="excercises">
<table sqln="excerc">
<extrafeatures/>
<tabletitle>Tasks</tabletitle>
<key sqln="id">
<ex>Identifier</ex>
<ti>Id</ti>
</key>
<largetext sqln="excer">
<color r="200" g="100" b="100" />
<ex>Task to do</ex>
<ti>Task</ti>
</largetext>
<check sqln="finished">
<ex>Finished</ex>
<ti>Finished</ti>
<true>Yes, It is done!</true>
<false>No, it is unfinished.</false>
<de>false</de>
</check>
<number sqln="price">
<ex>Cost</ex>
<ti>Cost</ti>
<ta>usd</ta>
</number>
<date sqln="deadline">
<ex>Deadline</ex>
<ti>Deadline</ti>
<de>NOW</de>
</date>
</table>
</element>
...
<templates>

After you create a HFactory object you have to fill with the XML data. ( appendTemplateData() function) Every time when you need a meta data object you can generate it with genHTable() and genHList()

Definition at line 105 of file hfactory.h.

Constructor & Destructor Documentation

HFactory::HFactory ( QString  rdata = "")

Creates a HFactory object

Parameters
rdatayou can set an initially XML data in this parameter.

Definition at line 30 of file hfactory.cpp.

HFactory::~HFactory ( void  )

Destructor

Definition at line 46 of file hfactory.cpp.

Member Function Documentation

void HFactory::appendTemplateData ( QString  rdata)

Append XML meta data to the current. This XML will be concatenated to the end of the current data

Definition at line 111 of file hfactory.cpp.

bool HFactory::characters ( const QString &  ch)

XML parsing function. Do not use, it works automatically

Definition at line 647 of file hfactory.cpp.

void HFactory::clearTemplateData ( void  )

Clears the XML meta data

Definition at line 117 of file hfactory.cpp.

bool HFactory::endDocument ( void  )

XML parsing function. Do not use, it works automatically

Definition at line 226 of file hfactory.cpp.

bool HFactory::endElement ( const QString &  ns,
const QString &  ln,
const QString &  name 
)

XML parsing function. Do not use, it works automatically

Definition at line 701 of file hfactory.cpp.

bool HFactory::error ( const QXmlParseException &  exception)

XML parsing function. Do not use, it works automatically

Definition at line 140 of file hfactory.cpp.

QString HFactory::errorString ( void  )

XML parsing function. Do not use, it works automatically

Definition at line 122 of file hfactory.cpp.

bool HFactory::fatalError ( const QXmlParseException &  exception)

XML parsing function. Do not use, it works automatically

Definition at line 153 of file hfactory.cpp.

HList * HFactory::genHList ( QString  part,
QString  inRole = "" 
)

Generate a HList meta-data object according to the current XML meta data. If you specify the second "role" parameter the list returned in the specified role.

Parameters
partthe name of the XML meta data element which will descibe of the generated meta-data.
rolethe (optional) role which the list returned.

Definition at line 73 of file hfactory.cpp.

HTable * HFactory::genHTable ( QString  part,
QString  inRole = "" 
)

Generate a HTable meta-data object according to the current XML meta data. If you specify the second "role" parameter the table returned in the specified role.

Parameters
partthe name of the XML meta data element which will descibe of the generated meta-data.
rolethe (optional) role which the table returned.

Definition at line 64 of file hfactory.cpp.

HTableBase * HFactory::genTable ( QString  part,
int  mode = TABLE 
)

Generate a HTableBase meta-data object according to the current XML meta data.

Parameters
partthe name of the XML meta data element which will describe of the generated meta-data.
modeCan be TABLE or LIST. The function generate HTable or HList

Definition at line 166 of file hfactory.cpp.

int HFactory::readFromFile ( QFile *  f)

Reads the XML meta data from a file.

Parameters
fthe file to read
Returns
0 if success, 0!= if error occured.

Definition at line 94 of file hfactory.cpp.

int HFactory::readFromFile ( QString  fn)

Reads the XML meta data from a file. Because the name is passed to QFile the name can be a valid file or a qt resource name too.

Parameters
fthe file or resource to read
Returns
0 if success, 0!= if error occured.

Definition at line 105 of file hfactory.cpp.

QString HFactory::sqlCreateString ( QString  part)

Returns the sql create string of the part.

See Also
HTableBase::sqlCreateString()

Definition at line 82 of file hfactory.cpp.

bool HFactory::startDocument ( void  )

XML parsing function. Do not use, it works automatically

Definition at line 220 of file hfactory.cpp.

bool HFactory::startElement ( const QString &  ns,
const QString &  ln,
const QString &  name,
const QXmlAttributes &  atts 
)

XML parsing function. Do not use, it works automatically

Definition at line 232 of file hfactory.cpp.

bool HFactory::warning ( const QXmlParseException &  exception)

XML parsing function. Do not use, it works automatically

Definition at line 127 of file hfactory.cpp.


The documentation for this class was generated from the following files: