Worlds
[libstage API reference]


Data Structures

struct  stg_world_t

Functions

stg_world_tstg_world_create (stg_id_t id, const char *token, int sim_interval, int real_interval, double ppm, double width, double height)
stg_world_tstg_world_create_from_file (const char *worldfile_path)
void stg_world_destroy (stg_world_t *world)
stg_model_tstg_world_get_model (stg_world_t *world, stg_id_t mid)
void stg_world_load (stg_world_t *mod)
stg_model_tstg_world_model_name_lookup (stg_world_t *world, const char *name)
void stg_world_print (stg_world_t *world)
void stg_world_save (stg_world_t *mod)
void stg_world_set_interval_real (stg_world_t *world, unsigned int val)
void stg_world_set_interval_sim (stg_world_t *world, unsigned int val)
void stg_world_start (stg_world_t *world)
void stg_world_stop (stg_world_t *world)
int stg_world_update (stg_world_t *world, int sleepflag)

Detailed Description

Implements a world - a collection of models and a matrix.

Function Documentation

stg_world_t* stg_world_create ( stg_id_t  id,
const char *  token,
int  sim_interval,
int  real_interval,
double  ppm,
double  width,
double  height 
)

Create a new world, to be configured and populated manually. Usually this function is not used directly; use the function stg_world_create_from_file() to create a world based on a worldfile instead.

References _stg_disable_gui, FALSE, gui_world_create(), model_destroy_cb(), stg_init(), stg_matrix_create(), and TRUE.

Referenced by stg_world_create_from_file().

void stg_world_destroy ( stg_world_t world  ) 

Destroy a world and everything it contains

References gui_world_destroy(), PRINT_DEBUG1, and stg_matrix_destroy().

Referenced by world_destroy_cb().

stg_model_t* stg_world_get_model ( stg_world_t world,
stg_id_t  mid 
)

look up a pointer to a model in [world] from the model's unique ID [mid].

Referenced by stg_world_create_from_file().

void stg_world_load ( stg_world_t mod  ) 

configure the world by reading from the current world file

stg_model_t* stg_world_model_name_lookup ( stg_world_t world,
const char *  name 
)

look up a pointer to a model from from the model's name.

Referenced by StgDriver::LocateModel(), and InterfaceSimulation::ProcessMessage().

void stg_world_print ( stg_world_t world  ) 

print human-readable information about the world on stdout

References model_print_cb().

Referenced by world_print_cb().

void stg_world_save ( stg_world_t mod  ) 

save the state of the world to the current world file

References gui_save(), stg_model_save_cb(), and wf_save().

Referenced by gui_action_save().

void stg_world_set_interval_real ( stg_world_t world,
unsigned int  val 
)

Set the duration in milliseconds of each simulation update step

void stg_world_set_interval_sim ( stg_world_t world,
unsigned int  val 
)

Set the real time in intervals that Stage should attempt to take for each simulation update step. If Stage has too much computation to do, it might take longer than this.

void stg_world_start ( stg_world_t world  ) 

Start the world clock

References FALSE.

void stg_world_stop ( stg_world_t world  ) 

Stop the world clock

References TRUE.

int stg_world_update ( stg_world_t world,
int  sleepflag 
)

Run one simulation step in world [world]. If [sleepflag] is non-zero, and the simulation update takes less than one real-time step, the simulation will nanosleep() for a while to reduce CPU load. Returns 0 if all is well, or a positive error code.

References _stg_quit, gui_poll(), gui_world_update(), model_update_cb(), stg_quit_request(), and stg_timenow().

Referenced by StgDriver::Update().


Generated on Wed Jun 3 23:12:29 2009 for Stage by  doxygen 1.5.9