TEMU  2
The Terma Emulator
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Component.h File Reference
Include dependency graph for Component.h:

Go to the source code of this file.

Macros

#define TEMU_COMPONENT_DEFINED
 

Typedefs

typedef struct temu_Component temu_Component
 

Functions

TEMU_API temu_Classtemu_registerComponent (const char *CompClass, temu_ObjectCreateFunc Create, temu_ObjectDisposeFunc Dispose)
 
TEMU_API temu_Componenttemu_componentCreate (const char *Name)
 
TEMU_API void temu_componentDispose (void *Comp)
 
TEMU_API void temu_componentAddDelegateIface (temu_Component *Comp, const char *Name, temu_IfaceRef Iface)
 
TEMU_API void temu_componentAddDelegateProp (temu_Component *Comp, const char *Name, void *Obj, const char *PropName)
 
TEMU_API temu_IfaceRef temu_componentGetDelegateIface (temu_Component *Comp, const char *Name)
 
TEMU_API temu_PropName temu_componentGetDelegateProp (temu_Component *Comp, const char *Name)
 
TEMU_API void * temu_createComponentObject (void *Comp, const char *Class, const temu_CreateArg *Args, const char *ObjNameFmt,...)
 
TEMU_API void * temu_componentGetObject (void *Comp, const char *Name)
 
TEMU_API void temu_foreachComponent (void(*Func)(temu_Component *, void *), void *Arg)
 
TEMU_API void temu_foreachRootComponent (void(*Func)(temu_Component *, void *), void *Arg)
 

Macro Definition Documentation

#define TEMU_COMPONENT_DEFINED

Definition at line 26 of file Component.h.

Typedef Documentation

Definition at line 27 of file Component.h.

Function Documentation

TEMU_API void temu_componentAddDelegateIface ( temu_Component Comp,
const char *  Name,
temu_IfaceRef  Iface 
)

Add delegate interface to component

Delegate interfaces are interfaces in objects internal in the component. It is possible to use the connect function to attach directly to a component delegated interface (although, in practice the connection is done to the internal object's interface).

Note that delegate interface do not support interface arrays, and can only expose a single interface instance at present.

Parameters
Compthe component to add the delegate interface to.
Namename of the delegate interface
IfaceInterface reference which the delegated interface is resolved to
TEMU_API void temu_componentAddDelegateProp ( temu_Component Comp,
const char *  Name,
void *  Obj,
const char *  PropName 
)

Add delegate property to component

Delegate property are properties in objects internal in the component. It is possible to use the connect function to connect from a delegated property directly using the component instead of the underlying object.

Parameters
Compthe component to add the delegate interface to.
Namename of the delegate property
ObjObject to which the property resolves to.
PropNameName of property in Obj
TEMU_API temu_Component* temu_componentCreate ( const char *  Name)

Allocate a component object.

The component create shall be called in the component constructor/create function (the create function passed to the registerComponent function). It will allocate an opaque component object with the relevant name.

The returned component is what the component constructor should return.

Parameters
NameName of component
Returns
Component pointer
TEMU_API void temu_componentDispose ( void *  Comp)

Deallocate a component object

The component dispose shall be called by the component destructor/dispose function registered in the registerComponent call.

Note that a component is seen as owning all the objects created with createComponentObject, and subsequently, all objects created will be recursively deleted when deleting the component.

Parameters
CompComponent to dispose.
TEMU_API temu_IfaceRef temu_componentGetDelegateIface ( temu_Component Comp,
const char *  Name 
)

Query the component for a delegated interface

Normally this function is not needed for the end user, however some usecases can be seen for exposing this. It returns the IfaceRef that has been added as a delegate interface. The main use is to redelegate delegated interfaces in a component of components.

Parameters
CompThe component to query the IfaceRef from
NameName of the interface reference.
Returns
Interface reference associated with Name, if none is found, iref type will be teTY_Invalid.
TEMU_API temu_PropName temu_componentGetDelegateProp ( temu_Component Comp,
const char *  Name 
)

Query the compontent for a delegated property

Normally this should not be called by the user. But is useful in case the user constructs components of components in which case a component can redelegate delegated properties.

Parameters
CompThe componten to query
NameName of delegated property
Returns
Object name pair with the target object and property name.
TEMU_API void* temu_componentGetObject ( void *  Comp,
const char *  Name 
)

Get named object in component

Parameters
CompComponent pointer
NameString without the component prefix (i.e. local name)
Returns
NULL if the object is not a member in the component
TEMU_API void* temu_createComponentObject ( void *  Comp,
const char *  Class,
const temu_CreateArg Args,
const char *  ObjNameFmt,
  ... 
)

Create an object in a component.

This function works as the temu_createObject, except that the object created is inserted in the component.

The function is indended to be used in the component constructor.

Object names are uniqued using the objnamefmt paramters and following varargs. Plus, that the name of the component itself is prefixed as '[compname]-'.

Parameters
CompThe component under which the object is to be created.
Classclass of the created object
ArgsNULL terminated array of create arguments for the constructor.
ObjNameFmtName of created object, but it allows for printf style string names, simplifying the creation of multiple objects of the same type.
Returns
Pointer to created object.
TEMU_API void temu_foreachComponent ( void(*)(temu_Component *, void *)  Func,
void *  Arg 
)

Iterate over all components and call a function on them

Parameters
FuncThe function to be called on each component, with the signature Func)(temu_Component,void*)
ArgThe second argument to be passed to the function, for passing context
TEMU_API void temu_foreachRootComponent ( void(*)(temu_Component *, void *)  Func,
void *  Arg 
)

Iterate over all root components and call a function on them

Parameters
FuncThe function to be called on each component, with the signature Func)(temu_Component,void*)
ArgThe second argument to be passed to the function, for passing context
TEMU_API temu_Class* temu_registerComponent ( const char *  CompClass,
temu_ObjectCreateFunc  Create,
temu_ObjectDisposeFunc  Dispose 
)

Register a new component class in

Parameters
CompClassName of the component to be registered
CreateThe constructor function that allocates the component
DisposeThe destructor function
Returns
Pointer to the new class