Main Page | Class List | File List | Class Members

CLUAInstance Class Reference

#include <luainstance.h>

List of all members.

Public Member Functions

 ~CLUAInstance ()
void runScript (std::string fileName)
void callFunction (const char *func, const char *sig,...)
void callFunctionError (const char *fmt,...)

Static Public Member Functions

static CLUAInstancegetInstance ()

Protected Member Functions

 CLUAInstance ()


Detailed Description

This is the singleton accessor to a LUA intepretter object.

This class both

Sample usage looks like this:

  CLUAInstance *lua = CLUAInstance::getInstance();
  lua->runScript( "lua.lua" );
  lua->callFunction( "test", "si>i", "string parameter", 2, &ret );
  printf("Function returned: %d\n", ret );

Author:
Steve Kemp http://www.steve.org.uk/
Version:
Id
luainstance.h,v 1.8 2005/10/20 15:51:44 steve Exp


Constructor & Destructor Documentation

CLUAInstance::~CLUAInstance  ) 
 

Destructor.

CLUAInstance::CLUAInstance  )  [protected]
 

Constructor - this is protected as this class uses the singleton design pattern.


Member Function Documentation

void CLUAInstance::callFunction const char *  func,
const char *  sig,
  ...
 

Call a LUA function from C++.

Here is an example of using this function to call a script function:

  callFunction("f", "dd>d", x, y, &z);

This calls the function "f" with two "double" arguments, returning a double.

Parameters:
func The name of the function to call.
sig A format string of input and output options with a ">" between them.
See also:
callFunctionError
Author:
http://www.lua.org/pil/25.3.html

void CLUAInstance::callFunctionError const char *  fmt,
  ...
 

This is an error-handling routine invoked if "callFunction" fails.

Parameters:
fmt The format string containing the error text.
See also:
callFunction

CLUAInstance * CLUAInstance::getInstance  )  [static]
 

This class is an example of the Singleton Design Pattern, so there is only one instance of this object ever in use.

Returns:
The single CLUAInstance object.

void CLUAInstance::runScript std::string  fileName  ) 
 

Run the given script.

Parameters:
fileName The name of the LUA script to load and execute.


The documentation for this class was generated from the following files:
Generated on Tue Oct 25 23:04:38 2005 for fortress by  doxygen 1.4.2