SMLAUTOCLASS Class Reference

A helper class to simplify installing real C++ classes into SML. More...

#include <sml.h>

Inheritance diagram for SMLAUTOCLASS:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 SMLAUTOCLASS (void(*SetupFunc)(), SMLCONTEXTTYPE ContextTypesToAllow=SMLCONTEXTTYPE_ANY, SMLCONTEXTTYPE ContextTypesToDisallow=SMLCONTEXTTYPE_NONE)
 ~SMLAUTOCLASS ()
void AddMethodOld (const char *name, const char *RetClass, void *(*func)(int, SMLARG *, UINT8 *, SMLCONTEXT *), SMLPARM *parms, int CreateDate, int ModDate=0, bool bInWin32Native=true, bool bInX=true)
void AddMethodOld (const char *name, void(*func)(int, SMLARG *, UINT8 *, SMLCONTEXT *), SMLPARM *parms, int CreateDate, int ModDate=0, bool bInWin32Native=true, bool bInX=true)
void AddMethodOldCB (const char *name, void(*func)(int, SMLARG *, UINT8 *, SMLCONTEXT *), SMLPARM *parms, int CreateDate, int ModDate=0, bool bInWin32Native=true, bool bInX=true)
void AddMethodOld (const char *name, SMLSTRING *(*func)(int, SMLARG *, UINT8 *, SMLCONTEXT *), SMLPARM *parms, int CreateDate, int ModDate=0, bool bInWin32Native=true, bool bInX=true)
void AddMethodOld (const char *name, double(*func)(int, SMLARG *, UINT8 *, SMLCONTEXT *), SMLPARM *parms, int CreateDate, int ModDate=0, bool bInWin32Native=true, bool bInX=true)
void AddMember (const SMLCLASSMEMBER &)
void AddMembers (const SMLCLASSMEMBER *)
void ForceLink ()
void Init (const char *ClassName, const char *BaseClassName, int CreateDate)
void SetConstructor (void *(*constructor)(void *data, SMLCONTEXT *context, SMLCLASS *smlclass), void(*destructor)(void *data, SMLCONTEXT *context, SMLCLASS *smlclass), int size=0)
void SetCopyConstructor (void *(*copyconstructor)(void *data, SMLCONTEXT *context, SMLCLASS *smlclass, void *))

Static Public Member Functions

int InstallAutoClasses (SMLCONTEXT *context, SMLCONTEXTTYPE contexttype)

Detailed Description

A helper class to simplify installing real C++ classes into SML.

Example usage

      // Declare that this class is only to be used in SML, not queries.
      // Note, an SMLAUTOCLASS must exist for the life of the process.
    // and is usually created statically.  This causes it to be constructed
      // at the beginning of the program and automatically registers itself.
      static SMLAUTOCLASS_NEW_T<FOOBAR> s_AutoClass(&FOOBAR::SetupSMLClass, SMLCONTEXTTYPE_SML);
   
      // [ static method of FOOBAR ]
    void FOOBAR::SetupSMLClass (
         SMLCONTEXT* context
         ) {
         typedef void (FOOBAR::*VOIDMETHOD)();
         s_AutoClass.Init("FOOBAR", NULL, 20011212);
   
         // Parametes for a method that takes one numeric parameter named "enabled"
         static SMLPARM PARMS_SetEnabled[] = {
            { "enabled", STYPE_Num },
            { 0 }
            };
   
         s_AutoClass.AddMethod("IsEnabled",  SIG_b,   (VOIDMETHOD)&FOOBAR::IsEnabled,  NULL, 20011212);
         s_AutoClass.AddMethod("SetEnabled", SIG_v_b, (VOIDMETHOD)&FOOBAR::SetEnabled, PARMS_SetEnabled, 20011212);
         s_AutoClass.AddMethod("SetFocus",   SIG_v,   (VOIDMETHOD)&FOOBAR::SetFocus,   NULL, 20011212);
         }

Note: You cannot use this class directly. Instead, you should use one of the following template methods:

Definition at line 4124 of file sml.h.


Constructor & Destructor Documentation

SMLAUTOCLASS::SMLAUTOCLASS void(*  SetupFunc)(),
SMLCONTEXTTYPE  ContextTypesToAllow = SMLCONTEXTTYPE_ANY,
SMLCONTEXTTYPE  ContextTypesToDisallow = SMLCONTEXTTYPE_NONE
[inline]
 

Parameters:
ContextTypesToAllow  Function to call to setup this class. Normally a static method of the class we're representing SMLCONTEXTTYPEs to install this class for
ContextTypesToDisallow  SMLCONTEXTTYPEs to NOT install this class for

Definition at line 4128 of file sml.h.

SMLAUTOCLASS::~SMLAUTOCLASS  ) 
 


Member Function Documentation

void SMLAUTOCLASS::AddMember const SMLCLASSMEMBER  ) 
 

void SMLAUTOCLASS::AddMembers const SMLCLASSMEMBER  ) 
 

Add an array of SMLCLASSMEMBERs.

The last entry must be blank to single the end of the array.

void SMLAUTOCLASS::AddMethodOld const char *  name,
double(*  func)(int, SMLARG *, UINT8 *, SMLCONTEXT *),
SMLPARM parms,
int  CreateDate,
int  ModDate = 0,
bool  bInWin32Native = true,
bool  bInX = true
 

Add an old-style method (returning a value).

void SMLAUTOCLASS::AddMethodOld const char *  name,
SMLSTRING *(*  func)(int, SMLARG *, UINT8 *, SMLCONTEXT *),
SMLPARM parms,
int  CreateDate,
int  ModDate = 0,
bool  bInWin32Native = true,
bool  bInX = true
 

Add an old-style method (returning SMLSTRING).

void SMLAUTOCLASS::AddMethodOld const char *  name,
void(*  func)(int, SMLARG *, UINT8 *, SMLCONTEXT *),
SMLPARM parms,
int  CreateDate,
int  ModDate = 0,
bool  bInWin32Native = true,
bool  bInX = true
 

Add an old-style method (returning void).

void SMLAUTOCLASS::AddMethodOld const char *  name,
const char *  RetClass,
void *(*  func)(int, SMLARG *, UINT8 *, SMLCONTEXT *),
SMLPARM parms,
int  CreateDate,
int  ModDate = 0,
bool  bInWin32Native = true,
bool  bInX = true
 

Add an old-style method (returning void*).

void SMLAUTOCLASS::AddMethodOldCB const char *  name,
void(*  func)(int, SMLARG *, UINT8 *, SMLCONTEXT *),
SMLPARM parms,
int  CreateDate,
int  ModDate = 0,
bool  bInWin32Native = true,
bool  bInX = true
 

Add an old-style method (returning void) Special case for when one parameter is a function with its own parameter list.

The callback's parameter list is expected to follow the main functions's parameter list (with a null-parameter between them)

void SMLAUTOCLASS::ForceLink  )  [inline]
 

Definition at line 4215 of file sml.h.

void SMLAUTOCLASS::Init const char *  ClassName,
const char *  BaseClassName,
int  CreateDate
 

Initialize the class.

Parameters:
ClassName  The name of this class
BaseClassName  The name of the base class (NULL if none)
CreateDate  Date the class was created (YYYYMMDD format)

int SMLAUTOCLASS::InstallAutoClasses SMLCONTEXT context,
SMLCONTEXTTYPE  contexttype
[static]
 

Called by context creation to add auto-registered classes.

void SMLAUTOCLASS::SetConstructor void *(*  constructor)(void *data, SMLCONTEXT *context, SMLCLASS *smlclass),
void(*  destructor)(void *data, SMLCONTEXT *context, SMLCLASS *smlclass),
int  size = 0
 

Call this to set a custom constructor/destructor.

By default, the class will be allocated and freed with new/delete.

There are a couple other other options, however.

Option 1: SML lets you allocate and free the structure To do this, call SetConstructor and pass pointers to constructor and destructor methods. In this case, you can ignore all the parameters in the constructor. Allocate your data and return it. The destructor can free the data. You must not pass a size to SetConstructor() if you want SML to let you allocate the memory.

Option 2: SML Allocates and Frees the structure using its own memory pool but lets you initialize and clean up. To do this, pass a non-zero size to SetConstructor(). You can also pass pointers to constructor/destructor functions, but in this case, the data parameter is already allocated for you. Your constructor can set things up and you destructor will be called just before the data is freed. Your destructor must not free the pointer itself. If there is nothing to do to constructo the class (i.e., memseting it to 0 is enough), you can pass NULL for the constructor.

void SMLAUTOCLASS::SetCopyConstructor void *(*  copyconstructor)(void *data, SMLCONTEXT *context, SMLCLASS *smlclass, void *)  ) 
 


The documentation for this class was generated from the following file:
Generated on Thu Aug 12 06:27:24 2004 for TNTsdk by doxygen 1.3.4-20031026