PrevNextUpHome BREW C++ Class Library & GUI Framework & XML Middleware : SophiaFramework 4.1

20.1. BREW Interface

SophiaFremwork provides the C++ wrapper classes for all the interfaces included in the BREW SDK.

20.1.1. Example: SFBHash

Example 20.1. Create the interface

// SFBHashSmp is smart pointer that manages SFBHash interface
// new interface is created by using SFBHash::NewInstance function
SFBHashSmp hash(SFBHash::NewInstance(AEECLSID_MD5));

Example 20.2. Call the interface

// call API
hash->Restart();

Example 20.3. Termination Processing after using the interface

// since interface will be automatically released, you need not to do anything

// if you want to release interface explicitly, use code below
// hash->Release(); 

20.1.2. Execution Speed of Wrapper

In a wrapper class, there are two types of functions: inline function that simply wraps the BREW API in C++, and function that takes the instances of SophiaFramework class as arguments.

Since the inline function is inline-expanded during compilation, the speed degradation will never occur at runtime.

Example 20.4. ISHELL_GetAppCopyright function of IShell interface

// BREW native API
int ISHELL_GetAppCopyright(IShell* pIShell, AECHAR* pBuff, int nSize);

// inline function that simply wraps BREW API function
SInt32 SFBShell::GetAppCopyright(WCharPtr buf, SInt32 size);

// function that takes instance of SophiaFramework class as argument
SInt32 SFBShell::GetAppCopyright(SFXWideStringPtr string);

The above function takes a pointer to the buffer where the WChar string is stored as an argument.

The inline function is one that wraps simply the BREW native API.

In the function that takes the instances of SophiaFramework class as arguments, the class such as SFXWideString is extended to be specified as an argument. Since overheads such as getting the size of SFXWideString instance are included, a bit slowdown occurs.