Context Management Class

The context management class (OSRTContext) manages an XBinder context structure used for C function calls. In general, for C++, this structure is hidden in that it is encapsulated within the message buffer and global element classes. The user needs to be aware of its existence, however, in cases where a C run-time functions needs to be called from within a C++ application. In these cases, the message buffer or global context class contains a method called getCtxtPtr that can be used to retrieve a pointer to the underlying context variable. Note that it does not matter from which class this method is invoked because the message buffer and global element classes share a common context variable.

The context is shared between the global element and message buffer classes by means of the OSRTCtxtPtr referenced counted pointer class. This class is used to maintain a reference count on the context so that it remains in scope as long as either a message buffer or global element class is in scope. A user can invoke the getContext method from either a message buffer or global element object in order to obtain a reference to this reference counter pointer object. This would allow them to hold onto the context after all message buffer or global element objects go out of scope should they have a specialized need to do this (for example, if they were using the C memory management facilities that use the managed heap that is stored within the context).