#include <basicobject.h>
Inheritance diagram for BasicObject:
Public Types | |
typedef BasicSlot::Callback | Callback |
Definition for callback functions. | |
Public Member Functions | |
DECLSPEC | BasicObject (const char *name, BasicObject *parent) |
DECLSPEC | BasicObject (TiXmlElement *el, BasicObject *p) |
TiXmlElement * | getXmlData () |
virtual const char * | getClassName () |
DECLSPEC bool | matchName (const char *name) |
DECLSPEC FunctionData | getFunctionByName (const char *name) |
DECLSPEC Callback | getFuncByName (const char *name) |
DECLSPEC BasicObject * | getObjectByName (const char *name) |
DECLSPEC BasicObject * | getChildWithName (const char *name) |
const char * | getName () const |
| |
BasicObject * | getParent () const |
| |
unsigned int | numChildren () |
| |
virtual bool | isUiObject () const |
| |
virtual bool | isNetSocket () const |
| |
void | init () |
Initilises the object by calling onInit(). | |
void | destroy () |
Static Public Member Functions | |
static BasicObject * | getObject (const char *name) |
static Callback | getFunc (const char *name) |
static DECLSPEC FunctionData | getFunction (const char *name) |
Protected Types | |
typedef std::list< BasicObject * > | child_list |
typedef child_list::iterator | child_iter |
typedef child_list::reverse_iterator | child_reverse_iter |
typedef std::list< BasicSlot * >::iterator | EventIter |
Protected Member Functions | |
virtual DECLSPEC void | onInit () |
virtual DECLSPEC void | onDestroy () |
Protected Attributes | |
TiXmlElement * | xmlData |
child_list | children |
child_iter | parentitem |
Friends | |
class | UiManager |
class | UiObject |
Classes | |
struct | FunctionData |
This class contains event-slots and/or other containers. Every slot can be looked up by a string, giving the path to the object and its function. The object tree is parsed similar to the directory tree in Unix: to specify an object either give the absolute or relative path, absolute looks like "my.wanted.object", relative looks like "..wanted.object" (every prefixed dot says "go to the parent object"). To get a function, simply append a sharp '#' and the function name, like "my.wanted.object#foo". To access slots of a base class of an object (e.g: ToggleVisibility (from GuiElement) of a GuiFrameCounter-object) you have to specify the class that declares the slot before the function's name - separated by a dot '.' (like: ...framecounter::GuiElement.ToggleVisibility).
Another special ability of BasicObject is the usage of XML data. When specifying a XML element on creation, the data can later be used for initialising the object. When the root's onInit() is called, all children's, grandchildren's,... onInit() are called subsequently. Each sibling's onInit() is called in the same order as the siblings were created (if the list-order was not modified after the children's creation).
BasicObject::BasicObject | ( | const char * | name, | |
BasicObject * | parent | |||
) |
Constructor. There must only be one BasicObject created without parent, and that is, if you need UI, the UiManager, for a server app you can take another object.
name | the name of this object (may be NULL, if parent is NULL); to name the object by the next unused number, name hast to be "" | |
parent | the parent object, where this event is registered |
BasicObject::BasicObject | ( | TiXmlElement * | el, | |
BasicObject * | p | |||
) |
Constructor, used to create an object from XML data. When using this method for creation, the method getXmlData() returns a valid pointer (not NULL).
el | the XML data | |
p | the parent element, or NULL to take GuiManager::the as parent |
TiXmlElement* BasicObject::getXmlData | ( | ) | [inline] |
virtual const char* BasicObject::getClassName | ( | ) | [inline, virtual] |
This function should be overriden in every sub-class of BasicObject!
Reimplemented in BasicThread, GuiBackground, GuiFrame, GuiBorder, GuiRadioContainer, GuiPictureBg, GuiFlowWindow, GuiPageControl, GuiCheck, GuiRadio, GuiNumScroller, GuiCursor, GuiDropDown, GuiDynamicButton, GuiClickableBtn, GuiCheckableBtn, GuiRadioBtn, GuiElement, GuiFader, GuiFileElement, GuiFlowMenu, GuiForm, GuiHint, GuiListBox, GuiManager, GuiMenuBar, GuiMenuItem, GuiMessageBox, GuiProgressBar, GuiRotator, GuiScroller, GuiScrollBg, GuiSurface, GuiText, GuiTextInput, GuiKeyControl, GuiFrameCounter, GuiTextField, GuiUpDown, NetSimpleManager, NetPeerManager, NetPeerSocket, NetStandardSocket, NetThread, UiManager, UiObject, and WebServer.
bool BasicObject::matchName | ( | const char * | name | ) |
Checks, whether the name of this object is equal to the first part of the specified name (first part means everything before the first '.' or '')
name | the name to check for equivalence |
BasicObject::FunctionData BasicObject::getFunctionByName | ( | const char * | name | ) |
name | the function's name to look for (i.e. "GuiManager.myobject#funcname") |
BasicObject::Callback BasicObject::getFuncByName | ( | const char * | name | ) |
name | the function's name to look for |
BasicObject * BasicObject::getObjectByName | ( | const char * | name | ) |
name | the object's name-path to look for (letters after a '#' will be ignored; if there is no dot at the beginning, the result is equal to the result of the static method getObject()) |
BasicObject * BasicObject::getChildWithName | ( | const char * | name | ) |
name | the name (no path!) of the child-object (only 1st generation); characters after a '.' or a '#' are ignored |
void BasicObject::destroy | ( | ) | [inline] |
Uninitilises the object by calling onDestroy() (memory is not freed). This should usually be called before deleting an object.
Reimplemented in BasicApp, GuiRadio, GuiDropDown, GuiListBox, NetBasicManager, WebServer, and XmlApp.
void BasicObject::onInit | ( | ) | [protected, virtual] |
Initializes the object's variables by reading data from the XML element. If there were no XML data used for creation, nothing is done. This function calls onInit() of its children recursively (after it has inited itself). It is highly recommended to call BasicObject::onInit(), usually at the end of the onInit() method, when overwriting it in a derived class.
Reimplemented in BasicApp, BasicLog, SignalMultiplier, GuiBackground, GuiFrame, GuiBorder, GuiRadioContainer, GuiPictureBg, GuiFlowWindow, GuiPageControl, GuiCheck, GuiRadio, GuiNumScroller, GuiCursor, GuiDropDown, GuiDynamicButton, GuiClickableBtn, GuiCheckableBtn, GuiRadioBtn, GuiElement, GuiFileElement, GuiFlowMenu, GuiFlowMenuItem, GuiForm, GuiHint, GuiListBox, GuiMessageBox, GuiProgressBar, GuiRotator, GuiScroller, GuiScrollBg, GuiSurface, GuiText, GuiTextInput, GuiKeyControl, GuiFrameCounter, GuiTextField, GuiUpDown, NetBasicManager, NetPeerManager, NetSocket, NetStandardSocket, NetThread, UiManager, WebServer, and XmlApp.
void BasicObject::onDestroy | ( | ) | [protected, virtual] |
May be called to reinitialise this object or stop an initialised module. Calls all children's onDestroy(). Most classes do not use this method. But sometimes it is useful to reset the functionality of an object.
Reimplemented in GuiElement, GuiManager, NetBasicManager, NetThread, UiObject, and WebServer.
TiXmlElement* BasicObject::xmlData [protected] |
The data used to create this element (NULL, if it was not created using XML) A valid pointer may be assigned later after creation as well.