ubit
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | Friends | List of all members
ubit::UObject Class Reference

Base class of most Ubit objects (SEE DETAILS!). More...

#include <uobject.hpp>

Inheritance diagram for ubit::UObject:
ubit::UErrorHandler ubit::UFontFamily ubit::UNode ubit::UShape ubit::UAttr ubit::UCall ubit::UCDATASection ubit::UComment ubit::UData ubit::UElem ubit::UNumber ubit::UProcessingInstruction ubit::USource ubit::UTimer ubit::UXmlDocType ubit::UEllipse ubit::ULine ubit::UPolygon ubit::URect

Classes

struct  MetaClass
 
struct  Modes
 [Impl] internal object modes. More...
 
struct  UConst
 

Public Types

typedef unsigned char State
 
typedef short PtrCount
 

Public Member Functions

 UObject (const UObject &)
 
UObjectoperator= (const UObject &)
 
virtual const UClassgetClass () const
 instance method that returns the metaclass of this object. More...
 
const UStrgetClassName () const
 returns getClass().getName().
 
virtual void error (const char *function_name, const char *format,...) const
 prints out an error message. More...
 
virtual void warning (const char *function_name, const char *format,...) const
 prints out a warning message: More...
 
bool isDeletable () const
 checks if this object can be destroyed by 'delete'. More...
 
bool isConst () const
 checks whether the content of this object can be modified ( More...
 
UObjectsetConst ()
 specifies that the content of this object cannot be modified. More...
 
bool isAutoUpdate () const
 return current update policy: More...
 
UObjectsetAutoUpdate (bool state=true)
 changes the update policy of this object when its is modified. More...
 
bool isIgnoringChangeCallbacks () const
 return true if change callbacks are fired.
 
UObjectignoreChangeCallbacks (bool state)
 change callbacks are not fired if argument is true.
 
virtual UNodetoNode ()
 dynamic cast: returns this object if it derives from UNode and null otherwise.
 
virtual const UNodetoNode () const
 dynamic cast: returns this object if it derives from UNode and null otherwise.
 
virtual UAttrtoAttr ()
 dynamic cast: returns this object if it derives from UAttr and null otherwise.
 
virtual const UAttrtoAttr () const
 dynamic cast: returns this object if it derives from UAttr and null otherwise.
 
virtual UElemtoElem ()
 dynamic cast: returns this object if it derives from UElem and null otherwise.
 
virtual const UElemtoElem () const
 dynamic cast: returns this object if it derives from UElem and null otherwise.
 
virtual UDatatoData ()
 dynamic cast: returns this object if it derives from UData and null otherwise.
 
virtual const UDatatoData () const
 dynamic cast: returns this object if it derives from UData and null otherwise.
 
virtual UStrtoStr ()
 dynamic cast: returns this object if it derives from UStr and null otherwise.
 
virtual const UStrtoStr () const
 dynamic cast: returns this object if it derives from UStr and null otherwise.
 
virtual UCalltoCall ()
 dynamic cast: returns this object if it derives from UCall and null otherwise.
 
virtual const UCalltoCall () const
 dynamic cast: returns this object if it derives from UCall and null otherwise.
 
virtual UBoxtoBox ()
 dynamic cast: returns this object if it derives from UBox and null otherwise.
 
virtual const UBoxtoBox () const
 dynamic cast: returns this object if it derives from UBox and null otherwise.
 
virtual UWintoWin ()
 dynamic cast: returns this object if it derives from UWin and null otherwise.
 
virtual const UWintoWin () const
 dynamic cast: returns this object if it derives from UWin and null otherwise.
 
virtual UMenutoMenu ()
 dynamic cast: returns this object if it derives from UMenu and null otherwise.
 
virtual const UMenutoMenu () const
 dynamic cast: returns this object if it derives from UMenu and null otherwise.
 
State getState () const
 returns the current object state.
 
void setState (State s)
 changes the object state.
 
PtrCount getPtrCount () const
 [impl] returns the number of uptr<> smart pointers that are pointing to this object.
 
bool checkConst () const
 [impl] produces an error if this object is logically constant ( More...
 
bool isDestructed () const
 [impl] this object has been destructed (but memory has not been freed yet).
 
bool isDestructing () const
 [impl] this object is being destructed (one of its destructors has been called).
 
virtual bool hasSceneGraphParent () const
 
void * operator new (size_t)
 < [impl] returns true if there is at least one scene graph parent (redefined by UNode). More...
 
void operator delete (void *)
 delete operator is forbidden on instances that derive from UObject.
 
void addPtr () const
 [Impl] a uptr is added to this object.
 
void removePtr () const
 [Impl] a uptr is removed from this object.
 

Static Public Member Functions

static const char * getVersion ()
 returns the version of the Ubit package.
 
static const UClassClass ()
 class method that returns the metaclass of this class. More...
 
static UStylecreateStyle ()
 

Static Public Attributes

static UConst UCONST
 UCONST can be given as an argument to some constructors to make the object constant. More...
 

Protected Attributes

PtrCount ptr_count
 
Modes omodes
 
State ostate
 

Friends

class UNode
 
class UUpdateContext
 
class UAppliImpl
 
class USelection
 
class UPtr
 

Detailed Description

Base class of most Ubit objects (SEE DETAILS!).

UObject is the base class for (almost) all Ubit objects. Its main subclasses are UNode, UAttr, UElem that play the same role as Node, Attribute and Element in a XML/DOM model and UBox and UWin that are the base classes for widgets and windows.

  1. SUBCLASSING: UObject subclasses MUST invoke the UCLASS macro in the public section of their declaration:
      class UColor: public UAttr {
      public:
        UCLASS("UColor", UColor, new UColor)
        .....
     };
    

UCLASS redefines getClass() and Class() which return a metaclass that describes the corresponding Ubit class (see UClass). getClass() is an instance method, Class() a static method.

  1. RECURSIVE DELETION: when a UObject instance is destroyed, its attributes and chidren (when applicable,
    See also
    UNode and UElem) are recursively deleted if they:

Note that:

  1. UPtr SMART POINTERS provide automatic memory management. UObject(s) are automatically deleted when nothing reference them, i.e. when the last reference from a UPtr or anoher UObject is removed (as said above, this only apply to objects created in the heap)

Example:

   class MyClass : public UObject {
       ....
   };
   uptr<MyClass> p1 = new MyClass();   // p1 points to a new MyClass object
   uptr<MyClass> p2 = p1;              // p2 points to the same object
   p1 = null;   // (null = 0) does nothing because p2 also points to the object
   p2 = null;   // destroys the object as no other uptr<> points on it
 
See also
: UPtr, UObject, UClass

Member Function Documentation

§ checkConst()

bool UObject::checkConst ( ) const

[impl] produces an error if this object is logically constant (

See also
setConst()).

§ Class()

static const UClass& ubit::UObject::Class ( )
inlinestatic

class method that returns the metaclass of this class.

See also
getClass().

§ error()

void UObject::error ( const char *  function_name,
const char *  format,
  ... 
) const
virtual

prints out an error message.

this method displays an error message (on std::cerr by default) :

  • 'function_name' = the name of the function where the error occured
  • 'format' = a printf-like format
  • '...' = a variadic list of arguments that correspond to 'format'.
    See also
    also: warning() and UAppli::error().

Reimplemented in ubit::UErrorHandler.

§ getClass()

virtual const UClass& ubit::UObject::getClass ( ) const
inlinevirtual

instance method that returns the metaclass of this object.

Class() and getClass() return a metaclass (see UClass) that describes this class. Class() is a class method, while getClass() is an instance method.

WARNING: Class() and getClass() must be redefined by ALL Ubit classes. This can be done by invoking the UCLASS macro (see UNode) in the public section

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

§ isAutoUpdate()

bool ubit::UObject::isAutoUpdate ( ) const
inline

return current update policy:

See also
setAutoUpdate().

§ isConst()

bool ubit::UObject::isConst ( ) const
inline

checks whether the content of this object can be modified (

See also
setConst()).

§ isDeletable()

bool ubit::UObject::isDeletable ( ) const
inline

checks if this object can be destroyed by 'delete'.

objects that were allocated in the heap or in static memory, or that are plain fields of other objects cannot be destroyed by using 'delete'.

§ operator new()

void * UObject::operator new ( size_t  sz)

< [impl] returns true if there is at least one scene graph parent (redefined by UNode).

[impl] internal memory management.

§ setAutoUpdate()

UObject & UObject::setAutoUpdate ( bool  state = true)

changes the update policy of this object when its is modified.

if 'state' is true, the object if automatically updated when modified

See also
UNode::setAutoUpdate() for more details.

§ setConst()

UObject & UObject::setConst ( )

specifies that the content of this object cannot be modified.

an attempt to modify the content of this object will then produce an error. Notes:

  • constness can't be changed once set.
  • this feature makes it possible to specify that an object is constant even if it is not declared 'const'. This makes it possible to have constant and non constant objects included in the same container. Constness is thus checked at run time instead of compilation time.
    See also
    also: UCONST.

§ warning()

void UObject::warning ( const char *  function_name,
const char *  format,
  ... 
) const
virtual

prints out a warning message:

See also
error().

Reimplemented in ubit::UErrorHandler.

Member Data Documentation

§ UCONST

UObject::UConst UObject::UCONST
static

UCONST can be given as an argument to some constructors to make the object constant.

an attempt to modify the value of this object will produce an error. Note that constness can't be changed once set.

See also
also: setConst().

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