OSRTContext Class Reference
Reference counted context class. More...
#include <OSRTContext.h>
Public Member Functions | |
EXTRTMETHOD | OSRTContext () |
The default constructor initializes the mCtxt member variable and sets the reference count variable (mCount) to zero. | |
virtual EXTRTMETHOD | ~OSRTContext () |
The destructor frees all memory held by the context. | |
OSCTXT * | getPtr () |
The getPtr method returns a pointer to the mCtxt member variable. | |
EXTRTMETHOD OSUINT32 | getRefCount () |
The getRefCount method returns the current reference count. | |
int | getStatus () const |
The getStatus method returns the runtime status code value. | |
OSBOOL | isInitialized () |
Returns TRUE, if initialized correctly, FALSE otherwise. | |
EXTRTMETHOD void | _ref () |
The _ref method increases the reference count by one. | |
EXTRTMETHOD void | _unref () |
The _unref method decreases the reference count by one. | |
EXTRTMETHOD char * | getErrorInfo () |
Returns error text in a dynamic memory buffer. | |
EXTRTMETHOD char * | getErrorInfo (size_t *pBufSize) |
Returns error text in a dynamic memory buffer. | |
EXTRTMETHOD char * | getErrorInfo (char *pBuf, size_t &bufSize) |
Returns error text in a memory buffer. | |
void * | memAlloc (size_t numocts) |
The memAlloc method allocates memory using the C runtime memory management functions. | |
void * | memAllocZ (size_t numocts) |
The memAllocZ method allocates and zeroes memory using the C runtime memory management functions. | |
void | memFreeAll () |
The memFreeAll method will free all memory currently tracked within the context. | |
void | memFreePtr (void *ptr) |
The memFreePtr method frees the memory at a specific location. | |
void * | memRealloc (void *ptr, size_t numocts) |
The memRealloc method reallocates memory using the C runtime memory management functions. | |
void | memReset () |
The memReset method resets dynamic memory using the C runtime memory management functions. | |
void | printErrorInfo () |
The printErrorInfo method prints information on errors contained within the context. | |
void | resetErrorInfo () |
The resetErrorInfo method resets information on errors contained within the context. | |
OSBOOL | setDiag (OSBOOL value=TRUE) |
The setDiag method will turn diagnostic tracing on or off. | |
virtual EXTRTMETHOD int | setRunTimeKey (const OSOCTET *key, size_t keylen) |
This method sets run-time key to the context. | |
int | setStatus (int stat) |
This method sets error status in the context. | |
Protected Attributes | |
OSCTXT | mCtxt |
The mCtxt member variable is a standard C runtime context variable used in most C runtime function calls. | |
OSUINT32 | mCount |
The mCount member variable holds the reference count of this context. | |
OSBOOL | mbInitialized |
TRUE, if initialized correctly, FALSE otherwise. | |
int | mStatus |
The mStatus variable holds the return status from C run-time function calls. |
Detailed Description
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.
Definition at line 65 of file OSRTContext.h.
Member Function Documentation
EXTRTMETHOD char* OSRTContext::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:
-
pBuf A pointer to a destination buffer to obtain the error text. If NULL, dynamic buffer will be allocated. bufSize A reference to buffer size. If pBuf is NULL it will receive the size of allocated dynamic buffer.
- Returns:
- A pointer to a buffer with error text. If pBuf is not NULL, the return pointer will be equal to it. Otherwise, returns newly allocated buffer with error text. NULL, if error occurred.
EXTRTMETHOD char* OSRTContext::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:
-
pBufSize A pointer to buffer size. It will receive the size of allocated dynamic buffer, or (size_t)-1 if an error occurred.
- Returns:
- A pointer to a newly allocated buffer with error text, or NULL if an error occurred.
EXTRTMETHOD char* OSRTContext::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 []'.
- Returns:
- A pointer to a newly allocated buffer with error text, or NULL if an error occurred.
OSCTXT* OSRTContext::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.
Definition at line 110 of file OSRTContext.h.
int OSRTContext::getStatus | ( | ) | const [inline] |
The getStatus method returns the runtime status code value.
- Returns:
- Runtime status code:
- 0 (0) = success,
- negative return value is error.
Definition at line 125 of file OSRTContext.h.
OSBOOL OSRTContext::isInitialized | ( | ) | [inline] |
Returns TRUE, if initialized correctly, FALSE otherwise.
- Returns:
- TRUE, if initialized correctly, FALSE otherwise.
Definition at line 133 of file OSRTContext.h.
void* OSRTContext::memAlloc | ( | size_t | numocts | ) | [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:
-
numocts - Number of bytes of memory to allocate
Definition at line 196 of file OSRTContext.h.
void* OSRTContext::memAllocZ | ( | size_t | numocts | ) | [inline] |
The memAllocZ method allocates and zeroes 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:
-
numocts - Number of bytes of memory to allocate
Definition at line 209 of file OSRTContext.h.
void OSRTContext::memFreeAll | ( | ) | [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.
Definition at line 219 of file OSRTContext.h.
void OSRTContext::memFreePtr | ( | 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:
-
ptr - Pointer to a block of memory allocated with memAlloc
Definition at line 231 of file OSRTContext.h.
void* OSRTContext::memRealloc | ( | void * | ptr, | |
size_t | numocts | |||
) | [inline] |
The memRealloc method reallocates memory using the C runtime memory management functions.
- Parameters:
-
ptr - Original pointer containing dynamic memory to be resized. numocts - Number of bytes of memory to allocate
- Returns:
- Reallocated memory pointer
Definition at line 244 of file OSRTContext.h.
OSBOOL OSRTContext::setDiag | ( | OSBOOL | value = TRUE |
) | [inline] |
The setDiag method will turn diagnostic tracing on or off.
- Parameters:
-
value - Boolean value (default = TRUE = on)
- Returns:
- - Previous state of the diagnostics enabled boolean
Definition at line 278 of file OSRTContext.h.
virtual EXTRTMETHOD int OSRTContext::setRunTimeKey | ( | const OSOCTET * | key, | |
size_t | keylen | |||
) | [virtual] |
This method sets run-time key to the context.
This method does nothing for unlimited redistribution libraries.
- Parameters:
-
key - array of octets with the key keylen - number of octets in key array.
- Returns:
- Completion status of operation:
- 0 = success,
- negative return value is error.
int OSRTContext::setStatus | ( | int | stat | ) | [inline] |
This method sets error status in the context.
- Parameters:
-
stat Status value.
- Returns:
- Error status value being set.
Definition at line 300 of file OSRTContext.h.
Member Data Documentation
int OSRTContext::mStatus [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.
Definition at line 91 of file OSRTContext.h.
The documentation for this class was generated from the following file: