syBR::Game::ScriptManager Class Reference

Script manager class. More...

#include <ScriptManager.hpp>

List of all members.

Public Member Functions

 ScriptManager (Core::Logger *pLogger)
 Constructor.
 ~ScriptManager ()
 Destructor.
bool initialize ()
 Initialize script manager.
void terminate ()
 Terminate script manager.
const bool hasLogger () const
 Indicate if a logger is used for all script-related stuff.
Core::LoggergetLogger ()
 Get the logger used for all script-related stuff.
HSQUIRRELVM getSquirrelVM ()
 Get the Squirrel virtual machine.
bool load (const std::string &filename)
 Load a script from a file.
bool unload (const std::string &filename)
 Unload a script.
bool execute (const std::string &filename)
 Execute a previously loaded script.

Static Private Member Functions

static void squirrelCompilerError (HSQUIRRELVM squirrel_vm, const char *description, const char *source, int line, int column)
 Squirrel compiler error handler.
static int squirrelError (HSQUIRRELVM squirrel_vm)
 Squirrel error handler.
static void squirrelPrint (HSQUIRRELVM squirrel_vm, const char *format,...)
 Squirrel print handler.

Private Attributes

const unsigned int m_squirrel_stack_size
 Squirrel stack size.
Core::Loggerm_pLogger
 Pointer to the logger to be used.
HSQUIRRELVM m_squirrelVM
 Squirrel virtual machine.
std::map
< std::string,
HSQOBJECT > 
m_mapScripts
 Scripts.

Friends

class ScriptExposer


Detailed Description

Script manager class.

It is the object responsible for managing all the scripts. Use it to (un)load scripts and then executing them.


Constructor & Destructor Documentation

syBR::Game::ScriptManager::ScriptManager ( Core::Logger pLogger  ) 

Constructor.

Parameters:
pLogger Pointer to the instance of the logger to use

syBR::Game::ScriptManager::~ScriptManager (  ) 

Destructor.


Member Function Documentation

bool syBR::Game::ScriptManager::initialize (  ) 

Initialize script manager.

Returns:
One of these:
  • true in case of success
  • false otherwise

void syBR::Game::ScriptManager::terminate (  ) 

Terminate script manager.

const bool syBR::Game::ScriptManager::hasLogger (  )  const

Indicate if a logger is used for all script-related stuff.

Returns:
One of these:
  • true if a logger has been specified
  • false otherwise

Core::Logger * syBR::Game::ScriptManager::getLogger (  ) 

Get the logger used for all script-related stuff.

Returns:
Pointer to the logger instance

HSQUIRRELVM syBR::Game::ScriptManager::getSquirrelVM (  ) 

Get the Squirrel virtual machine.

Returns:
Handle to the Squirrel virtual machine

bool syBR::Game::ScriptManager::load ( const std::string &  filename  ) 

Load a script from a file.

Parameters:
filename Name of the script file to be loaded
Returns:
One of these:
  • true in case of success
  • false otherwise

bool syBR::Game::ScriptManager::unload ( const std::string &  filename  ) 

Unload a script.

Parameters:
filename Name of the script file to be unloaded
Returns:
One of these:
  • true in case of success
  • false otherwise

bool syBR::Game::ScriptManager::execute ( const std::string &  filename  ) 

Execute a previously loaded script.

Parameters:
filename Name of the script file to be executed
Returns:
One of these:
  • true in case of success
  • false otherwise

void syBR::Game::ScriptManager::squirrelCompilerError ( HSQUIRRELVM  squirrel_vm,
const char *  description,
const char *  source,
int  line,
int  column 
) [static, private]

Squirrel compiler error handler.

Parameters:
squirrel_vm Squirrel virtual machine
description Description of the error
source Compiler source (filename, buffer name...)
line Line of the error
column Column of the error

int syBR::Game::ScriptManager::squirrelError ( HSQUIRRELVM  squirrel_vm  )  [static, private]

Squirrel error handler.

Parameters:
squirrel_vm Squirrel virtual machine

void syBR::Game::ScriptManager::squirrelPrint ( HSQUIRRELVM  squirrel_vm,
const char *  format,
  ... 
) [static, private]

Squirrel print handler.

Parameters:
squirrel_vm Squirrel virtual machine
format Format of the string to display followed by its arguments
Todo:
Use a logger, and remove the iostream inclusion


Friends And Related Function Documentation

friend class ScriptExposer [friend]


Member Data Documentation

const unsigned int syBR::Game::ScriptManager::m_squirrel_stack_size [private]

Squirrel stack size.

Core::Logger* syBR::Game::ScriptManager::m_pLogger [private]

Pointer to the logger to be used.

HSQUIRRELVM syBR::Game::ScriptManager::m_squirrelVM [private]

Squirrel virtual machine.

std::map<std::string, HSQOBJECT> syBR::Game::ScriptManager::m_mapScripts [private]

Scripts.


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

Copyright © 2008 by Sebastien Frippiat
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License.
Last modified Tue Dec 30 17:57:34 2008