OverSim
StrategyRemoveCoords.cc
Go to the documentation of this file.
1 /*
2  * StrategyRemoveCoords.cc
3  *
4  * Created on: 17.05.2010
5  * Author: user
6  */
7 
8 #include "StrategyRemoveCoords.h"
9 #include <GlobalViewBuilder.h>
10 
12  lastSendCount = 0;
13 }
14 
16  // TODO Auto-generated destructor stub
17 }
18 
20 
21  SendAllStrategyCall* msg = new SendAllStrategyCall("sendAllStrategyCall");
22 
23  CoordDataContainer tmpCoordContainer;
24  coordinatesVector sendCoordsVector = getCombinedCoordsVector();
25 
26  processCoordinates(&sendCoordsVector);
27 
28  tmpCoordContainer.coordinatesVector = sendCoordsVector;
29 
30  lastSendCount = tmpCoordContainer.coordinatesVector.size();
31 
32  msg->setCoordData(tmpCoordContainer);
33  msg->setBitLength(REMOVERANDOMSTRATEGYCALL_L(msg));
34 
35  return msg;
36 
37 }
38 
40  std::string strategyMode = globalViewBuilder->parProxy("gvbStrategyRemoveCoordsMode").stdstringValue();
41 
42  if(strategyMode == "limitCoords") {
43  int coordLimit = globalViewBuilder->parProxy("gvbStrategyRemoveCoordsCoordsLimit");
44  removeCoordinatesByCoordLimit(coords, coordLimit);
45 
46  } else if (strategyMode == "limitTraffic") {
47  int trafficLimit = globalViewBuilder->parProxy("gvbStrategyRemoveCoordsTrafficLimit");
48  removeCoordinatesByTrafficLimit(coords, trafficLimit);
49 
50  } else if (strategyMode == "percentage") {
51  int percentage = globalViewBuilder->parProxy("gvbStrategyRemoveCoordsPercentage");
52  removeCoordinatesByPercentage(coords, percentage);
53 
54  } else if (strategyMode == "") {
55  throw cRuntimeError("StrategyRemoveCoordinates::processCoordinates(): No Strategy Mode given.");
56 
57  } else {
58  throw cRuntimeError("StrategyRemoveCoordinates::processCoordinates(): Unknown Strategy Mode given.");
59  }
60 }
61 
63  throw cRuntimeError("StrategyRemoveCoordinates::processCoordinates(): Choice Strategy not implemented.");
64 }
65 
67  int entrysToRemove = static_cast<int>(coords->size() * (percentage / 100));
68  removeCoordinates(coords, entrysToRemove);
69 }
70 
72  int entrysToRemove = coords->size() - coordLimit;
73  removeCoordinates(coords, entrysToRemove);
74 }
75 
77  int coordLimit = (int)(trafficLimit / getSizeOfSingleCoordinate(*coords));
78  removeCoordinatesByCoordLimit(coords, coordLimit);
79 }
80 
82 
83  std::string strategyMode = globalViewBuilder->parProxy("gvbStrategyRemoveCoordsMode").stdstringValue();
84 
85  std::stringstream tempStr;
86  tempStr << globalViewBuilder->parProxy("gvbSendStrategy").stdstringValue();
87  tempStr << "/";
88  tempStr << strategyMode;
89  tempStr << "/";
90 
91  if(strategyMode == "limitCoords") {
92  tempStr << globalViewBuilder->parProxy("gvbStrategyRemoveCoordsCoordsLimit").longValue();
93 
94  } else if (strategyMode == "limitTraffic") {
95  tempStr << globalViewBuilder->parProxy("gvbStrategyRemoveCoordsTrafficLimit").longValue();
96 
97  } else if (strategyMode == "percentage") {
98  tempStr << globalViewBuilder->parProxy("gvbStrategyRemoveCoordsPercentage").longValue();
99  }
100 
101  return tempStr.str();
102 }