Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

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



Location: e32std.h
Link against: euser.lib

Class RHandleBase

RHandleBase

Support

Supported from 5.0

Description

Handle to an object.

The class encapsulates the basic behaviour of a handle, hiding the handle-number which identifies the object which the handle represents. While a number of functions are publicly exported from the header file, only Close(), Duplicate(), Handle(), SetHandle() and the copy constructor are part of the public API.

The class is abstract in the sense that a RHandleBase object is never explicitly instantiated. It always a base class to a concrete handle class; for example, RSemaphore, RThread, RProcess, RCriticalSection etc.

Defined in RHandleBase:
Close(), Duplicate(), Handle(), RHandleBase(), SetHandle()


Construction


RHandleBase()

RHandleBase(const RHandleBase& aHandle);

Description

Copy constructor.

It constructs this handle from an existing one. Specifically, the handle-number encapsulated by the specified handle is copied to this handle.

[Top]


Closing a handle to a global kernel object


Close()

void Close();

Description

Closes the handle.

This has the effect of closing the associated object.

As the associated object is a reference counting object, it is destroyed if there are no other open references to it.

See also:

[Top]


Duplicating a handle


Duplicate()

TInt Duplicate(const RThread& aSrc,TOwnerType aType=EOwnerProcess);

Description

Creates a valid handle to the Kernel object to which the specified thread already has a handle.

The function assumes that this handle has been copy constructed from an existing handle (or the handle-number has been explicitly copied through calls to Handle() and SetHandle()).

By default, ownership of this handle representing the object is vested in the current process, but can be vested in the current thread by passing EOwnerThread as the second parameter to this function.

Parameters

const RThread& aSrc

A reference to the thread containing the handle which is to be duplicated for this thread.

TOwnerType aType

An enumeration whose enumerators define the ownership of this handle. If not explicitly specified, EOwnerProcess is taken as default.

Return value

TInt

KErrNone, if successful; otherwise, one of the other system wide error codes.

[Top]


Setting and retrieving the handle-number


SetHandle()

void SetHandle(TInt aHandle);

Description

Use this function to set the handle-number of this handle to the specified value.

Parameters

TInt aHandle

The handle-number to be set.


Handle()

TInt Handle() const;

Description

Retrieves the handle-number of the object associated with this handle.

Return value

TInt

The handle number