#include <TraCIServerAPI_Route.h>
Definition at line 43 of file TraCIServerAPI_Route.h.
Static Public Member Functions | |
| static bool | processGet (tcpip::Storage &inputStorage, tcpip::Storage &outputStorage, bool withStatus=true) throw (traci::TraCIException) |
| Processes a get value command (Command 0xa6: Get Route Variable). | |
| static bool | processSet (tcpip::Storage &inputStorage, tcpip::Storage &outputStorage) throw (traci::TraCIException) |
| Processes a set value command (Command 0xc6: Change Route State). | |
Private Member Functions | |
| TraCIServerAPI_Route & | operator= (const TraCIServerAPI_Route &s) |
| invalidated assignment operator | |
| TraCIServerAPI_Route (const TraCIServerAPI_Route &s) | |
| invalidated copy constructor | |
| TraCIServerAPI_Route::TraCIServerAPI_Route | ( | const TraCIServerAPI_Route & | s | ) | [private] |
invalidated copy constructor
| TraCIServerAPI_Route& TraCIServerAPI_Route::operator= | ( | const TraCIServerAPI_Route & | s | ) | [private] |
invalidated assignment operator
| bool TraCIServerAPI_Route::processGet | ( | tcpip::Storage & | inputStorage, | |
| tcpip::Storage & | outputStorage, | |||
| bool | withStatus = true | |||
| ) | throw (traci::TraCIException) [static] |
Processes a get value command (Command 0xa6: Get Route Variable).
| [in] | inputStorage | The storage to read the command from |
| [out] | outputStorage | The storage to write the result to |
| [in] | withStatus | Whether the status message shall be written (not in subscription) |
Definition at line 54 of file TraCIServerAPI_Route.cpp.
References MSRoute::begin(), CMD_GET_ROUTE_VARIABLE, MSRoute::dictionary(), MSRoute::end(), ID_LIST, MSRoute::insertIDs(), RESPONSE_GET_ROUTE_VARIABLE, RTYPE_ERR, RTYPE_OK, tcpip::Storage::size(), MSRoute::size(), TYPE_STRINGLIST, VAR_EDGES, tcpip::Storage::writeInt(), TraCIServerAPIHelper::writeStatusCmd(), tcpip::Storage::writeString(), tcpip::Storage::writeStringList(), and tcpip::Storage::writeUnsignedByte().
Referenced by traci::TraCIServer::dispatchCommand(), and traci::TraCIServer::processSingleSubscription().
00056 { 00057 std::string warning = ""; // additional description for response 00058 // variable & id 00059 int variable = inputStorage.readUnsignedByte(); 00060 std::string id = inputStorage.readString(); 00061 // check variable 00062 if (variable!=ID_LIST&&variable!=VAR_EDGES) { 00063 TraCIServerAPIHelper::writeStatusCmd(CMD_GET_ROUTE_VARIABLE, RTYPE_ERR, "Get Route Variable: unsupported variable specified", outputStorage); 00064 return false; 00065 } 00066 // begin response building 00067 Storage tempMsg; 00068 // response-code, variableID, objectID 00069 tempMsg.writeUnsignedByte(RESPONSE_GET_ROUTE_VARIABLE); 00070 tempMsg.writeUnsignedByte(variable); 00071 tempMsg.writeString(id); 00072 // process request 00073 if (variable==ID_LIST) { 00074 std::vector<std::string> ids; 00075 MSRoute::insertIDs(ids); 00076 tempMsg.writeUnsignedByte(TYPE_STRINGLIST); 00077 tempMsg.writeStringList(ids); 00078 } else { 00079 const MSRoute *r = MSRoute::dictionary(id); 00080 if (r==0) { 00081 TraCIServerAPIHelper::writeStatusCmd(CMD_GET_ROUTE_VARIABLE, RTYPE_ERR, "Route '" + id + "' is not known", outputStorage); 00082 return false; 00083 } 00084 switch (variable) { 00085 case VAR_EDGES: 00086 tempMsg.writeUnsignedByte(TYPE_STRINGLIST); 00087 tempMsg.writeInt(r->size()); 00088 for (MSRouteIterator i=r->begin(); i!=r->end(); ++i) { 00089 tempMsg.writeString((*i)->getID()); 00090 } 00091 break; 00092 default: 00093 break; 00094 } 00095 } 00096 if (withStatus) { 00097 TraCIServerAPIHelper::writeStatusCmd(CMD_GET_ROUTE_VARIABLE, RTYPE_OK, warning, outputStorage); 00098 } 00099 // send response 00100 outputStorage.writeUnsignedByte(0); // command length -> extended 00101 outputStorage.writeInt(1 + 4 + tempMsg.size()); 00102 outputStorage.writeStorage(tempMsg); 00103 return true; 00104 }
| bool TraCIServerAPI_Route::processSet | ( | tcpip::Storage & | inputStorage, | |
| tcpip::Storage & | outputStorage | |||
| ) | throw (traci::TraCIException) [static] |
Processes a set value command (Command 0xc6: Change Route State).
| [in] | inputStorage | The storage to read the command from |
| [out] | outputStorage | The storage to write the result to |
Definition at line 108 of file TraCIServerAPI_Route.cpp.
1.5.6