interpreter_hooks.h File Reference

Abstraction of the glue between the simulator's C++ implementation and the interpreter that will serve as the interactive and scripting component. More...

#include "interpreter_defs.h"
#include <string>
#include "config.h"
#include "Entity.h"
#include "Time.h"

Include dependency graph for interpreter_hooks.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ItemWrapper
 Simple structure to handle object interactions between the harness and the interpreter. More...

Functions

unsigned char verbosity ()
 Report the verbosity level of the simulator.
Functions Callable from Python
void seed_prng (unsigned long int s)
 Seed the random number generator.
float prng ()
 Generate a pseudo-random number uniformly in the range [0,1).
Define Interpreter Hooks for Python
void add_entity (Entity *e)
 Register an Entity with the Registry.
unsigned int num_entities ()
 Get the number of Entitys being tracked by the simulator.
InterpreterItem get_entity (unsigned int i)
 Get a specific Entity from the simulator.
ItemWrapper resolve_symbol (InterpreterItem e)
 Given a reference to an Entity in the interpreter, return the corresponding C++ object.
long int parse_long (const InterpreterItem l)
 Given an integer (normal or long) in the interpreter's representation, parse it into a long int.
double parse_double (const InterpreterItem d)
 Given a real number in the interpreter's representation, parse it into a double.
std::string parse_string (const InterpreterItem s)
 Given a string in the interpreter's representation, parse it into a C++ string.
Time parse_time (const InterpreterItem t)
 Given a time in the interpreter's representation, parse into a Time object.
InterpreterItem construct_string (const std::string &s)
 Given a string, convert it to the interpreter's representation.
InterpreterItem construct_double (double d)
 Given a double, convert it to the interpreter's representation.
InterpreterItem construct_long (long int l)
 Given a long integer, convert it to the interpreter's representation.
InterpreterItem construct_ulong (unsigned long int l)
 Given an unsigned long integer, convert it to the interpreter's representation.
InterpreterItem construct_list (Entity::ArgList &alist)
 Given a list of items, compose a list in the interpreter's representation.
InterpreterItem construct_boolean (bool b)
 Given a boolean, convert it to the interpreter's representation.
InterpreterItem construct_time (const Time &t)
 Given a Time, compose a corresponding list.
New Python Types
void clean_arglist (Entity::ArgList &alist)
 Perform any necessary clean-up for an argument list that will no longer be used.
void build_arglist (Entity::ArgList &alist, InterpreterItem i)
 Parse a reference from the interpreter into an appropriate list of arguments, also references from the interpreter.


Detailed Description

Abstraction of the glue between the simulator's C++ implementation and the interpreter that will serve as the interactive and scripting component.

A module implementing concrete Entitys will need to register those classes in its bootstrap routine. Registration is done through the add_entity() method, which takes a dummy instance of each Entity subclass.

In order to pass information from the interpreter to C++, an Entity accepts an argv-like list of stringified arguments. Since we can't produce meaningful string representations of objects, the interpreter will pass a string token to Entity::configure() or Entity::emit() instead of an actual representation of an Entity, and this can be resolved to a real object using the method resolve_symbol().

Definition in file interpreter_hooks.h.


Generated on Mon Mar 24 11:15:46 2008 for Pydtn Simulator by  doxygen 1.5.4