Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

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



Location: apmrec.h
Link against: apmime.lib

Class CApaDataRecognizerType

CApaDataRecognizerType

Support

Supported from 5.0

Description

Abstract base class for a recognizer.

Concrete recognizers need to define and implement a derived class; specifically, they need to provide an implementation of the DoRecognizeL(), SupportedDataTypeL() and PreferredBufSize() functions.

The class is implemented as part of a DLL. The ordinal 1 function of the DLL must construct an instance of, and return a pointer to, a CApaDataRecognizerType derived class.

Derivation

CApaDataRecognizerTypeAbstract base class for a recognizer
CBaseBase class for all classes to be instantiated on the heap

Defined in CApaDataRecognizerType:
CApaDataRecognizerType(), Confidence(), DoRecognizeL(), ECertain, EHigh, ELow, ENormal, ENotRecognized, EPossible, EProbable, EUnlikely, Lock(), Locked(), MimeType(), MimeTypesCount(), PreferredBufSize(), Priority(), RecognizeL(), SupportedDataTypeL(), TRecognitionConfidence, TRecognizerPriority, TypeUid(), Unlock(), UpdateDataTypesL(), iConfidence, iCountDataTypes, iDataType, ~CApaDataRecognizerType()

Inherited from CBase:
operator new()


Construction and destruction


CApaDataRecognizerType()

protected : CApaDataRecognizerType(TUid aUid, TInt aPriority);

Description

Constructs the recognizer with a UID and a priority.

Typically, a derived class constructor calls this constructor through a constructor initialization list.

The UID is the way that a recognizer is detected by the framework.

Parameters

TUid aUid

A UID that identifies the recognizer.

TInt aPriority

A value that estimates the probability that the recognizer will successfully identify data. This is one of the CApaDataRecognizerType::TRecognizerPriority enumerators.

See also:


~CApaDataRecognizerType()

~CApaDataRecognizerType();

Description

Destructor.

This implementation is empty.

[Top]


Performing data recognition


RecognizeL()

TDataRecognitionResult RecognizeL(const TDesC& aName, const TDesC8& aBuffer);

Description

Attempts to recognize data.

This function is called by the Application Architecture server as a result of client calls to the server through an instance of RApaLsSession.

The function calls DoRecognizeL() which implements recognition behaviour.

Parameters

const TDesC& aName

The name of the data; typically this is a file name containing the data to be recognized.

const TDesC8& aBuffer

A buffer containing data to be recognized; typically, this is read from the start of the file containing the data. Implement PreferredBufSize() to define the ideal size for this buffer. Note that failure to implement PreferredBufSize() results in a default buffer size of zero.

Return value

TDataRecognitionResult

The result of the attempt to recognize the data.

See also:


DoRecognizeL()

private : virtual void DoRecognizeL(const TDesC& aName, const TDesC8& aBuffer);

Description

Implements the attempt to recognize data.

The function is called by RecognizeL().

Recognizers should provide an implementation of this function in a derived class. Note that, when the implementation recognizes data, it must put the result of the operation in the iDataType and iConfidence data members.

The default implementation does not recognize data.

Parameters

const TDesC& aName

The name of the data; typically this is a file name containing the data to be recognized.

const TDesC8& aBuffer

A buffer containing data to be recognized; typically, this is read from the start of the file containing the data.

See also:


Lock()

void Lock();

Description

Adds a lock to the recognizer.

This may be called any number of times, but each call to this function must be matched by a corresponding call to Unlock() to completely unlock the recognizer.

This function is used to prevent the recognizer DLL from being unloaded.

See also:


Unlock()

void Unlock();

Description

Removes a lock from the recognizer.

All calls to Lock() should be matched by a corresponding call to this function. The recognizer is not unlocked until all calls to Lock() have been matched by corresponding calls to this function.

See also:


UpdateDataTypesL()

void UpdateDataTypesL();

Description

Refreshes the list of data (MIME) types supported by this recognizer.

[Top]


Information


Priority()

TInt Priority() const;

Description

Gets the recognizer's priority.

The priority defines the likelihood that the recognizer will successfully identify data. This is one of the CApaDataRecognizerType::TRecognizerPriority enumerators.

Return value

TInt

The priority value.

See also:


TypeUid()

TUid TypeUid() const;

Description

Gets the UID that identifies the recognizer.

Return value

TUid

The UID.


Confidence()

TInt Confidence() const;

Description

Gets the recognizer's confidence rating for the most recently recognized data.

Return value

TInt

The confidence rating. This is one of the TRecognitionConfidence enumeration values.

See also:


MimeType()

TDataType MimeType();

Description

Gets the data (MIME) type of the most recently recognized data.

Return value

TDataType

The data (MIME) type.

See also:


MimeTypesCount()

TInt MimeTypesCount() const;

Description

Gets the number of data (MIME) types supported by this recognizer.

Return value

TInt

The number of data types.

See also:


Locked()

TInt Locked() const;

Description

Tests whether the recognizer is locked.

Return value

TInt

If zero, the recognizer is not locked; if greater than 0, the recognizer is locked.

See also:


PreferredBufSize()

virtual TUint PreferredBufSize();

Description

Gets the size of buffer preferred for the purpose of recognizing the data type.

Regardless of the preferred buffer size returned by an implementation of this function, the actual size used is never greater than a maximum value as set by the client of the Application Architecture server through a call to RApaLsSession::SetMaxDataBufSize().

Return value

TUint

The preferred data size. The default implementation returns zero.

See also:


SupportedDataTypeL()

virtual TDataType SupportedDataTypeL(TInt aIndex) const = 0;

Description

Gets one of the data (MIME) types that the recognizer can recognize.

Parameters

TInt aIndex

An index that identifies the data type. Typically, the minimum value is zero and the maximum value is the value of MimeTypesCount() - 1.

Return value

TDataType

The data (MIME) type.

[Top]


Data members


iConfidence

protected : TInt iConfidence

Description

The recognizer's confidence rating of the most recently recognized data.

Users of the derived class use Confidence() to get this value.


iDataType

protected : TDataType iDataType;

Description

The data (MIME) type of the most recently recognized data.

Users of the derived class use MimeType() to get this value.


iCountDataTypes

protected : TInt iCountDataTypes;

Description

The number of data (MIME) types supported by this recognizer. Typically, this is set during construction of an instance of the derived class.

Users of the derived class use MimeTypesCount() to get this value.

[Top]


Enumerations


Enum TRecognitionConfidence

TRecognitionConfidence

Description

A set of values describing the probability that the recognizer assigns to its belief that the most recently sampled data is of the type ascribed to it.

ECertain

The data is definitely of the data type.

EProbable

A level of confidence between ECertain and EPossible.

EPossible

The data is possibly of the data type.

EUnlikely

A level of confidence between EPossible and ENotRecognized.

ENotRecognized

The data is not recognized.


Enum TRecognizerPriority

TRecognizerPriority

Description

A set of values used to indicate the probability that the recognizer will successfully identify data. The Application Architecture framework uses this set to determine the order in which recognizers are invoked.

See also:

EHigh

The highest recognizer priority. Recognizers with this priority are invoked before those with any other priority.

ENormal

The normal recognizer priority. Recognizers with this priority are invoked after those with a EHigh priority but before those with a ELow priority.

ELow

The lowest recognizer priority.