ubit
Public Types | Public Member Functions | List of all members
ubit::UClass Class Reference

Ubit class. More...

#include <uclass.hpp>

Inheritance diagram for ubit::UClass:
ubit::UDefaultAttribute::MetaClass ubit::UDefaultBlockElement::MetaClass ubit::UDefaultInlineElement::MetaClass ubit::UObject::MetaClass

Public Types

enum  ParseModes { EMPTY_ELEMENT = 1<<0, DONT_PARSE_CONTENT = 1<<1, PRESERVE_SPACES = 1<<2 }
 Parse Modes returned by UClass::getParseModes(): More...
 

Public Member Functions

 UClass (const char *name)
 
 UClass (const UStr &name)
 
const UStrgetName () const
 returns the class name.
 
unsigned int getNo () const
 returns the class #. More...
 
virtual int getParseModes () const
 returns an ORed combination of the parse modes (0 if none).
 
virtual bool isInstance (UObject &object) const
 returns true if this 'object' derives from this class.
 
virtual UObjectnewInstance () const
 creates a new instance of the corresponding class (if applicable). More...
 
virtual UStylenewStyle () const
 creates a new instance of the style of this class (if applicable). More...
 
UStyleobtainStyle () const
 returns the style prototype that is associated to this class. More...
 
UAttrListgetAttributes () const
 returns current class properties. More...
 
void setAttributes (UAttrList *alist) const
 changes the class properties. More...
 

Detailed Description

Ubit class.

All classes that derives from UObject can have an associated UClass. UClass is a metaclass that defines some useful data for the corresponding Ubit class, such as the class name, a unique ID, a static constructor, a style def, etc.

UObject (and UNode) subclasses MUST invoke the UCLASS macro in the public section of their declaration as follows:

  class UColor: public UAttr {
  public:
    UCLASS("ucolor", UColor, new UColor)
    .....
 };

The arguments of the UCLASS macro are:

The UCLASS macro redefines the getClass() and Class() methods which are, respectively, an instance ad a class method. Both methods return a metaclass that describes the C++ class.

Member Enumeration Documentation

§ ParseModes

Parse Modes returned by UClass::getParseModes():

  • closing tags can be omitted for EMPTY_ELEMENTs (eg. ) if the 'permissive' mode of the XMLParser is set.
  • the textual content of DONT_PARSE_CONTENT elements is not parsed and their comments are stored as a text element (eg. <style> <script>)
  • the XML Parser collapses white spaces (and tabs and new lines) if the 'collapse_spaces' mode is on except for PRESERVE_SPACES elements (eg. the
     element) 
    

Member Function Documentation

§ getAttributes()

UAttrList* ubit::UClass::getAttributes ( ) const
inline

returns current class properties.

WARNING: the returned properties must NOT be deleted.

§ getNo()

unsigned int ubit::UClass::getNo ( ) const
inline

returns the class #.

the class No depends in which order classes are created (the first created class has No 1 and so on)

§ newInstance()

virtual UObject* ubit::UClass::newInstance ( ) const
inlinevirtual

creates a new instance of the corresponding class (if applicable).

Ubit classes that derive from UObject should have an associated UClass that redefines this method.

Reimplemented in ubit::UObject::MetaClass, ubit::UDefaultBlockElement::MetaClass, ubit::UDefaultInlineElement::MetaClass, and ubit::UDefaultAttribute::MetaClass.

§ newStyle()

virtual UStyle* ubit::UClass::newStyle ( ) const
inlinevirtual

creates a new instance of the style of this class (if applicable).

Ubit classes that derive from UElem should have an associated UClass that redefines this method.

Reimplemented in ubit::UObject::MetaClass, ubit::UDefaultBlockElement::MetaClass, and ubit::UDefaultInlineElement::MetaClass.

§ obtainStyle()

UStyle* ubit::UClass::obtainStyle ( ) const
inline

returns the style prototype that is associated to this class.

Ubit classes that derive from UElem can have a style prototype. This function calls newStyle() the 1st type it is called to create the style prototype WARNING: the returned style must NOT be deleted.

§ setAttributes()

void ubit::UClass::setAttributes ( UAttrList alist) const
inline

changes the class properties.

WARNING: the properties given as argument are not copied and will be destroyed by the Class destr. They must NOT be deleted by another function


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