ASN1C C/C++ Common Runtime  ASN1C v7.5.x
Public Member Functions | Protected Attributes | List of all members
OSRTContext Class Reference

#include <OSRTContext.h>

Inheritance diagram for OSRTContext:
ASN1Context

Public Member Functions

EXTRTMETHOD OSRTContext ()
 
virtual EXTRTMETHOD ~OSRTContext ()
 
OSCTXTgetPtr ()
 
const OSCTXTgetPtr () const
 
EXTRTMETHOD OSUINT32 getRefCount ()
 
int getStatus () const
 
OSBOOL isInitialized ()
 
EXTRTMETHOD void _ref ()
 
EXTRTMETHOD void _unref ()
 
EXTRTMETHOD char * getErrorInfo ()
 
EXTRTMETHOD char * getErrorInfo (size_t *pBufSize)
 
EXTRTMETHOD char * getErrorInfo (char *pBuf, size_t &bufSize)
 
void * memAlloc (size_t numocts)
 
void * memAllocZ (size_t numocts)
 
void memFreeAll ()
 
void memFreePtr (void *ptr)
 
void * memRealloc (void *ptr, size_t numocts)
 
void memReset ()
 
void printErrorInfo ()
 
void resetErrorInfo ()
 
OSBOOL setDiag (OSBOOL value=TRUE)
 
virtual EXTRTMETHOD int setRunTimeKey (const OSOCTET *key, size_t keylen)
 
int setStatus (int stat)
 

Protected Attributes

OSCTXT mCtxt
 
OSUINT32 mCount
 
OSBOOL mbInitialized
 
int mStatus
 

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.

Constructor & Destructor Documentation

◆ OSRTContext()

EXTRTMETHOD OSRTContext::OSRTContext ( )

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

◆ ~OSRTContext()

virtual EXTRTMETHOD OSRTContext::~OSRTContext ( )
virtual

The destructor frees all memory held by the context.

Member Function Documentation

◆ _ref()

EXTRTMETHOD void OSRTContext::_ref ( )

The _ref method increases the reference count by one.

Referenced by OSRTCtxtPtr::operator=(), and OSRTCtxtPtr::OSRTCtxtPtr().

◆ _unref()

EXTRTMETHOD void OSRTContext::_unref ( )

The _unref method decreases the reference count by one.

Referenced by OSRTCtxtPtr::operator=(), and OSRTCtxtPtr::~OSRTCtxtPtr().

◆ getErrorInfo() [1/3]

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.

◆ getErrorInfo() [2/3]

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
pBufSizeA 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.

◆ getErrorInfo() [3/3]

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
pBufA pointer to a destination buffer to obtain the error text. If NULL, dynamic buffer will be allocated.
bufSizeA 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.

◆ getPtr()

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.

Referenced by OSRTCtxtPtr::getCtxtPtr(), and ASN1CType::getCtxtPtr().

◆ getRefCount()

EXTRTMETHOD OSUINT32 OSRTContext::getRefCount ( )

The getRefCount method returns the current reference count.

◆ getStatus()

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.

References rtxErrGetLastError().

Referenced by ASN1CType::getStatus().

◆ isInitialized()

OSBOOL OSRTContext::isInitialized ( )
inline

Returns TRUE, if initialized correctly, FALSE otherwise.

Returns
TRUE, if initialized correctly, FALSE otherwise.

◆ memAlloc()

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

References rtxMemAlloc.

Referenced by ASN1CType::memAlloc().

◆ memAllocZ()

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

References rtxMemAllocZ.

Referenced by ASN1CType::memAllocZ().

◆ memFreeAll()

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.

References rtxMemFree().

Referenced by ASN1CType::memFreeAll().

◆ memFreePtr()

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

References rtxMemFreePtr.

Referenced by ASN1CType::memFreePtr().

◆ memRealloc()

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

References rtxMemRealloc.

Referenced by ASN1CType::memRealloc().

◆ memReset()

void OSRTContext::memReset ( )
inline

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

References rtxMemReset().

Referenced by ASN1CType::memReset().

◆ printErrorInfo()

void OSRTContext::printErrorInfo ( )
inline

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

References rtxErrPrint().

Referenced by ASN1CType::printErrorInfo().

◆ resetErrorInfo()

void OSRTContext::resetErrorInfo ( )
inline

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

References rtxErrReset().

Referenced by ASN1CType::resetError().

◆ setDiag()

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

References rtxSetDiag().

◆ setRunTimeKey()

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.

Reimplemented in ASN1Context.

◆ setStatus()

int OSRTContext::setStatus ( int  stat)

This method sets error status in the context.

Parameters
statStatus value.
Returns
Error status value being set.

Referenced by ASN1MessageBuffer::setStatus().

Member Data Documentation

◆ mbInitialized

OSBOOL OSRTContext::mbInitialized
protected

TRUE, if initialized correctly, FALSE otherwise

◆ mCount

OSUINT32 OSRTContext::mCount
protected

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

◆ mCtxt

OSCTXT OSRTContext::mCtxt
protected

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

◆ mStatus

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.


The documentation for this class was generated from the following file: