PikaScript
Public Member Functions | List of all members
Pika::Script< Config >::Variables Class Referenceabstract

Variables is an abstract base class which implements the interface to the variable space that a Frame works on. More...

#include <PikaScript.h>

Inheritance diagram for Pika::Script< Config >::Variables:
Inheritance graph
[legend]

Public Member Functions

virtual bool lookup (const String &symbol, Value &result)=0
 Lookup symbol. More...
 
virtual bool assign (const String &symbol, const Value &value)=0
 Assign value to symbol and return true if the assignment succeeded. More...
 
virtual bool erase (const String &symbol)=0
 Erase symbol. Return true if the symbol existed and was successfully erased.
 
virtual void list (const String &key, VarList &list)=0
 Iterate all symbols that begins with key and push back names and values to list. More...
 
virtual NativelookupNative (const String &identifier)=0
 Lookup the native function (or object) with identifier. More...
 
virtual bool assignNative (const String &identifier, Native *native)=0
 Assign the native function (or object) native to identifier, replacing any already existing definition. More...
 
virtual ~Variables ()
 Destructor. More...
 
virtual bool lookup (const String &symbol, Value &result)=0
 Lookup symbol. More...
 
virtual bool assign (const String &symbol, const Value &value)=0
 Assign value to symbol and return true if the assignment succeeded. More...
 
virtual bool erase (const String &symbol)=0
 Erase symbol. Return true if the symbol existed and was successfully erased.
 
virtual void list (const String &key, VarList &list)=0
 Iterate all symbols that begins with key and push back names and values to list. More...
 
virtual NativelookupNative (const String &identifier)=0
 Lookup the native function (or object) with identifier. More...
 
virtual bool assignNative (const String &identifier, Native *native)=0
 Assign the native function (or object) native to identifier, replacing any already existing definition. More...
 
virtual ~Variables ()
 Destructor. More...
 

Detailed Description

template<class Config>
class Pika::Script< Config >::Variables

Variables is an abstract base class which implements the interface to the variable space that a Frame works on.

In the configuration meta-class class (Script::Config) two typedefs exist that determines which sub-classes of Variables should be used for the "root frame" (= Globals) and subsequently for the "sub-frames" (= Locals).

A standard Variables class is supplied in this header file (STLVariables). Custom sub-classes are useful for optimization and special integration needs.

Notice that the separation of Frames and Variables makes it possible to have more than one Frame referencing the same variable space. This could be useful for example in a threaded situation where several concurrent threads running PikaScript should share global variables. In this case each thread should still have a distinct "root frame" and you need to implement a sub-class of Variables that accesses its data in a thread-safe manner.

Definition at line 291 of file PikaScript.h.

Constructor & Destructor Documentation

template<class Config >
TMPL Pika::Script< Config >::Variables::~Variables ( )
virtual

Destructor.

Don't forget to delete all registered natives.

Definition at line 1058 of file PikaScriptImpl.h.

template<class Config >
virtual Pika::Script< Config >::Variables::~Variables ( )
virtual

Destructor.

Don't forget to delete all registered natives.

Member Function Documentation

template<class Config >
virtual bool Pika::Script< Config >::Variables::assign ( const String symbol,
const Value value 
)
pure virtual

Assign value to symbol and return true if the assignment succeeded.

If false is returned, the calling Frame::set() will throw an exception.

template<class Config >
virtual bool Pika::Script< Config >::Variables::assign ( const String symbol,
const Value value 
)
pure virtual

Assign value to symbol and return true if the assignment succeeded.

If false is returned, the calling Frame::set() will throw an exception.

template<class Config >
virtual bool Pika::Script< Config >::Variables::assignNative ( const String identifier,
Native native 
)
pure virtual

Assign the native function (or object) native to identifier, replacing any already existing definition.

Once assigned, the native is considered "owned" by this variable space. This class is responsible for deleting its natives on destruction and also delete the existing definition when an identifier is being reassigned.

template<class Config >
virtual bool Pika::Script< Config >::Variables::assignNative ( const String identifier,
Native native 
)
pure virtual

Assign the native function (or object) native to identifier, replacing any already existing definition.

Once assigned, the native is considered "owned" by this variable space. This class is responsible for deleting its natives on destruction and also delete the existing definition when an identifier is being reassigned.

template<class Config >
virtual void Pika::Script< Config >::Variables::list ( const String key,
VarList &  list 
)
pure virtual

Iterate all symbols that begins with key and push back names and values to list.

There are no requirements on the order of the listed elements. You should not erase the list at the beginning.

template<class Config >
virtual void Pika::Script< Config >::Variables::list ( const String key,
VarList &  list 
)
pure virtual

Iterate all symbols that begins with key and push back names and values to list.

There are no requirements on the order of the listed elements. You should not erase the list at the beginning.

template<class Config >
virtual bool Pika::Script< Config >::Variables::lookup ( const String symbol,
Value result 
)
pure virtual

Lookup symbol.

If found, store the found value in result and return true, otherwise return false.

template<class Config >
virtual bool Pika::Script< Config >::Variables::lookup ( const String symbol,
Value result 
)
pure virtual

Lookup symbol.

If found, store the found value in result and return true, otherwise return false.

template<class Config >
virtual Native* Pika::Script< Config >::Variables::lookupNative ( const String identifier)
pure virtual

Lookup the native function (or object) with identifier.

Return 0 if the native could not be found. In this case, the caller will throw an exception.

template<class Config >
virtual Native* Pika::Script< Config >::Variables::lookupNative ( const String identifier)
pure virtual

Lookup the native function (or object) with identifier.

Return 0 if the native could not be found. In this case, the caller will throw an exception.


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