Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: e32std.h
Link against: euser.lib

Class TCallBack

TCallBack

Support

Supported from 5.0

Description

Encapsulates a general call-back function.

Although widely applicable, it simplifies the programming interface of:

The class encapsulates:

The callback function can be a static function of a class, e.g. TInt X::Foo(TAny *) or it can be a function which is not a member of any class, e.g. TInt Foo(TAny *).

When used with the CIdle and the CPeriodic classes, the callback function is intended to be called repeatedly; the encapsulated pointer is passed on each call. Typically, the pointer refers to an object which records the state of the task across each call. The callback function should also return a true (non-zero) value if it is intended to be called again, otherwise it should return a false (zero) value.

Defined in TCallBack:
CallBack(), TCallBack()

See also:


Construction and destruction


TCallBack()

TCallBack(TInt (*aFunction)(TAny* aPtr));
TCallBack(TInt (*aFunction)(TAny* aPtr),TAny* aPtr);

Description

Constructs the callback object with the specified callback function and, optionally, a pointer to an object.

Parameters

TInt (*aFunction)(TAny *aPtr)

A pointer to the callback function. It takes an argument of type TAny* and returns a TInt. It must be either a static function of a class or a function which is not a member of any class.

TAny *aPtr

A pointer which is always passed to the callback function. If not specified, defaults to NULL.

[Top]


Callback


CallBack()

TInt CallBack() const;

Description

Calls the callback function.

Return value

TInt

The value returned by the callback function. A true (non-zero) value indicates that the callback function should be called again. A false (zero) value indicates that the callback function should not be called again. This is particularly important when the callback is used with the CIdle and CPeriodic classes