SimComponent Class Reference#include <simComponent.h>
Inheritance diagram for SimComponent:
[legend]List of all members.
|
Public Member Functions |
| SimComponent () |
| Constructor Add this component.
|
virtual | ~SimComponent () |
| Destructor Remove this component and destroy child references.
|
bool | hasComponents () const |
| Will return true if this object contains components.
|
const SimComponent * | getOwner () const |
| The component which owns this object.
|
virtual StringTableEntry | getComponentName () |
virtual bool | addComponent (SimComponent *component) |
| Add Component to this one.
|
virtual bool | removeComponent (SimComponent *component) |
| Remove Component from this one.
|
virtual bool | clearComponents () |
| Clear Child components of this one.
|
virtual bool | onComponentAdd (SimComponent *target) |
virtual void | onComponentRemove (SimComponent *target) |
S32 | getComponentCount () |
SimComponent * | getComponent (S32 idx) |
template<class T> |
T * | getComponent () |
| getComponent by type T
|
virtual void | setEnabled (const bool enabled) |
bool | isEnabled () const |
virtual bool | getInterfaces (ComponentInterfaceList *list, const char *type=NULL, const char *name=NULL, const SimComponent *owner=NULL, bool notOwner=false) |
| getInterfaces allows the caller to enumerate the interfaces exposed by this component.
|
template<class T> |
bool | getInterfaces (ComponentInterfaceList *list, const char *type=NULL, const char *name=NULL, const SimComponent *owner=NULL, bool notOwner=false) |
ComponentInterface * | getInterface (const char *type=NULL, const char *name=NULL, const SimComponent *owner=NULL, bool notOwner=false) |
| These two methods allow for easy query of component interfaces if you know exactly what you are looking for, and don't mind being passed back the first matching result.
|
template<class T> |
T * | getInterface (const char *type=NULL, const char *name=NULL, const SimComponent *owner=NULL, bool notOwner=false) |
bool | registerCachedInterface (const char *type, const char *name, SimComponent *interfaceOwner, ComponentInterface *cinterface) |
| Add an interface to the cache.
|
void | registerUnCachedInterface (const char *type, const char *name, SimComponent *interfaceOwner, ComponentInterface *cinterface) |
| Inform component hierarchy of the existence of a new, uncached interface.
|
Static Public Member Functions |
static bool | setEnabled (void *obj, const char *data) |
Public Attributes |
bool | mEnabled |
Protected Types |
typedef VectorPtr< SimComponent
* >::iterator | SimComponentIterator |
Protected Member Functions |
void | _registerInterfaces (SimComponent *owner) |
| This is called internally to instruct the component to iterate over it's list of components and recursively call _registerInterfaces on their lists of components.
|
bool | _registerComponents (SimComponent *owner) |
bool | _postRegisterComponents () |
void | _unregisterComponents () |
SimComponent * | _getOwner () |
VectorPtr< SimComponent * > & | getComponentList () |
| Returns a reference to private mComponentList.
|
virtual bool | onComponentRegister (SimComponent *owner) |
| onComponentRegister is called on each component by it's owner.
|
virtual bool | onComponentPostRegister () |
| onComponentPostRegister occurs after onComponentRegister, and the purpose of the method is to allow for initialization which occurs after components are registered.
|
virtual void | onComponentUnRegister () |
| onUnregister is called when the owner is unregistering.
|
virtual void | registerInterfaces (SimComponent *owner) |
| registerInterfaces is called on each component as it's owner is registering it's interfaces.
|
Protected Attributes |
ComponentInterfaceCache | mInterfaceCache |
| Stores the interfaces exposed by this component.
|
Private Attributes |
VectorPtr< SimComponent * > | mComponentList |
| The Component List.
|
SimComponent * | mOwner |
| The component which owns this one.
|
Member Typedef Documentation
Constructor & Destructor Documentation
SimComponent::SimComponent |
( |
|
) |
|
Constructor Add this component.
virtual SimComponent::~SimComponent |
( |
|
) |
[virtual] |
Destructor Remove this component and destroy child references.
Member Function Documentation
This is called internally to instruct the component to iterate over it's list of components and recursively call _registerInterfaces on their lists of components.
bool SimComponent::_postRegisterComponents |
( |
|
) |
[protected] |
void SimComponent::_unregisterComponents |
( |
|
) |
[protected] |
SimComponent* SimComponent::_getOwner |
( |
|
) |
[inline, protected] |
Returns a reference to private mComponentList.
virtual bool SimComponent::onComponentRegister |
( |
SimComponent * |
owner |
) |
[inline, protected, virtual] |
onComponentRegister is called on each component by it's owner.
If a component has no owner, onComponentRegister will not be called on it. The purpose of onComponentRegister is to allow a component to check for any external interfaces, or other dependencies which it needs to function. If any component in a component hierarchy returns false from it's onComponentRegister call the entire hierarchy is invalid, and SimObject::onAdd will fail on the top-level component. To put it another way, if a component contains other components, it will be registered successfully with Sim iff each subcomponent returns true from onComponentRegister. If a component does not contain other components, it will not receive an onComponentRegister call.
When onComponentRegister is called on a component, it can be assumed that all *interfaces* are registered, but not that all components are registered. To perform initialization operations, please use onComponentPostRegister. - See also:
- onComponentPostRegister
Overloads of this method must pass the call along to their parent, as is shown in the example below.
Reimplemented in T3DSceneClient, and T3DSceneComponent.
virtual bool SimComponent::onComponentPostRegister |
( |
|
) |
[inline, protected, virtual] |
onComponentPostRegister occurs after onComponentRegister, and the purpose of the method is to allow for initialization which occurs after components are registered.
This is different than onComponentRegister, which occurs after all interfaces are registered.
Overloads of this method must pass the call along to their parent in the same manner as onComponentRegister.
- See also:
- onComponentRegister
virtual void SimComponent::onComponentUnRegister |
( |
|
) |
[inline, protected, virtual] |
onUnregister is called when the owner is unregistering.
Your object should do cleanup here, as well as pass a call up the chain to the parent.
Reimplemented in T3DSceneComponent.
virtual void SimComponent::registerInterfaces |
( |
SimComponent * |
owner |
) |
[inline, protected, virtual] |
registerInterfaces is called on each component as it's owner is registering it's interfaces.
This is called before onComponentRegister, and should be used to register all interfaces exposed by your component, as well as all callbacks needed by your component.
Reimplemented in T3DSceneClient, and T3DSceneComponent.
bool SimComponent::hasComponents |
( |
|
) |
const [inline] |
Will return true if this object contains components.
const SimComponent* SimComponent::getOwner |
( |
|
) |
const [inline] |
The component which owns this object.
virtual bool SimComponent::removeComponent |
( |
SimComponent * |
component |
) |
[virtual] |
Remove Component from this one.
virtual bool SimComponent::clearComponents |
( |
|
) |
[inline, virtual] |
Clear Child components of this one.
virtual bool SimComponent::onComponentAdd |
( |
SimComponent * |
target |
) |
[inline, virtual] |
virtual void SimComponent::onComponentRemove |
( |
SimComponent * |
target |
) |
[inline, virtual] |
S32 SimComponent::getComponentCount |
( |
|
) |
[inline] |
template<class T>
T * SimComponent::getComponent |
( |
|
) |
|
static bool SimComponent::setEnabled |
( |
void * |
obj, |
|
|
const char * |
data | |
|
) |
| | [inline, static] |
virtual void SimComponent::setEnabled |
( |
const bool |
enabled |
) |
[inline, virtual] |
bool SimComponent::isEnabled |
( |
|
) |
const [inline] |
getInterfaces allows the caller to enumerate the interfaces exposed by this component.
This method can be overwritten to expose interfaces which are not cached on the object, before passing the call to the Parent. This can be used delay interface creation until it is queried for, instead of creating it on initialization, and caching it. Returns false if no results were found
- Parameters:
-
| list | The list that this method will append search results on to. |
| type | An expression which the 'type' field on an added object must match to be included in results |
| name | An expression which the 'name' field on an added object must match to be included in results |
| owner | Limit results to components owned/not-owned by this SimComponent (see next param) |
| notOwner | If set to true, this will enumerate only interfaces NOT owned by 'owner' |
T * SimComponent::getInterface |
( |
const char * |
type = NULL , |
|
|
const char * |
name = NULL , |
|
|
const SimComponent * |
owner = NULL , |
|
|
bool |
notOwner = false | |
|
) |
| | |
These two methods allow for easy query of component interfaces if you know exactly what you are looking for, and don't mind being passed back the first matching result.
template<class T>
T* SimComponent::getInterface |
( |
const char * |
type = NULL , |
|
|
const char * |
name = NULL , |
|
|
const SimComponent * |
owner = NULL , |
|
|
bool |
notOwner = false | |
|
) |
| | |
Add an interface to the cache.
This function will return true if the interface is added successfully. An interface will not be added successfully if an entry in this components cache with the same values for 'type' and 'name' is present.
- Parameters:
-
| type | Type of the interface being added. If NULL is passed, it will match any type string queried. |
| name | Name of interface being added. If NULL is passed, it will match any name string queried. |
| interfaceOwner | The component which owns the interface being cached |
| cinterface | The ComponentInterface being cached |
Inform component hierarchy of the existence of a new, uncached interface.
Member Data Documentation
The component which owns this one.
Stores the interfaces exposed by this component.
|