18 #define _uobject_hpp_ 1 21 #include <ubit/udefs.hpp> 22 #include <ubit/uclass.hpp> 27 class UError :
public std::exception {
30 FATAL_ERROR = -1, WARNING, ERROR, INTERNAL_ERROR, STYLE_ERROR, CSS_ERROR, XML_ERROR
34 virtual ~
UError()
throw ();
36 virtual const char* what()
const throw();
38 static const int message_capacity = 2000;
41 const char* function_name;
42 char message[message_capacity];
45 void uerror(
const char* function_name,
const char* format, ...);
54 void uwarning(
const char* function_name,
const char* format, ...);
118 virtual bool isInstance(
UObject* obj)
const {
return dynamic_cast<UObject*
>(obj);}
128 static const char* getVersion();
143 const UStr& getClassName()
const;
146 static UStyle* createStyle() {
return null;}
150 virtual void error(
const char* function_name,
const char* format, ...)
const;
159 virtual void warning(
const char* function_name,
const char* format, ...)
const;
170 bool isConst()
const {
return omodes.IS_CONST;}
188 UObject& setAutoUpdate(
bool state =
true);
197 UObject& ignoreChangeCallbacks(
bool state);
258 typedef unsigned char State;
259 typedef short PtrCount;
272 unsigned IS_DYNAMIC:1;
274 unsigned IS_DESTRUCTED:1;
275 unsigned IS_DESTRUCTING:1;
276 unsigned DONT_AUTO_UPDATE:1;
277 unsigned IS_UPDATING:1;
278 unsigned IS_IN_SELECTION:1;
279 unsigned IGNORE_CHANGE_CALLBACKS:1;
290 bool checkConst()
const;
299 virtual bool hasSceneGraphParent()
const {
return false;};
302 void*
operator new(size_t);
305 void operator delete(
void*);
309 void removePtr()
const;
318 mutable PtrCount ptr_count;
359 void deferenceError()
const;
367 void addPtr(
const CC* o) {
if (o) o->addPtr();}
368 void removePtr(
const CC* o) {
if (o) o->removePtr();}
371 uptr(CC& _obj) {obj = &_obj; addPtr(obj);}
372 uptr(CC* _obj) {obj = _obj; addPtr(obj);}
382 removePtr(obj); obj = &_obj; addPtr(obj);
return *
this;
385 removePtr(obj); obj = _obj; addPtr(obj);
return *
this;
390 removePtr(obj); obj = p2.obj; addPtr(obj);
return *
this;
394 operator CC*()
const {
return obj;}
404 if (!obj) deferenceError();
410 if (!obj) deferenceError();
Base class for attributes.
Definition: uattr.hpp:97
bool isDestructing() const
[impl] this object is being destructed (one of its destructors has been called).
Definition: uobject.hpp:296
uptr< CC > & operator=(CC *_obj)
assignment: ptr = obj; (obj can be null).
Definition: uobject.hpp:384
text selection.
Definition: uselection.hpp:25
virtual UData * toData()
dynamic cast: returns this object if it derives from UData and null otherwise.
Definition: uobject.hpp:220
Definition: uobject.hpp:282
Box container.
Definition: ubox.hpp:64
virtual const UAttr * toAttr() const
dynamic cast: returns this object if it derives from UAttr and null otherwise.
Definition: uobject.hpp:211
CC & operator*() const
dereferencing: if 'ptr' points to 'obj' then *ptr return *obj.
Definition: uobject.hpp:403
Definition: uappliImpl.hpp:40
Base class of objects that can be added to the UBIT scene graph (SEE DETAILS!).
Definition: unode.hpp:38
virtual UMenu * toMenu()
dynamic cast: returns this object if it derives from UMenu and null otherwise.
Definition: uobject.hpp:250
virtual const UCall * toCall() const
dynamic cast: returns this object if it derives from UCall and null otherwise.
Definition: uobject.hpp:235
CC * operator->() const
dereferencing: if 'ptr' points to 'obj' then ptr->foo() calls obj->foo().
Definition: uobject.hpp:409
[Impl] internal object modes.
Definition: uobject.hpp:271
virtual UStr * toStr()
dynamic cast: returns this object if it derives from UStr and null otherwise.
Definition: uobject.hpp:226
uptr(CC *_obj)
constructors: uptr<ObjClass> ptr = obj;
Definition: uobject.hpp:372
virtual const UElem * toElem() const
dynamic cast: returns this object if it derives from UElem and null otherwise.
Definition: uobject.hpp:217
virtual UBox * toBox()
dynamic cast: returns this object if it derives from UBox and null otherwise.
Definition: uobject.hpp:238
static const UClass & Class()
class method that returns the metaclass of this class.
Definition: uobject.hpp:131
virtual const UData * toData() const
dynamic cast: returns this object if it derives from UData and null otherwise.
Definition: uobject.hpp:223
virtual UNode * toNode()
dynamic cast: returns this object if it derives from UNode and null otherwise.
Definition: uobject.hpp:202
Base class for Viewable Objects.
Definition: udata.hpp:31
CC * operator()() const
returns pointed object: if 'ptr' points to 'obj' then ptr() returns obj.
Definition: uobject.hpp:400
bool isDestructed() const
[impl] this object has been destructed (but memory has not been freed yet).
Definition: uobject.hpp:293
uptr< CC > & operator=(const uptr< CC > &p2)
assignment: ptr = ptr2;
Definition: uobject.hpp:389
virtual const UWin * toWin() const
dynamic cast: returns this object if it derives from UWin and null otherwise.
Definition: uobject.hpp:247
lightweight general purpose container.
Definition: uelem.hpp:44
virtual UWin * toWin()
dynamic cast: returns this object if it derives from UWin and null otherwise.
Definition: uobject.hpp:244
virtual const UStr * toStr() const
dynamic cast: returns this object if it derives from UStr and null otherwise.
Definition: uobject.hpp:229
Smart Pointer for UObject instances (.
Definition: uobject.hpp:365
base class of callback objects for firing functions or methods.
Definition: ucall.hpp:144
virtual UAttr * toAttr()
dynamic cast: returns this object if it derives from UAttr and null otherwise.
Definition: uobject.hpp:208
bool isConst() const
checks whether the content of this object can be modified (
Definition: uobject.hpp:170
static UConst UCONST
UCONST can be given as an argument to some constructors to make the object constant.
Definition: uobject.hpp:284
Ubit class.
Definition: uclass.hpp:74
~uptr()
destructor: deletes pointed object (if not null and not pointed elsewhere).
Definition: uobject.hpp:378
bool isAutoUpdate() const
return current update policy:
Definition: uobject.hpp:185
Ubit exception.
Definition: uobject.hpp:27
Definition: uupdatecontext.hpp:32
virtual UElem * toElem()
dynamic cast: returns this object if it derives from UElem and null otherwise.
Definition: uobject.hpp:214
uptr(const uptr< CC > &p2)
constructor: uptr<ObjClass> ptr = p2;
Definition: uobject.hpp:375
Definition: uhardfont.hpp:31
virtual const UNode * toNode() const
dynamic cast: returns this object if it derives from UNode and null otherwise.
Definition: uobject.hpp:205
virtual const UMenu * toMenu() const
dynamic cast: returns this object if it derives from UMenu and null otherwise.
Definition: uobject.hpp:253
virtual const UClass & getClass() const
instance method that returns the metaclass of this object.
Definition: uobject.hpp:134
Definition: tstclass.hpp:5
bool isIgnoringChangeCallbacks() const
return true if change callbacks are fired.
Definition: uobject.hpp:194
Base class for windows and menus.
Definition: uwin.hpp:47
void setState(State s)
changes the object state.
Definition: uobject.hpp:264
virtual UCall * toCall()
dynamic cast: returns this object if it derives from UCall and null otherwise.
Definition: uobject.hpp:232
virtual const UBox * toBox() const
dynamic cast: returns this object if it derives from UBox and null otherwise.
Definition: uobject.hpp:241
bool isDeletable() const
checks if this object can be destroyed by 'delete'.
Definition: uobject.hpp:164
State getState() const
returns the current object state.
Definition: uobject.hpp:261
PtrCount getPtrCount() const
[impl] returns the number of uptr<> smart pointers that are pointing to this object.
Definition: uobject.hpp:267
Compiled Object Style.
Definition: ustyle.hpp:44
Smart Pointer for UObject instances.
Definition: uobject.hpp:355
Ubit String.
Definition: ustr.hpp:72
Base class of most Ubit objects (SEE DETAILS!).
Definition: uobject.hpp:113
CC * operator &() const
returns pointed object: if 'ptr' points to 'obj' then &ptr returns obj.
Definition: uobject.hpp:397