SML::AUTOCLASS Class Reference

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

#include <sml/class.h>

Inheritance diagram for SML::AUTOCLASS:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 AUTOCLASS (void(*SetupFunc)())
DEPRECATED AUTOCLASS (void(*SetupFunc)(), CONTEXTTYPE ContextTypesToAllow, CONTEXTTYPE ContextTypesToDisallow=CONTEXTTYPE_NONE)
virtual ~AUTOCLASS ()
void AddMember (const CLASSMEMBER &member)
void AddMembers (const CLASSMEMBER *members)
void AddMethodOld (const char *name, double(*func)(int, ARG *, UINT8 *, CONTEXT *), PARM *parms, int CreateDate=0, int ModDate=0, bool bInWin32Native=true, bool bInX=true, bool bRequired=false)
void AddMethodOld (const char *name, STRING *(*func)(int, ARG *, UINT8 *, CONTEXT *), PARM *parms, int CreateDate=0, int ModDate=0, bool bInWin32Native=true, bool bInX=true, bool bRequired=false)
void AddMethodOld (const char *name, void(*func)(int, ARG *, UINT8 *, CONTEXT *), PARM *parms, int CreateDate=0, int ModDate=0, bool bInWin32Native=true, bool bInX=true, bool bRequired=false)
void AddMethodOld (const char *name, const char *RetClass, bool bReturnIsAllocated, void *(*func)(int, ARG *, UINT8 *, CONTEXT *), PARM *parms, int CreateDate=0, int ModDate=0, bool bInWin32Native=true, bool bInX=true, bool bRequired=false)
void AddMethodOld (const char *name, const char *RetClass, CLASSHASH *(*func)(int, ARG *, UINT8 *, CONTEXT *), PARM *parms, int CreateDate=0, int ModDate=0, bool bInWin32Native=true, bool bInX=true, bool bReturnIsAllocated=true, bool bRequired=false)
void AddMethodOldCB (const char *name, void(*func)(int, ARG *, UINT8 *, CONTEXT *), PARM *parms, int CreateDate=0, int ModDate=0, bool bInWin32Native=true, bool bInX=true, bool bRequired=false)
void AddMethodOldCB (const char *name, const char *RetClass, bool bReturnIsAllocated, void *(*func)(int, ARG *, UINT8 *, CONTEXT *), PARM *parms, int CreateDate=0, int ModDate=0, bool bInWin32Native=true, bool bInX=true, bool bRequired=false)
void GenerateBuilderText (MISTRING &code, const MISTRING &name, const MISTRINGLIST &ParamList)
RESTRICTIONGetRestrictions ()
void Init (const char *ClassName, const char *BaseClassName=0, int CreateDate=0)
void SetConstructor (void *(*constructor)(void *data, CONTEXT *context, CLASS *smlclass), int size=0)
void SetCopyConstructor (void *(*copyconstructor)(void *data, CONTEXT *context, CLASS *smlclass, void *))
void SetDeprecated ()
void SetDestructor (void *(*destructor)(void *data, CONTEXT *context, CLASS *smlclass))
void SetGenerateBuilderTextFunc (void(*GenerateBuilderTextFunc)(MISTRING &code, const MISTRING &name, const MISTRINGLIST &ParamList))
void SetNoWin32Native ()
void SetSize (int size)

Static Public Member Functions

static const CLASSMEMBERFindMember (const char *ClassName, const char *MemberName)

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 SML::AUTOCLASS 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 SML::AUTOCLASS_NEW_T<FOOBAR> s_AutoClass(&FOOBAR::SetupSMLClass, SML::CONTEXTTYPE_SML);

 // [ static method of FOOBAR ]
 void FOOBAR::SetupSMLClass (
      ) {
      typedef void (FOOBAR::*VOIDMETHOD)();
      s_AutoClass.Init("FOOBAR", NULL);

      // Parametes for a method that takes one numeric parameter named "enabled"
      static SML::PARM PARMS_SetEnabled[] = {
         { "enabled", STYPE_Num },
         { 0 }
         };

      s_AutoClass.AddMethod("IsEnabled",  SIG_b,   (VOIDMETHOD)&FOOBAR::IsEnabled,  NULL);
      s_AutoClass.AddMethod("SetEnabled", SIG_v_b, (VOIDMETHOD)&FOOBAR::SetEnabled, PARMS_SetEnabled);
      s_AutoClass.AddMethod("SetFocus",   SIG_v,   (VOIDMETHOD)&FOOBAR::SetFocus,   NULL);
      }

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


Constructor & Destructor Documentation

DEPRECATED SML::AUTOCLASS::AUTOCLASS ( void(*)()  SetupFunc,
CONTEXTTYPE  ContextTypesToAllow,
CONTEXTTYPE  ContextTypesToDisallow = CONTEXTTYPE_NONE 
) [inline]

Constructor.

Every SML::AUTOCLASS should have one static instance. When this instance is constructed, it registers the class so that any SML::CONTEXT created will know about it.

Parameters:
ContextTypesToAllow Function to call to setup this class. Normally a static method of the class we're representing SML::CONTEXTTYPEs to install this class for
ContextTypesToDisallow SML::CONTEXTTYPEs to NOT install this class for
SML::AUTOCLASS::AUTOCLASS ( void(*)()  SetupFunc  )  [inline]

Constructor.

Every SML::AUTOCLASS should have one static instance. When this instance is constructed, it registers the class so that any SML::CONTEXT created will know about it.

Parameters:
SetupFunc Function to call to setup this class. Normally a static method of the class we're representing
virtual SML::AUTOCLASS::~AUTOCLASS (  )  [virtual]

Destructor.


Member Function Documentation

void SML::AUTOCLASS::AddMember ( const CLASSMEMBER member  ) 

Add a single SML::CLASSMEMBER to the class.

This should only be used for members, not methods.

void SML::AUTOCLASS::AddMembers ( const CLASSMEMBER members  ) 

Add an array of SML::CLASSMEMBERs.

The last entry must be blank to single the end of the array. This should only be used for members, not methods.

void SML::AUTOCLASS::AddMethodOld ( const char *  name,
double(*)(int, ARG *, UINT8 *, CONTEXT *)  func,
PARM parms,
int  CreateDate = 0,
int  ModDate = 0,
bool  bInWin32Native = true,
bool  bInX = true,
bool  bRequired = false 
)

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

Parameters:
name Method name
func Pointer to function
parms Parameter list (can be NULL if none needed)
CreateDate No longer necessary
ModDate No longer necessary
bInWin32Native Pass false if the method does not exist in Win32Native builds
bInX Pass false if the method does not exist in X builds
bRequired Set to true to mark method as required
void SML::AUTOCLASS::AddMethodOld ( const char *  name,
STRING *(*)(int, ARG *, UINT8 *, CONTEXT *)  func,
PARM parms,
int  CreateDate = 0,
int  ModDate = 0,
bool  bInWin32Native = true,
bool  bInX = true,
bool  bRequired = false 
)

Add an old-style method (returning SML::STRING).

Parameters:
name Method name
func Pointer to function
parms Parameter list (can be NULL if none needed)
CreateDate No longer necessary
ModDate No longer necessary
bInWin32Native Pass false if the method does not exist in Win32Native builds
bInX Pass false if the method does not exist in X builds
bRequired Set to true to mark method as required
void SML::AUTOCLASS::AddMethodOld ( const char *  name,
void(*)(int, ARG *, UINT8 *, CONTEXT *)  func,
PARM parms,
int  CreateDate = 0,
int  ModDate = 0,
bool  bInWin32Native = true,
bool  bInX = true,
bool  bRequired = false 
)

Add an old-style method (returning void).

Parameters:
name Method name
func Pointer to function
parms Parameter list (can be NULL if none needed)
CreateDate No longer necessary
ModDate No longer necessary
bInWin32Native Pass false if the method does not exist in Win32Native builds
bInX Pass false if the method does not exist in X builds
bRequired Set to true to mark method as required
void SML::AUTOCLASS::AddMethodOld ( const char *  name,
const char *  RetClass,
bool  bReturnIsAllocated,
void *(*)(int, ARG *, UINT8 *, CONTEXT *)  func,
PARM parms,
int  CreateDate = 0,
int  ModDate = 0,
bool  bInWin32Native = true,
bool  bInX = true,
bool  bRequired = false 
)

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

Parameters:
name Name of the method
RetClass Name of the class returned (use SMLCLASSNAME macros defined in sml.h if possible)
bReturnIsAllocated Pass true if the return value is allocated so SML will know to free it. Pass false if SML should not free the reutrn value
func Pointer to function
parms Parameters (can be NULL if none needed)
CreateDate No longer necessary
ModDate No longer necessary
bInWin32Native Pass false if the method does not exist in Win32Native builds
bInX Pass false if the method does not exist in X builds
bRequired Set to true to mark method as required
void SML::AUTOCLASS::AddMethodOld ( const char *  name,
const char *  RetClass,
CLASSHASH *(*)(int, ARG *, UINT8 *, CONTEXT *)  func,
PARM parms,
int  CreateDate = 0,
int  ModDate = 0,
bool  bInWin32Native = true,
bool  bInX = true,
bool  bReturnIsAllocated = true,
bool  bRequired = false 
)

Add an old-style method (returning an SML::HASH* (allocated)) This function can return an SML::HASH (which acts like an array) of classes.

Parameters:
name Method name
RetClass Name of the class held in the SML::HASH (use SMLCLASSNAME macros defined in sml.h if possible)
parms Parameter list (can be NULL if none needed)
CreateDate No longer necessary
ModDate No longer necessary
bInWin32Native Pass false if the method does not exist in Win32Native builds
bInX Pass false if the method does not exist in X builds
bReturnIsAllocated Pass false if the hash should not be freed
bRequired Set to true to mark method as required
void SML::AUTOCLASS::AddMethodOldCB ( const char *  name,
void(*)(int, ARG *, UINT8 *, CONTEXT *)  func,
PARM parms,
int  CreateDate = 0,
int  ModDate = 0,
bool  bInWin32Native = true,
bool  bInX = true,
bool  bRequired = false 
)

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). This allows the documentation to document the callback's prototype.

Parameters:
name Method name
func Pointer to function
parms Parameter list (can be NULL if none needed)
CreateDate No longer necessary
ModDate No longer necessary
bInWin32Native Pass false if the method does not exist in Win32Native builds
bInX Pass false if the method does not exist in X builds
bRequired Set to true to mark method as required
void SML::AUTOCLASS::AddMethodOldCB ( const char *  name,
const char *  RetClass,
bool  bReturnIsAllocated,
void *(*)(int, ARG *, UINT8 *, CONTEXT *)  func,
PARM parms,
int  CreateDate = 0,
int  ModDate = 0,
bool  bInWin32Native = true,
bool  bInX = true,
bool  bRequired = false 
)

Add an old-style method that contains a callback(returning void*).

Parameters:
name Name of the method
RetClass Name of the class returned (use SMLCLASSNAME macros defined in sml.h if possible)
bReturnIsAllocated Pass true if the return value is allocated so SML will know to free it. Pass false if SML should not free the reutrn value
func Pointer to function
parms Parameters (can be NULL if none needed)
CreateDate No longer necessary
ModDate No longer necessary
bInWin32Native Pass false if the method does not exist in Win32Native builds
bInX Pass false if the method does not exist in X builds
bRequired Set to true to mark method as required
static const CLASSMEMBER* SML::AUTOCLASS::FindMember ( const char *  ClassName,
const char *  MemberName 
) [static]
void SML::AUTOCLASS::GenerateBuilderText ( MISTRING code,
const MISTRING name,
const MISTRINGLIST ParamList 
) [inline]

Called to create SMLBuilder text for class.

RESTRICTION& SML::AUTOCLASS::GetRestrictions (  )  [inline]

Get a reference to the class's restrictions This allows you to modify them.

void SML::AUTOCLASS::Init ( const char *  ClassName,
const char *  BaseClassName = 0,
int  CreateDate = 0 
)

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)
void SML::AUTOCLASS::SetConstructor ( void *(*)(void *data, CONTEXT *context, CLASS *smlclass)  constructor,
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.

This method is normally only called by the derived templates.

void SML::AUTOCLASS::SetCopyConstructor ( void *(*)(void *data, CONTEXT *context, CLASS *smlclass, void *)  copyconstructor  ) 

Set the copy constructor Normally only called by the derived templates.

void SML::AUTOCLASS::SetDeprecated (  )  [inline]

Set the class as "deprecated".

void SML::AUTOCLASS::SetDestructor ( void *(*)(void *data, CONTEXT *context, CLASS *smlclass)  destructor  ) 
void SML::AUTOCLASS::SetGenerateBuilderTextFunc ( void(*)(MISTRING &code, const MISTRING &name, const MISTRINGLIST &ParamList)  GenerateBuilderTextFunc  ) 

Called to create SMLBuilder code for class.

void SML::AUTOCLASS::SetNoWin32Native (  )  [inline]

Indicate that the class does not exist in WIN32_NATIVE builds.

This should be called in the Setup method on the X build if the class does not exist for WIN32_NATIVE builds. This is used to document this fact in the documentation when the user is running under X.

void SML::AUTOCLASS::SetSize ( int  size  )  [inline]

Set the size of an instance of this class.

SML uses this when storing arrays of classes to determine if it can store them like a SIMPLE_ARRAY<> or if it needs to store an array of pointers to individually allocated instances.


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

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