CObjectCon Class Reference

#include <e32base.h>

class CObjectCon : public CBase

Inherits from

Detailed Description

An object container.

An object container acts as a home for a set of related reference counting objects.

A reference counting object, a CObject type, must be added to an object container. Only one instance of a given reference counting object can be held by an object container, i.e. each object within an object container must be distinct.

Object containers are constructed by an object container index, a CObjectConIx type.

Note that this class is not intended for user derivation.

See also: CObject CObjectConIx

Member Attribute Documentation

iUniqueID

TInt iUniqueID

The object container's unique Id value.

Constructor & Destructor Documentation

CObjectCon ( TInt )

IMPORT_CCObjectCon(TIntaUniqueID)[protected]

Constructor taking a unique Id.

ParameterDescription
aUniqueIDThe unique Id value.

~CObjectCon ( )

IMPORT_C~CObjectCon()

Destructor.

Frees all resources owned by the object container, prior to its destruction.

In particular, it destroys all contained reference counting objects.

See also: CObject

Member Function Documentation

AddL ( CObject * )

IMPORT_C voidAddL(CObject *anObj)

Adds a reference counting object to this object container.

If the specified reference counting object has a name, it must be valid, otherwise the function leaves with KErrBadName; in addition, the reference counting object's full name must be unique to this object container, otherwise the function leaves with KErrAlreadyExists.

If the specified reference counting object has no name, then the object itself must be unique to the object container, i.e. the object container should not already contain the same reference counting object, otherwise the function leaves with KErrAlreadyExists.

ParameterDescription
anObjA pointer to the reference counting object to be added.

At ( TInt )

IMPORT_C CObject *At(TIntaFindHandle)const

Gets a pointer to the reference counting object with the specified find-handle number.

A find-handle number is an integer which uniquely identifies a reference counting object with respect to its object container.

panic
E32User-CBase 38 if the unique Id part of aFindHandle is not the same as the unique Id of this container.
panic
E32User-CBase 39 if the index part of aFindHandle is negative or greater than or equal to the total number of reference counting objects held by this object container.
ParameterDescription
aFindHandleThe find-handle number of the reference counting object. The unique Id part of this number must be the same as the unique Id of this container. The index part of the find-handle number must be a valid index.

Returns: A pointer to the reference counting object.

AtL ( TInt )

IMPORT_C CObject *AtL(TIntaFindHandle)const

Gets a pointer to the reference counting object with the specified find-handle number, and leaves on error..

A find-handle number is an integer which uniquely identifies a reference counting object with respect to its object container.

leave
KErrBadHandle if the unique Id part of aFindHandle is not the same as the unique Id of this container.
leave
KErrArgument if the index part of aFindHandle is negative or greater than or equal to the total number of reference counting objects held by this object container.
ParameterDescription
aFindHandleThe find-handle number of the reference counting object. The unique Id part of this number must be the same as the unique Id of this container. The index part of the find-handle number must be a valid index.

Returns: A pointer to the reference counting object.

CheckUniqueFullName ( const CObject *, const TDesC & )

IMPORT_C TIntCheckUniqueFullName(const CObject *anOwner,
const TDesC &aName
)const

Checks that a name will be unique.

The function checks that no reference counting object exists in this object container with the same full name as that generated from the specified name and the specified owning reference counting object.

This is a useful test to ensure that the name for a potential new reference counting object will result in a unique full name.

ParameterDescription
anOwnerA pointer to a potential owning reference counting object.
aNameThe name for a potential new reference counting object.

Returns: KErrNone, if the full name does not already exist in this object container; KErrBadName, if the specified name is invalid; KErrAlreadyExists, if a reference counting object with the same fullname as the generated one already exists in this object container.

CheckUniqueFullName ( const CObject * )

IMPORT_C TIntCheckUniqueFullName(const CObject *anObject)const

Checks that the specified reference counting object does not already exist in this object container.

Uniqueness is decided by name, if the object has a name, otherwise by pointer.

If the reference counting object has a name, then it is unique only if there is no other reference counting object in the container with the same full name.

If the reference counting object has no name, then it is unique only if there is no other reference counting object in the container with the same pointer.

ParameterDescription
anObjectA pointer to the reference counting object to be checked.

Returns: KErrNone, if the reference counting object does not already exist in this object container; KErrBadName, if the name of the reference counting object is invalid; KErrAlreadyExists, if the reference counting object already exists.

Count ( )

TInt Count()const [inline]

Gets the number of reference counting objects in this object container.

Returns: The number of objects.

FindByFullName ( TInt &, const TDesC &, TFullName & )

IMPORT_C TIntFindByFullName(TInt &aFindHandle,
const TDesC &aMatch,
TFullName &aFullName
)const

Searches for the reference counting object whose full name matches the specified match pattern.

The search starts at the reference counting object following the one associated with the specified find-handle number. If the specified find-handle number is zero, then searching starts at the beginning of the object container.

Notes:

1. names are folded for the purpose of pattern matching

2. if the specified find-handle number is non-zero, then the unique Id part of the number must be the same as the unique Id of this container.

panic
E32User-CBase 38 if aFindHandle is non-zero and the unique Id part of it is not the same as the unique Id of this container.
ParameterDescription
aFindHandleOn entry, contains the find-handle number of a reference counting object from where searching is to start or zero. On return, if an object is found, then this is set to the find-handle number of that object; if no object is found, then this is set to a generated number, the index part of which has the value 0x7fff. If the object container is empty, then this reference is not changed.
aMatchThe match pattern.
aFullNameA modifiable buffer descriptor with a defined maximum length. On return, if an object is found, then this contains the full name of that object; if no object is found, then the length of this descriptor is set to zero. If the object container is empty, then this reference is not changed.

Returns: KErrNone, if a matching reference counting object is found; KErrNotFound, if no matching reference counting object can be found or the object container is empty.

FindByName ( TInt &, const TDesC &, TName & )

IMPORT_C TIntFindByName(TInt &aFindHandle,
const TDesC &aMatch,
TName &aName
)const

Searches for the reference counting object whose name matches the specified match pattern.

The search starts at the reference counting object following the one associated with the specified find-handle number. If the specified find-handle number is zero, then searching starts at the beginning of the object container.

Notes:

1. names are folded for the purpose of pattern matching

2. if the specified find-handle number is non-zero, then the unique Id part of the number must be the same as the unique Id of this container.

panic
E32User-CBase 38 if aFindHandle is non-zero and the unique Id part of it is not the same as the unique Id of this container.
ParameterDescription
aFindHandleOn entry, contains the find-handle number of a reference counting object from where searching is to start, or zero. On return, if an object is found, then this is set to the find-handle number of that object; if no object is found, then this is set to a generated number, the index part of which has the value 0x7fff. If the object container is empty, then this reference is not changed.
aMatchThe match pattern.
aNameA modifiable buffer descriptor with a defined maximum length. On return, if an object is found, then this contains the name of that object; if no object is found, then the length of this descriptor is set to zero. If the object container is empty, then this reference is not changed.

Returns: KErrNone, if a matching reference counting object is found; KErrNotFound, if no matching reference counting object can be found or the object container is empty.

NamesMatch ( const CObject *, const CObject * )

TBool NamesMatch(const CObject *anObject,
const CObject *aCurrentObject
)const [protected]

protected recursive function for use by CheckUniqueFullName

NamesMatch ( const CObject *, const TName &, const CObject * )

TBool NamesMatch(const CObject *anObject,
const TName &anObjectName,
const CObject *aCurrentObject
)const [protected]

protected recursive function for use by CheckUniqueFullName

NewL ( )

IMPORT_C CObjectCon *NewL()[static]

Creates an object container.

Open code rarely, if ever, explicitly calls this function. Instead, call the CreateL() member function of the container index, CObjectConIx, which uses this function in its implementation.

See also: CObjectConIx::CreateL

Returns: A pointer to the new object container.

Remove ( CObject * )

IMPORT_C voidRemove(CObject *anObj)

Removes a reference counting object from this object container.

The specified reference counting object is destroyed on removal.

panic
E32USER-CBase 35 if the reference counting object is not held by this object container.
ParameterDescription
anObjA pointer to the reference counting object to be removed.

UniqueID ( )

TInt UniqueID()const [inline]

Gets this object container's unique ID.

Returns: The unique ID value.

operator[] ( TInt )

IMPORT_C CObject *operator[](TIntanIndex)

Gets a pointer to the reference counting object located at the specified offset within the object container.

panic
E32USER-CBase 21 if anIndex is negative or is greater than or equal to the total number of objects held by the container.
ParameterDescription
anIndexThe offset of the reference counting object within the object container. Offset is relative to zero.

Returns: A pointer to the owning reference counting object.