Transit Planner
1.0
An experiment on transfer patterns robustness
|
00001 // Copyright 2011: Eugen Sawin, Philip Stahl, Jonas Sternisko 00002 #ifndef SRC_COMMAND_H_ 00003 #define SRC_COMMAND_H_ 00004 00005 #include <boost/asio.hpp> 00006 #include <boost/shared_ptr.hpp> 00007 #include <string> 00008 #include <map> 00009 #include <sstream> 00010 #include "./Logger.h" 00011 #include "./Server.h" 00012 #include "./Statistics.h" 00013 00014 using std::string; 00015 using std::map; 00016 using boost::asio::ip::tcp; 00017 using boost::shared_ptr; 00018 00019 struct Query { 00020 int dep; 00021 int dest; 00022 string time; 00023 }; 00024 00025 class Command { 00026 public: 00027 virtual ~Command() {} 00028 virtual vector<string> operator()(Server& server, // NOLINT 00029 const StrStrMap& args, 00030 Logger& log) = 0; 00031 static void execute(Server& server, // NOLINT 00032 shared_ptr<tcp::socket> socket, // NOLINT 00033 const string& com, const StrStrMap& args, 00034 Logger& log); 00035 static void send(shared_ptr<tcp::socket> socket, 00036 const string& msg, Logger& log); 00037 // Returns a vector of random queries. Dep and destStops are ranging from zero 00038 // to numStops, times from 0:00:00 to 23:59:00 at 1st of may 2012. 00039 static vector<Query> getRandQueries(int numQueries, int numStops, int seed); 00040 00041 // Computes the shortest path between dep and dest stop @ time 00042 static void dijkstraQuery(const TransitNetwork& network, const HubSet* hubs, 00043 const int dep, const int time, const int dest, 00044 QueryResult* resultPtr); 00045 }; 00046 00047 class WebCommand : public Command { 00048 vector<string> operator()(Server& server, // NOLINT 00049 const StrStrMap& args, Logger& log); 00050 string contentType(const string& doc) const; 00051 }; 00052 00053 class SelectStop : public Command { 00054 vector<string> operator()(Server& server, // NOLINT 00055 const StrStrMap& args, Logger& log); 00056 }; 00057 00058 class SelectStopById : public Command { 00059 vector<string> operator()(Server& server, // NOLINT 00060 const StrStrMap& args, Logger& log); 00061 }; 00062 00063 class LoadNetwork : public Command { 00064 vector<string> operator()(Server& server, // NOLINT 00065 const StrStrMap& args, Logger& log); 00066 }; 00067 00068 class ListNetworks : public Command { 00069 vector<string> operator()(Server& server, // NOLINT 00070 const StrStrMap& args, Logger& log); 00071 }; 00072 00073 class FindRoute : public Command { 00074 vector<string> operator()(Server& server, // NOLINT 00075 const StrStrMap& args, Logger& log); 00076 }; 00077 00078 class Test : public Command { 00079 vector<string> operator()(Server& server, // NOLINT 00080 const StrStrMap& args, Logger& serverLog); 00081 00082 boost::shared_mutex _mutex; 00083 int _numPathsDi; 00084 int _numPathsTp; 00085 int _numReachedDi; 00086 int _numReachedTp; 00087 int _numSubset; 00088 int _numAlmostSubset; 00089 int _numFailed; 00090 int _numInvalid; 00091 int _numTpInvalid; 00092 Logger* _serverLog; 00093 Logger* _expLog; 00094 Server* _server; 00095 }; 00096 00097 class GenerateScenario : public Command { 00098 vector<string> operator()(Server& server, // NOLINT 00099 const StrStrMap& args, Logger& log); 00100 }; 00101 00102 class PlotSeedStops : public Command { 00103 vector<string> operator()(Server& server, // NOLINT 00104 const StrStrMap& args, Logger& log); 00105 }; 00106 00107 class ListHubs : public Command { 00108 vector<string> operator()(Server& server, // NOLINT 00109 const StrStrMap& args, Logger& log); 00110 }; 00111 00112 class GetGeoInfo : public Command { 00113 vector<string> operator()(Server& server, // NOLINT 00114 const StrStrMap& args, Logger& log); 00115 }; 00116 00117 #endif // SRC_COMMAND_H_