SML::DEVPRIVATE Class Reference

This class provides a way to attach private data to an SML::CONTEXT on a per-context basis. More...

#include <sml/context.h>

List of all members.

Public Member Functions

virtual ~DEVPRIVATE ()

Protected Member Functions

 DEVPRIVATE ()

Detailed Description

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);
      }

Constructor & Destructor Documentation

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.


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

Generated on Sun Oct 7 21:39:09 2012 for TNTsdk 2012 by  doxygen 1.6.1