BasicObject Class Reference

Base class for most Netrinjo-classes. More...

#include <basicobject.h>

Inheritance diagram for BasicObject:

Inheritance graph
[legend]
Collaboration diagram for BasicObject:

Collaboration graph
[legend]
List of all members.

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)
TiXmlElementgetXmlData ()
virtual const char * getClassName ()
DECLSPEC bool matchName (const char *name)
DECLSPEC FunctionData getFunctionByName (const char *name)
DECLSPEC Callback getFuncByName (const char *name)
DECLSPEC BasicObjectgetObjectByName (const char *name)
DECLSPEC BasicObjectgetChildWithName (const char *name)
const char * getName () const
 
Returns:
the name of the object, as specified on creation.

BasicObjectgetParent () const
 
Returns:
a pointer to the parent object

unsigned int numChildren ()
 
Returns:
the number of children this object has

virtual bool isUiObject () const
 
Returns:
whether this is derived from UiObject

virtual bool isNetSocket () const
 
Returns:
whether this is derived from NetSocket.

void init ()
 Initilises the object by calling onInit().
void destroy ()

Static Public Member Functions

static BasicObjectgetObject (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

TiXmlElementxmlData
child_list children
child_iter parentitem

Friends

class UiManager
class UiObject

Classes

struct  FunctionData

Detailed Description

Base class for most Netrinjo-classes.

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).


Constructor & Destructor Documentation

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.

Parameters:
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).

Parameters:
el the XML data
p the parent element, or NULL to take GuiManager::the as parent


Member Function Documentation

TiXmlElement* BasicObject::getXmlData (  )  [inline]

Returns:
the XML data, used for initializing this object. If the object was created without specifying an TiXmlElement, NULL is returned.

virtual const char* BasicObject::getClassName (  )  [inline, virtual]

This function should be overriden in every sub-class of BasicObject!

Returns:
the name of the class.

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 '')

Parameters:
name the name to check for equivalence
Returns:
true, if equal, otherwise false

BasicObject::FunctionData BasicObject::getFunctionByName ( const char *  name  ) 

Parameters:
name the function's name to look for (i.e. "GuiManager.myobject#funcname")
Returns:
a pointer to the function and to the corresponding object, or NULLs, if there is none (if the object was found, but not the function, only func is set NULL)

BasicObject::Callback BasicObject::getFuncByName ( const char *  name  ) 

Parameters:
name the function's name to look for
Returns:
the function pointer of the event with the matching name, or NULL if there is none

BasicObject * BasicObject::getObjectByName ( const char *  name  ) 

Parameters:
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())
Returns:
a pointer to the object with the matching name, or NULL if there is none

BasicObject * BasicObject::getChildWithName ( const char *  name  ) 

Parameters:
name the name (no path!) of the child-object (only 1st generation); characters after a '.' or a '#' are ignored
Returns:
the child object with the specified name; NULL if there is none

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.


Member Data Documentation

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.


The documentation for this class was generated from the following files:
Generated on Wed May 9 17:36:11 2007 for netrinjo by  doxygen 1.5.1