OSRTContext Class Reference

class OSRTContext

Reference counted context class. This keeps track of all encode/decode function variables between function invocations. It is reference counted to allow a message buffer and type class to share access to it.

Public Member Functions
OSRTContext()
~OSRTContext()
EXTRTMETHOD void_ref()
EXTRTMETHOD void_unref()
EXTRTMETHOD char *getErrorInfo()
EXTRTMETHOD char *getErrorInfo(size_t *)
EXTRTMETHOD char *getErrorInfo(char *, size_t &)
OSCTXT *getPtr()
const OSCTXT *getPtr()
EXTRTMETHOD OSUINT32getRefCount()
intgetStatus()
OSBOOL isInitialized()
void *memAlloc(size_t)
voidmemFreeAll()
voidmemFreePtr(void *)
void *memRealloc(void *, size_t)
voidmemReset()
voidprintErrorInfo()
voidresetErrorInfo()
OSBOOL setDiag(OSBOOL)
EXTRTMETHOD intsetRunTimeKey(const OSOCTET *, size_t)
intsetStatus(int)
Private Member Functions
OSRTContext(OSCTXT *)
Protected Attributes
OSUINT32 mCount
OSCTXT mCtxt
intmStatus
OSBOOL mbInitialized

Constructor & Destructor Documentation

OSRTContext(OSCTXT *)

EXTRTMETHODOSRTContext(OSCTXT *)[private]

Parameters

OSCTXT *

OSRTContext()

EXTRTMETHODOSRTContext()

The default constructor initializes the mCtxt member variable and sets the reference count variable (mCount) to zero.

~OSRTContext()

EXTRTMETHOD~OSRTContext()[virtual]

The destructor frees all memory held by the context.

Member Functions Documentation

_ref()

EXTRTMETHOD void_ref()

The _ref method increases the reference count by one.

_unref()

EXTRTMETHOD void_unref()

The _unref method decreases the reference count by one.

getErrorInfo()

EXTRTMETHOD char *getErrorInfo()

Returns error text in a dynamic memory buffer. Buffer will be allocated using 'operator new []'. The calling routine is responsible for freeing the memory by using 'operator delete []'.

getErrorInfo(size_t *)

EXTRTMETHOD char *getErrorInfo(size_t *pBufSize)

Returns error text in a dynamic memory buffer. Buffer will be allocated using 'operator new []'. The calling routine is responsible for freeing the memory by using 'operator delete []'.

Parameters

size_t * pBufSizeA pointer to buffer size. It will receive the size of allocated dynamic buffer, or (size_t)-1 if an error occurred.

getErrorInfo(char *, size_t &)

EXTRTMETHOD char *getErrorInfo(char *pBuf,
size_t &bufSize
)

Returns error text in a memory buffer. If buffer pointer is specified in parameters (not NULL) then error text will be copied in the passed buffer. Otherwise, this method allocates memory using the 'operator new []' function. The calling routine is responsible to free the memory by using 'operator delete []'.

Parameters

char * pBufA pointer to a destination buffer to obtain the error text. If NULL, dynamic buffer will be allocated.
size_t & bufSizeA reference to buffer size. If pBuf is NULL it will receive the size of allocated dynamic buffer.

getPtr()

OSCTXT *getPtr()[inline]

The getPtr method returns a pointer to the mCtxt member variable. A user can use this function to get the the context pointer variable for use in a C runtime function call.

getPtr()

const OSCTXT *getPtr()const [inline]

getRefCount()

EXTRTMETHOD OSUINT32getRefCount()

The getRefCount method returns the current reference count.

getStatus()

intgetStatus()const [inline]

The getStatus method returns the runtime status code value.

isInitialized()

OSBOOL isInitialized()[inline]

Returns TRUE, if initialized correctly, FALSE otherwise.

memAlloc(size_t)

void *memAlloc(size_tnumocts)[inline]

The memAlloc method allocates memory using the C runtime memory management functions. The memory is tracked in the underlying context structure. When both this OSXSDGlobalElement derived control class object and the message buffer object are destroyed, this memory will be freed.

Parameters

size_t numocts- Number of bytes of memory to allocate

memFreeAll()

voidmemFreeAll()[inline]

The memFreeAll method will free all memory currently tracked within the context. This includes all memory allocated with the memAlloc method as well as any memory allocated using the C rtxMemAlloc function with the context returned by the getCtxtPtr method.

memFreePtr(void *)

voidmemFreePtr(void *ptr)[inline]

The memFreePtr method frees the memory at a specific location. This memory must have been allocated using the memAlloc method described earlier.

Parameters

void * ptr- Pointer to a block of memory allocated with memAlloc

memRealloc(void *, size_t)

void *memRealloc(void *ptr,
size_tnumocts
)[inline]

The memRealloc method reallocates memory using the C runtime memory management functions.

Parameters

void * ptr- Original pointer containing dynamic memory to be resized.
size_t numocts- Number of bytes of memory to allocate

memReset()

voidmemReset()[inline]

The memReset method resets dynamic memory using the C runtime memory management functions.

printErrorInfo()

voidprintErrorInfo()[inline]

The printErrorInfo method prints information on errors contained within the context.

resetErrorInfo()

voidresetErrorInfo()[inline]

The resetErrorInfo method resets information on errors contained within the context.

setDiag(OSBOOL)

OSBOOL setDiag(OSBOOLvalue = TRUE)[inline]

The setDiag method will turn diagnostic tracing on or off.

Parameters

OSBOOL value = TRUE- Boolean value (default = TRUE = on)

setRunTimeKey(const OSOCTET *, size_t)

EXTRTMETHOD intsetRunTimeKey(const OSOCTET *key,
size_tkeylen
)[virtual]

This method sets run-time key to the context. This method does nothing for unlimited redistribution libraries.

Parameters

const OSOCTET * key- array of octets with the key
size_t keylen- number of octets in key array.

setStatus(int)

intsetStatus(intstat)[inline]

This method sets error status in the context.

Parameters

int statStatus value.

Member Data Documentation

OSUINT32 mCount

OSUINT32 mCount[protected]

The mCount member variable holds the reference count of this context.

OSCTXT mCtxt

OSCTXT mCtxt[protected]

The mCtxt member variable is a standard C runtime context variable used in most C runtime function calls.

int mStatus

intmStatus[protected]

The mStatus variable holds the return status from C run-time function calls. The getStatus method will either return this status or the last status on the context error list.

OSBOOL mbInitialized

OSBOOL mbInitialized[protected]

TRUE, if initialized correctly, FALSE otherwise