Skip to content

Commit

Permalink
refractor: moved global variables to settings struct
Browse files Browse the repository at this point in the history
  • Loading branch information
jannikbusse committed Nov 29, 2023
1 parent 02459a8 commit 1fad058
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
22 changes: 12 additions & 10 deletions src/libfiles/export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@ using namespace std;
settings setting;

EXPORTED void setFileName(char* file){
_filename = file;
setting.filename = file;
}


EXPORTED void setLogFile(char* file){
_logfile = file;
setting.logfile = file;
}

EXPORTED void setOutputName(char* outName){
_outName = outName;
_setOutput = true;
setting.outname = outName;
setting.outputNameSet = true;
}

EXPORTED int execPipeline(){
return executePipeline(_filename);
return executePipeline(setting.filename);
}

EXPORTED void setSilentMode(bool sMode){
Expand All @@ -77,18 +77,20 @@ EXPORTED void setXMLSchemaLocation(char* file){
EXPORTED int executePipeline(char* file)
{

char dt[100];//stores timestamp as string

if (file == NULL){
cout << "ERR: no file has been provided!" << endl;
return -1;
}

if(!_setOutput){
_outName = file;
if(!setting.outputNameSet){
setting.outname = file;
}

(void)! freopen(_logfile.c_str(), "a", stderr); //(void)! suppresses the unused return warning..
(void)! freopen(setting.logfile.c_str(), "a", stderr); //(void)! suppresses the unused return warning..


char dt[100];
getTimeStamp(dt);
cerr << "\n" << dt << " Error log for run with attribute: " << file << endl;

Expand All @@ -107,7 +109,7 @@ EXPORTED int executePipeline(char* file)
xmlTree inputxml;

roadNetwork data;
string outputFile = _outName;
string outputFile = setting.outname;
data.outputFile = outputFile.substr(0, outputFile.find(".xml"));
data.outputFile = data.outputFile.substr(0, outputFile.find(".xodr"));

Expand Down
5 changes: 1 addition & 4 deletions src/libfiles/export.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ struct r_config{
};


std::string _logfile = "log.txt";
bool _setOutput = false;
char* _filename;
std::string _outName = "";



/**
Expand Down
4 changes: 4 additions & 0 deletions src/utils/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,12 @@ struct settings
laneChanges laneChange;
busStops busStop;

char* filename;
std::string outname;
std::string xmlSchemaLocation; //this has to be set to the xml schema input path
std::string logfile = "log.txt"; //stores the location fo the logfile

bool outputNameSet = false;
bool silentMode = false; //silent mode disables console outputs
bool overwriteLog = true;
int warnings = 0; // counts number of warnings
Expand Down
2 changes: 1 addition & 1 deletion src/utils/xmlParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ struct xmlTree
}
catch (const XMLException &toCatch)
{
cout << "something wrong in xmlreader" << endl;
cout << "ERR: in initializing xml Tree" << endl;
return;
}
}
Expand Down

0 comments on commit 1fad058

Please sign in to comment.