Skip to content

Commit c0d564b

Browse files
author
Padmanabh Patil
committed
Fixed minor formatting
1 parent 6fb5511 commit c0d564b

File tree

2 files changed

+95
-5
lines changed

2 files changed

+95
-5
lines changed

Simulator/Core/Graphitti_Main.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,22 @@
2222
#include "log4cplus/configurator.h"
2323
#include "log4cplus/logger.h"
2424
#include "log4cplus/loggingmacros.h"
25+
#include <cstdlib>
2526
#include <fstream>
2627
#include <iostream>
2728
#include <string>
2829
#include <unistd.h>
29-
#include <cstdlib>
3030

3131
using namespace std;
3232

3333
// Function to check whether there is a file given at a specific path
3434
bool findFile(string path)
3535
{
36-
3736
// Opens the file at specified path
3837
ifstream newFile(path);
3938

4039
// Checks if file is opened properly, otherwise results in an error and returns false
4140
if (newFile.is_open()) {
42-
4341
// Use good() to check if the file exists
4442
bool found = newFile.good();
4543
newFile.close();
@@ -61,7 +59,6 @@ bool findFile(string path)
6159
/// @return -1 if error, else 0 if success.
6260
int main(int argc, char *argv[])
6361
{
64-
6562
// Clear logging files at the start of each simulation
6663
fstream("Output/Debug/logging.txt", ios::out | ios::trunc);
6764
fstream("Output/Debug/vertices.txt", ios::out | ios::trunc);
@@ -73,7 +70,7 @@ int main(int argc, char *argv[])
7370
// This is to find the absolute path of the home directory log4cplus file
7471
string absPath = getenv("HOME");
7572
absPath = absPath + "/log4cplus_configure.ini";
76-
73+
7774
// Checks whether the file is in the home directory
7875
// otherwise uses the file in RuntimeFiles
7976
if (findFile(absPath)) {

Simulator/Core/temp.txt

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/**
2+
* @file Graphitti_Main.cpp
3+
*
4+
* @ingroup Simulator/Core
5+
*
6+
* @brief Starting point of the Simulation - Main.
7+
*
8+
* The main functions calls the Core's runSimulation method which performs the following simulation steps:
9+
* 1) Instantiates Simulator object
10+
* 2) Parses command line to get configuration file and additional information if provided
11+
* 3) Loads global Simulator parameters from configuration file
12+
* 4) Instantiates all simulator objects (Layout, Connections, Synapases, Vertices)
13+
* 5) Reads simulator objects' parameters from configuration file
14+
* 6) Simulation setup (Deseralization, Initailizing values, etc.)
15+
* 7) Run Simulation
16+
* 8) Simulation shutdown (Save results, serialize)
17+
*
18+
* The Core is de-coupled from main to improve testability.
19+
*/
20+
21+
#include "Core.h"
22+
#include "log4cplus/configurator.h"
23+
#include "log4cplus/logger.h"
24+
#include "log4cplus/loggingmacros.h"
25+
#include <cstdlib>
26+
#include <fstream>
27+
#include <iostream>
28+
#include <string>
29+
#include <unistd.h>
30+
31+
using namespace std;
32+
33+
// Function to check whether there is a file given at a specific path
34+
bool findFile(string path)
35+
{
36+
// Opens the file at specified path
37+
ifstream newFile(path);
38+
39+
// Checks if file is opened properly, otherwise results in an error and returns false
40+
if (newFile.is_open()) {
41+
// Use good() to check if the file exists
42+
bool found = newFile.good();
43+
newFile.close();
44+
return found;
45+
46+
} else {
47+
cerr << "ERROR opening file." << endl;
48+
}
49+
50+
return false;
51+
}
52+
53+
54+
/// Main function calls the Core's runSimulation method which
55+
/// handles command line arguments and running the simulation.
56+
///
57+
/// @param argc argument count.
58+
/// @param argv arguments.
59+
/// @return -1 if error, else 0 if success.
60+
int main(int argc, char *argv[])
61+
{
62+
// Clear logging files at the start of each simulation
63+
fstream("Output/Debug/logging.txt", ios::out | ios::trunc);
64+
fstream("Output/Debug/vertices.txt", ios::out | ios::trunc);
65+
fstream("Output/Debug/edges.txt", ios::out | ios::trunc);
66+
67+
// Initialize log4cplus and set properties based on configure file
68+
::log4cplus::initialize();
69+
70+
// This is to find the absolute path of the home directory log4cplus file
71+
string absPath = getenv("HOME");
72+
absPath = absPath + "/log4cplus_configure.ini";
73+
74+
// Checks whether the file is in the home directory
75+
// otherwise uses the file in RuntimeFiles
76+
if (findFile(absPath)) {
77+
::log4cplus::PropertyConfigurator::doConfigure(absPath);
78+
} else {
79+
::log4cplus::PropertyConfigurator::doConfigure("RuntimeFiles/log4cplus_configure.ini");
80+
}
81+
82+
// storing command line arguments as string
83+
// required to pass as an argument to setupSimulation
84+
string cmdLineArguments;
85+
string executableName = argv[0];
86+
for (int i = 1; i < argc; i++) {
87+
cmdLineArguments = cmdLineArguments + argv[i] + " ";
88+
}
89+
90+
// Creating an instance of core class
91+
Core core;
92+
return core.runSimulation(executableName, cmdLineArguments);
93+
};

0 commit comments

Comments
 (0)