zoo_driver.h

Go to the documentation of this file.
00001 #ifndef _STAGE_ZOO_DRIVER_H
00002 #define _STAGE_ZOO_DRIVER_H
00003 
00004 #include "p_driver.h"
00005 #include <limits.h>
00006 #include <vector>
00007 #include <map>
00008 #include <sys/types.h>
00009 #include <stdio.h>
00010 #include "zoo.h"
00011 
00012 /* some forward declarations here */
00013 class ZooSpecies;
00014 class ZooController;
00015 class ZooDriver;
00016 class ZooReferee;
00017 
00018 /* for registering the driver */
00019 void ZooDriver_Register(DriverTable *);
00020 
00021 class ZooDriver : public Driver
00022 {
00023 public:
00024         ZooDriver(ConfigFile *cf, int section);
00025         ~ZooDriver();
00026 
00027         ZooSpecies *GetSpeciesByName(const char *);
00028 
00029         /* Player calls these */
00030         int Setup(void);
00031         int Shutdown(void);
00032         void Prepare(void);
00033 
00034         /* Functions for starting and stopping controllers */
00035         void Run(int);
00036         void Run(const char *);   // accepts a model name
00037         void RunAll(void);
00038         void Kill(int);
00039         void Kill(const char *);  // accepts a model name
00040         void KillAll(void);
00041 
00042         /* Model access functions.  Provide a variety of ways of getting a
00043          * variety of representations of a robot: a stg_model_t object, a string
00044          * holding the name, the index in a list kept by Zoo, or port. */
00045         int GetModelCount(void);
00046         const char *GetModelNameByIndex(int);
00047         const char *GetModelNameByPort(int);
00048         stg_model_t *GetModelByName(const char *);
00049         stg_model_t *GetModelByIndex(int);
00050         stg_model_t *GetModelByPort(int);
00051         int GetModelPortByName(const char *);
00052 
00053         /* Functions for storing and retrieving arbitrary score data */
00054         int GetScore(const char *, void *);
00055         int GetScoreSize(const char *);
00056         int SetScore(const char *, void *, size_t);
00057         int ClearScore(const char *);
00058         void SetScoreDrawCB(zooref_score_draw_t, void *userdata);
00059                 // for every species
00060 
00061         /* New interface for looking up robots */
00062         rmap_t *FindRobot(const char *modelName);
00063         rmap_t *FindRobot(int port);
00064         rmap_t *FindRobot(ZooController *);
00065         rmap_t *FindRobot(stg_model_t *);
00066 
00067 private:
00068         int species_count;
00069         ZooSpecies **species;
00070 
00071         int robot_count; /* could be model_count or port_count */
00072         rmap_t *robotMap; // port --> ZooController
00073         std::vector<const char *> modelList;
00074 
00075         void *zooref_handle; // for dynamically linked ref
00076         ZooReferee *referee;
00077 };
00078 
00079 #endif

Generated on Thu Dec 13 14:35:18 2007 for Stage by  doxygen 1.4.6