This class provides a way to attach private data to an SML::CONTEXT on a per-context basis. More...
#include <sml/context.h>
Public Member Functions | |
| virtual | ~DEVPRIVATE () |
Protected Member Functions | |
| DEVPRIVATE () | |
This class provides a way to attach private data to an SML::CONTEXT on a per-context basis.
Any data attached in this way is automatically deleted when the context is destroied. To do so, first create a class derived from SML::DEVPRIVATE. Then write a function like the following.
static MYPRIVDATA* GetPrivData ( SML::CONTEXT* context ) { static int PrivateDataIndex = -1; MYPRIVDATA* pdp; if (PrivateDataIndex < 0) { PrivateDataIndex = context->PrivDataIndexAlloc(); if (PrivateDataIndex < 0) return (NULL); } pdp = static_cast<MYPRIVDATA*>(context->GetPrivData(PrivateDataIndex)); if (pdp == NULL) { // First time for this context pdp = new MYPRIVDATA(context); context->SetPrivData(PrivateDataIndex, pdp); } return (pdp); }
| virtual SML::DEVPRIVATE::~DEVPRIVATE | ( | ) | [inline, virtual] |
| SML::DEVPRIVATE::DEVPRIVATE | ( | ) | [inline, protected] |
Constructor (protected).
The constructor is protected so that you can't create an instance of an SML::DEVPRIVATE, only derived classes. The derived class should make the constructor public.
1.6.1