00001
00017 #define DISPATCHER_H
00018
00019 #include <stdlib.h>
00020 #include <stdio.h>
00021 #include <vector>
00022 #include <map>
00023 #include <string>
00024 #include <queue>
00025
00026 #ifndef BOOST_SHARED_PTR_HPP_INCLUDED
00027 #include <boost/shared_ptr.hpp>
00028 #endif
00029
00030
00031 class StateControl;
00032 class MessageController;
00033
00034 using namespace boost;
00035 using namespace std;
00036
00042 class Dispatcher{
00043
00044 public:
00045 Dispatcher();
00046 ~Dispatcher();
00053 bool proccessMessageFromMC(shared_ptr< vector< shared_ptr< string > > > msg);
00059 bool dispatchMessage();
00069 bool setSpdInSim(int id, double speed, double ts, double te);
00079 bool order(int Ris, int Rid, double ts, double tf);
00087 bool communicationMode(int cMode, string filename);
00096 bool communicationMode(int cMode, string thisName, string thatName);
00103 bool setTimeFlow(double flowFactor);
00107 double getTime();
00111 double getTimeFlow();
00112
00113 private:
00114 StateControl* world;
00115 MessageController* mc;
00116
00117 shared_ptr< queue< shared_ptr< vector< shared_ptr< string > > > > > parseQ;
00118 pthread_mutex_t* mutex_ptr;
00119 pthread_cond_t* cond_ptr;
00120
00121
00122
00123
00124
00125 bool drvparse(shared_ptr< vector< shared_ptr< string > > >);
00126 bool loadparse(shared_ptr< vector< shared_ptr< string > > >);
00127 bool unloadparse(shared_ptr< vector< shared_ptr< string > > >);
00128 bool setspdparse(shared_ptr< vector< shared_ptr< string > > >);
00129 bool locationparse(shared_ptr< vector< shared_ptr< string > > >);
00130 bool trnewparse(shared_ptr< vector< shared_ptr< string > > >);
00131 bool trdelparse(shared_ptr< vector< shared_ptr< string > > >);
00132 bool newcargparse(shared_ptr< vector< shared_ptr< string > > >);
00133 bool rmcargparse(shared_ptr< vector< shared_ptr< string > > >);
00134 bool arcparse(shared_ptr< vector< shared_ptr< string > > >);
00135 };
00136
00137