Skip to content

Commit

Permalink
astyle formatting test #22
Browse files Browse the repository at this point in the history
  • Loading branch information
behrisch committed Jan 20, 2024
1 parent ef46110 commit f7b8fdb
Show file tree
Hide file tree
Showing 99 changed files with 1,571 additions and 1,571 deletions.
65 changes: 33 additions & 32 deletions src/fmi/fmi2Functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const char* fmi2GetVersion(void) {
fmi2Status
fmi2SetDebugLogging(fmi2Component c, fmi2Boolean loggingOn, size_t nCategories, const fmi2String categories[]) {

ModelInstance *comp = (ModelInstance *)c;
ModelInstance* comp = (ModelInstance*)c;

if (loggingOn) {
size_t i;
Expand Down Expand Up @@ -85,15 +85,14 @@ fmi2SetDebugLogging(fmi2Component c, fmi2Boolean loggingOn, size_t nCategories,
failed.*/
fmi2Component
fmi2Instantiate(fmi2String instanceName, fmi2Type fmuType, fmi2String fmuGUID,
fmi2String fmuResourceLocation, const fmi2CallbackFunctions *functions,
fmi2Boolean visible, fmi2Boolean loggingOn)
{
fmi2String fmuResourceLocation, const fmi2CallbackFunctions* functions,
fmi2Boolean visible, fmi2Boolean loggingOn) {
UNREFERENCED_PARAMETER(fmuType);
UNREFERENCED_PARAMETER(fmuGUID);
UNREFERENCED_PARAMETER(visible);

allocateMemoryType funcAllocateMemory = (allocateMemoryType)functions->allocateMemory;
ModelInstance* comp = (ModelInstance *) funcAllocateMemory(1, sizeof(ModelInstance));
ModelInstance* comp = (ModelInstance*) funcAllocateMemory(1, sizeof(ModelInstance));

if (comp) {
comp->componentEnvironment = functions->componentEnvironment;
Expand All @@ -105,12 +104,12 @@ fmi2Instantiate(fmi2String instanceName, fmi2Type fmuType, fmi2String fmuGUID,
comp->allocateMemory = (allocateMemoryType)functions->allocateMemory;
comp->freeMemory = (freeMemoryType)functions->freeMemory;

comp->instanceName = (char *)comp->allocateMemory(1 + strlen(instanceName), sizeof(char));
strcpy((char *)comp->instanceName, (char *)instanceName);
comp->instanceName = (char*)comp->allocateMemory(1 + strlen(instanceName), sizeof(char));
strcpy((char*)comp->instanceName, (char*)instanceName);

if (fmuResourceLocation) {
comp->resourceLocation = (char *)comp->allocateMemory(1 + strlen(fmuResourceLocation), sizeof(char));
strcpy((char *)comp->resourceLocation, (char *)fmuResourceLocation);
comp->resourceLocation = (char*)comp->allocateMemory(1 + strlen(fmuResourceLocation), sizeof(char));
strcpy((char*)comp->resourceLocation, (char*)fmuResourceLocation);
} else {
comp->resourceLocation = NULL;
}
Expand All @@ -126,23 +125,23 @@ fmi2Instantiate(fmi2String instanceName, fmi2Type fmuType, fmi2String fmuGUID,
and other resources that have been allocated by the functions of the FMU interface. */
void
fmi2FreeInstance(fmi2Component c) {
ModelInstance *comp = (ModelInstance *)c;
ModelInstance* comp = (ModelInstance*)c;

/* Store the pointer to the freeMemory function, because we
are going to free comp as well */
freeMemoryType freeMemoryFunc = comp->freeMemory;

/* We want to free everything that we allocated in fmi2Instantiate */
freeMemoryFunc((void *)comp->instanceName);
freeMemoryFunc((void *)comp->resourceLocation);
freeMemoryFunc((void *)comp->libsumoCallOptions);
freeMemoryFunc((void *)comp->getterParameters);
freeMemoryFunc((void*)comp->instanceName);
freeMemoryFunc((void*)comp->resourceLocation);
freeMemoryFunc((void*)comp->libsumoCallOptions);
freeMemoryFunc((void*)comp->getterParameters);
int i;
for (i = 0; i < comp->bufferArrayLength; i++) {
freeMemoryFunc((void *)comp->bufferArray[i]);
freeMemoryFunc((void*)comp->bufferArray[i]);
}
freeMemoryFunc((void *)comp->bufferArray);
freeMemoryFunc((void *)comp);
freeMemoryFunc((void*)comp->bufferArray);
freeMemoryFunc((void*)comp);
}

fmi2Status
Expand All @@ -154,7 +153,7 @@ fmi2SetupExperiment(fmi2Component c, fmi2Boolean toleranceDefined, fmi2Real tole
UNREFERENCED_PARAMETER(stopTimeDefined);

// ignore arguments: toleranceDefined, tolerance
ModelInstance *comp = (ModelInstance *)c;
ModelInstance* comp = (ModelInstance*)c;

// Store the start and stop times of the experiment
comp->startTime = startTime;
Expand All @@ -176,7 +175,7 @@ fmi2EnterInitializationMode(fmi2Component c) {
// Informs the FMU to exit Initialization Mode
fmi2Status
fmi2ExitInitializationMode(fmi2Component c) {
ModelInstance *comp = (ModelInstance *)c;
ModelInstance* comp = (ModelInstance*)c;

sumo2fmi_logEvent(comp, "Calling libsumo with the following options: \"%s\"", comp->libsumoCallOptions);
libsumo_load(comp->libsumoCallOptions);
Expand Down Expand Up @@ -217,7 +216,7 @@ fmi2GetReal(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2Real
fmi2Status
fmi2GetInteger(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2Integer value[]) {

ModelInstance *comp = (ModelInstance *)c;
ModelInstance* comp = (ModelInstance*)c;

// Check for null pointer errors
if (nvr > 0 && (!vr || !value)) {
Expand Down Expand Up @@ -253,7 +252,7 @@ fmi2GetBoolean(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2B
fmi2Status
fmi2GetString(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2String value[]) {

ModelInstance *comp = (ModelInstance *)c;
ModelInstance* comp = (ModelInstance*)c;

// Check for null pointer errors
if (nvr > 0 && (!vr || !value)) {
Expand All @@ -265,10 +264,10 @@ fmi2GetString(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2St
/** Clear value array buffer before reuse */
int b;
for (b = 0; b < comp->bufferArrayLength; b++) {
comp->freeMemory((void *)comp->bufferArray[b]);
comp->freeMemory((void*)comp->bufferArray[b]);
}
comp->freeMemory((void *)comp->bufferArray);
comp->bufferArray = (fmi2String *)comp->allocateMemory(nvr, sizeof(fmi2String));
comp->freeMemory((void*)comp->bufferArray);
comp->bufferArray = (fmi2String*)comp->allocateMemory(nvr, sizeof(fmi2String));
comp->bufferArrayLength = (int)nvr;

// Go through the list of arrays and save all requested values
Expand Down Expand Up @@ -322,14 +321,16 @@ fmi2SetBoolean(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const
fmi2Status
fmi2SetString(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2String value[]) {

ModelInstance *comp = (ModelInstance *)c;
ModelInstance* comp = (ModelInstance*)c;
fmi2Status status = fmi2OK;

size_t i;
for (i = 0; i < nvr; i++) {
fmi2Status s = sumo2fmi_setString(comp, vr[i], value[i]);
status = s > status ? s : status;
if (status > fmi2Warning) return status;
if (status > fmi2Warning) {
return status;
}
}

return status;
Expand Down Expand Up @@ -425,7 +426,7 @@ fmi2Status
fmi2DoStep(fmi2Component c, fmi2Real currentCommunicationPoint, fmi2Real communicationStepSize, fmi2Boolean noSetFMUStatePriorToCurrentPoint) {
UNREFERENCED_PARAMETER(noSetFMUStatePriorToCurrentPoint);

ModelInstance *comp = (ModelInstance *)c;
ModelInstance* comp = (ModelInstance*)c;

if (communicationStepSize <= 0) {
return fmi2Error;
Expand All @@ -443,7 +444,7 @@ fmi2CancelStep(fmi2Component c) {

/* Status functions */
fmi2Status
fmi2GetStatus(fmi2Component c, const fmi2StatusKind s, fmi2Status *value) {
fmi2GetStatus(fmi2Component c, const fmi2StatusKind s, fmi2Status* value) {
UNREFERENCED_PARAMETER(c);
UNREFERENCED_PARAMETER(s);
UNREFERENCED_PARAMETER(value);
Expand All @@ -452,7 +453,7 @@ fmi2GetStatus(fmi2Component c, const fmi2StatusKind s, fmi2Status *value) {
}

fmi2Status
fmi2GetRealStatus(fmi2Component c, const fmi2StatusKind s, fmi2Real *value) {
fmi2GetRealStatus(fmi2Component c, const fmi2StatusKind s, fmi2Real* value) {
UNREFERENCED_PARAMETER(c);
UNREFERENCED_PARAMETER(s);
UNREFERENCED_PARAMETER(value);
Expand All @@ -461,7 +462,7 @@ fmi2GetRealStatus(fmi2Component c, const fmi2StatusKind s, fmi2Real *value) {
}

fmi2Status
fmi2GetIntegerStatus(fmi2Component c, const fmi2StatusKind s, fmi2Integer *value) {
fmi2GetIntegerStatus(fmi2Component c, const fmi2StatusKind s, fmi2Integer* value) {
UNREFERENCED_PARAMETER(c);
UNREFERENCED_PARAMETER(s);
UNREFERENCED_PARAMETER(value);
Expand All @@ -470,7 +471,7 @@ fmi2GetIntegerStatus(fmi2Component c, const fmi2StatusKind s, fmi2Integer *value
}

fmi2Status
fmi2GetBooleanStatus(fmi2Component c, const fmi2StatusKind s, fmi2Boolean *value) {
fmi2GetBooleanStatus(fmi2Component c, const fmi2StatusKind s, fmi2Boolean* value) {
UNREFERENCED_PARAMETER(c);
UNREFERENCED_PARAMETER(s);
UNREFERENCED_PARAMETER(value);
Expand All @@ -479,7 +480,7 @@ fmi2GetBooleanStatus(fmi2Component c, const fmi2StatusKind s, fmi2Boolean *value
}

fmi2Status
fmi2GetStringStatus(fmi2Component c, const fmi2StatusKind s, fmi2String *value) {
fmi2GetStringStatus(fmi2Component c, const fmi2StatusKind s, fmi2String* value) {
UNREFERENCED_PARAMETER(c);
UNREFERENCED_PARAMETER(s);
UNREFERENCED_PARAMETER(value);
Expand Down
22 changes: 11 additions & 11 deletions src/fmi/sumo2fmi_bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#define BUFFER_SIZE 256

void
sumo2fmi_set_startValues(ModelInstance *comp) {
sumo2fmi_set_startValues(ModelInstance* comp) {
char sumoHomePath[BUFFER_SIZE];
/* check if $SUMO_HOME exists */
if (!getenv("SUMO_HOME")) {
Expand All @@ -54,12 +54,12 @@ sumo2fmi_set_startValues(ModelInstance *comp) {

char defaultCallOptions[BUFFER_SIZE * 2];
snprintf(defaultCallOptions, BUFFER_SIZE * 2, "-c %s/tools/game/grid6.sumocfg", sumoHomePath);
comp->libsumoCallOptions = (char *)comp->allocateMemory(1 + strlen(defaultCallOptions), sizeof(char));
strcpy((char *)comp->libsumoCallOptions, (char *)defaultCallOptions);
comp->libsumoCallOptions = (char*)comp->allocateMemory(1 + strlen(defaultCallOptions), sizeof(char));
strcpy((char*)comp->libsumoCallOptions, (char*)defaultCallOptions);
}

void
sumo2fmi_logEvent(ModelInstance *comp, const char *message, ...) {
sumo2fmi_logEvent(ModelInstance* comp, const char* message, ...) {
if (!comp->logEvents) {
return;
}
Expand All @@ -71,7 +71,7 @@ sumo2fmi_logEvent(ModelInstance *comp, const char *message, ...) {
}

void
sumo2fmi_logError(ModelInstance *comp, const char *message, ...) {
sumo2fmi_logError(ModelInstance* comp, const char* message, ...) {
if (!comp->logErrors) {
return;
}
Expand All @@ -83,10 +83,10 @@ sumo2fmi_logError(ModelInstance *comp, const char *message, ...) {
}

void
sumo2fmi_logMessage(ModelInstance *comp, int status, const char *category, const char *message, va_list args) {
sumo2fmi_logMessage(ModelInstance* comp, int status, const char* category, const char* message, va_list args) {
va_list args1;
size_t len = 0;
char *buf = "";
char* buf = "";

va_copy(args1, args);
len = vsnprintf(buf, len, message, args1);
Expand Down Expand Up @@ -117,7 +117,7 @@ sumo2fmi_getInteger(ModelInstance* comp, const fmi2ValueReference vr, int* value
}

fmi2Status
sumo2fmi_getString(ModelInstance *comp, const fmi2ValueReference vr, fmi2String *value) {
sumo2fmi_getString(ModelInstance* comp, const fmi2ValueReference vr, fmi2String* value) {
switch (vr) {
case 0:
*value = comp->libsumoCallOptions;
Expand All @@ -144,12 +144,12 @@ sumo2fmi_setString(ModelInstance* comp, fmi2ValueReference vr, fmi2String value)
switch (vr) {
case 0:
comp->freeMemory(comp->libsumoCallOptions);
comp->libsumoCallOptions = (char *)comp->allocateMemory(1 + strlen(value), sizeof(char));
comp->libsumoCallOptions = (char*)comp->allocateMemory(1 + strlen(value), sizeof(char));
strcpy(comp->libsumoCallOptions, value);
return fmi2OK;
case 1:
comp->freeMemory(comp->getterParameters);
comp->getterParameters = (char *)comp->allocateMemory(1 + strlen(value), sizeof(char));
comp->getterParameters = (char*)comp->allocateMemory(1 + strlen(value), sizeof(char));
strcpy(comp->getterParameters, value);
return fmi2OK;
case 3:
Expand All @@ -161,7 +161,7 @@ sumo2fmi_setString(ModelInstance* comp, fmi2ValueReference vr, fmi2String value)
}

fmi2Status
sumo2fmi_step(ModelInstance *comp, double tNext) {
sumo2fmi_step(ModelInstance* comp, double tNext) {
UNREFERENCED_PARAMETER(comp);

libsumo_step(tNext);
Expand Down
3 changes: 1 addition & 2 deletions src/libsumo/Person.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,7 @@ Person::getStage(const std::string& personID, int nextStageIndex) {
result.travelTime = INVALID_DOUBLE_VALUE;
if (stage->getArrived() >= 0) {
result.travelTime = STEPS2TIME(stage->getArrived() - stage->getDeparted());
}
else if (stage->getDeparted() >= 0) {
} else if (stage->getDeparted() >= 0) {
result.travelTime = STEPS2TIME(SIMSTEP - stage->getDeparted());
}

Expand Down
2 changes: 1 addition & 1 deletion src/mesosim/MEVehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ class MEVehicle : public MSBaseVehicle {


/// @brief Returns the duration for which the vehicle was blocked
inline SUMOTime getWaitingTime(const bool accumulated=false) const {
inline SUMOTime getWaitingTime(const bool accumulated = false) const {
UNUSED_PARAMETER(accumulated);
return MAX2(SUMOTime(0), myEventTime - myBlockTime);
}
Expand Down
2 changes: 1 addition & 1 deletion src/microsim/MSVehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ class MSVehicle : public MSBaseVehicle {
* If accumulated is true the time is aggregated over a configurable interval.
* @return The time the vehicle is standing
*/
SUMOTime getWaitingTime(const bool accumulated=false) const {
SUMOTime getWaitingTime(const bool accumulated = false) const {
if (!accumulated) {
return myWaitingTime;
}
Expand Down
4 changes: 2 additions & 2 deletions src/microsim/devices/MSRoutingEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ class MSRoutingEngine {

/// @brief return the vehicle router instance
static MSVehicleRouter& getRouterTT(const int rngIndex,
SUMOVehicleClass svc,
const MSEdgeVector& prohibited = MSEdgeVector());
SUMOVehicleClass svc,
const MSEdgeVector& prohibited = MSEdgeVector());

/// @brief return the person router instance
static MSTransportableRouter& getIntermodalRouterTT(const int rngIndex,
Expand Down
4 changes: 2 additions & 2 deletions src/microsim/transportables/MSPModel_JuPedSim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ MSPModel_JuPedSim::createGeometryFromShape(PositionVector shape, std::string sha
cleanShape.push_back(shape[0]);
PositionVector duplicates;
for (int i = 1; i < (int)shape.size(); i++) {
if (shape[i] != shape[i-1]) {
if (shape[i] != shape[i - 1]) {
cleanShape.push_back(shape[i]);
} else {
duplicates.push_back(shape[i]);
Expand Down Expand Up @@ -772,7 +772,7 @@ MSPModel_JuPedSim::initialize() {
}
if (nbrConnectedComponents > 1) {
WRITE_WARNINGF(TL("While generating geometry % connected components were detected, %% of total pedestrian area is covered by the first."),
nbrConnectedComponents, maxArea/totalArea*100.0, "%");
nbrConnectedComponents, maxArea / totalArea * 100.0, "%");
}
#ifdef DEBUG_GEOMETRY_GENERATION
dumpGeometry(maxAreaConnectedComponentPolygon, "pedestrianNetwork.wkt");
Expand Down
2 changes: 1 addition & 1 deletion src/microsim/transportables/MSPerson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ MSPerson::checkAccess(const MSStage* const prior, const bool waitAtStop) {
}
}
newStage = new MSPersonStage_Access(accessEdge, prevStop, arrivalPos, access->length, true,
trainExit, platformEntry);
trainExit, platformEntry);
}
myStep = myPlan->insert(myStep, newStage);
return true;
Expand Down
6 changes: 3 additions & 3 deletions src/microsim/transportables/MSStageDriving.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ MSStageDriving::MSStageDriving(const MSEdge* origin, const MSEdge* destination,
MSStage*
MSStageDriving::clone() const {
MSStage* const clon = new MSStageDriving(myOrigin, myDestination, myDestinationStop, myArrivalPos,
std::vector<std::string>(myLines.begin(), myLines.end()),
myGroup, myIntendedVehicleID, myIntendedDepart);
std::vector<std::string>(myLines.begin(), myLines.end()),
myGroup, myIntendedVehicleID, myIntendedDepart);
clon->setParameters(*this);
return clon;
}
Expand Down Expand Up @@ -434,7 +434,7 @@ MSStageDriving::setArrived(MSNet* net, MSTransportable* transportable, SUMOTime
const double totalLength = myVehicle->getVehicleType().getLength();
const int numCarriages = MAX2(1, 1 + (int)((totalLength - pars.locomotiveLength) / (pars.carriageLength + pars.carriageGap) + 0.5));
const int firstPassengerCarriage = numCarriages == 1
|| (myVehicle->getVClass() & (SVC_RAIL_ELECTRIC | SVC_RAIL_FAST | SVC_RAIL)) == 0 ? 0 : 1;
|| (myVehicle->getVClass() & (SVC_RAIL_ELECTRIC | SVC_RAIL_FAST | SVC_RAIL)) == 0 ? 0 : 1;
const int randomCarriage = RandHelper::rand(numCarriages - firstPassengerCarriage) + firstPassengerCarriage;
const double positionOnLane = myVehicle->getPositionOnLane();
if (randomCarriage == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/microsim/transportables/MSStageMoving.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class MSStageMoving : public MSStage {
virtual bool moveToNextEdge(MSTransportable* transportable, SUMOTime currentTime, int prevDir, MSEdge* nextInternal = 0) = 0;

/// @brief add the move reminders for the current lane on entry
virtual void activateEntryReminders(MSTransportable* person, const bool isDepart=false) {
virtual void activateEntryReminders(MSTransportable* person, const bool isDepart = false) {
UNUSED_PARAMETER(person);
UNUSED_PARAMETER(isDepart);
}
Expand Down
2 changes: 1 addition & 1 deletion src/microsim/transportables/MSStageWaiting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ MSStageWaiting::~MSStageWaiting() {}
MSStage*
MSStageWaiting::clone() const {
MSStage* const clon = new MSStageWaiting(myDestination, myDestinationStop, myWaitingDuration, myWaitingUntil, myArrivalPos,
myActType, myType == MSStageType::WAITING_FOR_DEPART);
myActType, myType == MSStageType::WAITING_FOR_DEPART);
clon->setParameters(*this);
return clon;
}
Expand Down
Loading

0 comments on commit f7b8fdb

Please sign in to comment.