ReFRACtor
FullPhysics::LuaState Class Reference

This is a light wrapper around the lua_state object. More...

#include <lua_state.h>

+ Inheritance diagram for FullPhysics::LuaState:
+ Collaboration diagram for FullPhysics::LuaState:

Public Member Functions

 LuaState (const std::string &Dir_name="./")
 Create a new instance of Lua. More...
 
virtual ~LuaState ()
 
const std::string & base_dir_name () const
 Base directory that we use when running Lua. More...
 
void do_file (const std::string &Fname)
 Load the given file and execute it. More...
 
LuabindObject globals ()
 Globals table. More...
 
lua_State * lua_state ()
 Lua state pointer. More...
 
void print (std::ostream &Os) const
 
std::string print_to_string () const
 Print to string. More...
 
LuabindObject registry ()
 Registery table. More...
 
void run (const std::string &S)
 Run the given Lua code. More...
 

Static Public Member Functions

static boost::shared_ptr< LuaStateload_file (const std::string &Fname)
 Create a new LuaState, and then open the given file. More...
 

Detailed Description

This is a light wrapper around the lua_state object.

This maintains the lifetime of this object, as well as other house keeping chores.

Definition at line 25 of file lua_state.h.

Constructor & Destructor Documentation

◆ LuaState()

LuaState::LuaState ( const std::string &  Dir_name = "./")

Create a new instance of Lua.

Because it is often convenient to do so, you can optionally give a directory that the we will change to before running Lua code. This allows things like configuration file to use relative paths from where the configuration file is located rather than where we are running from.

Definition at line 70 of file lua_state.cc.

◆ ~LuaState()

virtual FullPhysics::LuaState::~LuaState ( )
inlinevirtual

Definition at line 28 of file lua_state.h.

Member Function Documentation

◆ base_dir_name()

const std::string& FullPhysics::LuaState::base_dir_name ( ) const
inline

Base directory that we use when running Lua.

Definition at line 41 of file lua_state.h.

◆ do_file()

void LuaState::do_file ( const std::string &  Fname)

Load the given file and execute it.

Definition at line 90 of file lua_state.cc.

◆ globals()

LuabindObject LuaState::globals ( )

Globals table.

Definition at line 12 of file lua_state.cc.

◆ load_file()

boost::shared_ptr< LuaState > LuaState::load_file ( const std::string &  Fname)
static

Create a new LuaState, and then open the given file.

We run this in the same directory as the given file, so for example a configuration file can use relative paths for various files that will be relative to the location of the configuration file, not the directory we happen to be running in.

Definition at line 39 of file lua_state.cc.

◆ lua_state()

lua_State* FullPhysics::LuaState::lua_state ( )
inline

Lua state pointer.

You can use this to do things with luabind (or directly with Lua) that this class doesn't already support.

Definition at line 47 of file lua_state.h.

◆ print()

void FullPhysics::LuaState::print ( std::ostream &  Os) const
inline

Definition at line 29 of file lua_state.h.

◆ print_to_string()

std::string FullPhysics::Printable< LuaState >::print_to_string ( ) const
inlineinherited

Print to string.

This is primarily useful for SWIG wrappers to this class, e.g. a to_s method in ruby.

Definition at line 31 of file printable.h.

◆ registry()

LuabindObject LuaState::registry ( )

Registery table.

Definition at line 23 of file lua_state.cc.

◆ run()

void LuaState::run ( const std::string &  S)

Run the given Lua code.

Definition at line 107 of file lua_state.cc.


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

Copyright © 2017, California Institute of Technology.
ALL RIGHTS RESERVED.
U.S. Government Sponsorship acknowledged.
Generated Fri Aug 24 2018 15:44:13