Skip to content

Commit 375a2ba

Browse files
committed
Style fix
1 parent 0483aa2 commit 375a2ba

7 files changed

Lines changed: 65 additions & 66 deletions

File tree

parser/parser_exec.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ namespace Parser {
3636

3737
ParserExecutor::ParserExecutor() : UserInputHandler()
3838
{
39-
cmd_line_opts_.add(generic_).add(config_).add(hidden_);
40-
cfg_file_opts_.add(config_).add(hidden_);
41-
visible_.add(generic_).add(config_);
39+
_cmd_line_opts.add(_generic).add(_config).add(_hidden);
40+
_cfg_file_opts.add(_config).add(_hidden);
41+
_visible.add(_generic).add(_config);
4242
}
4343

4444
void ParserExecutor::execute(int arg_count, char* args[])
@@ -47,7 +47,7 @@ void ParserExecutor::execute(int arg_count, char* args[])
4747

4848
Util::prog_opts::variables_map vm;
4949
store(Util::prog_opts::command_line_parser(arg_count, args)
50-
.options(cmd_line_opts_).positional(positional_).run(), vm);
50+
.options(_cmd_line_opts).positional(_positional).run(), vm);
5151
notify(vm);
5252

5353
// Help handling -------------------------------------------------------------
@@ -56,7 +56,7 @@ void ParserExecutor::execute(int arg_count, char* args[])
5656
std::cout << "Usage: filename [options]\n";
5757
std::cout << "Command line options are prioritized over configuration file"
5858
" options.";
59-
std::cout << visible_ << "\n";
59+
std::cout << _visible << "\n";
6060
return;
6161
}
6262

@@ -69,18 +69,18 @@ void ParserExecutor::execute(int arg_count, char* args[])
6969

7070
// Optional configuration file handling --------------------------------------
7171

72-
if (config_file_) {
73-
std::ifstream config_fs((*config_file_).c_str());
72+
if (_config_file) {
73+
std::ifstream config_fs((*_config_file).c_str());
7474
if (config_fs) {
75-
store(parse_config_file(config_fs, cfg_file_opts_), vm);
75+
store(parse_config_file(config_fs, _cfg_file_opts), vm);
7676
notify(vm);
7777
}
7878
}
7979

8080
// Input SBG program file handling -------------------------------------------
8181

82-
if (input_file_) {
83-
parseFile(*input_file_);
82+
if (_input_file) {
83+
parseFile(*_input_file);
8484
}
8585
else {
8686
std::cout << "Usage: filename [options]";

util/logger.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,27 @@
1717
1818
******************************************************************************/
1919

20-
#include "logger.hpp"
21-
22-
using namespace std;
20+
#include "util/logger.hpp"
2321

2422
namespace SBG {
2523

2624
namespace Util {
2725

28-
SBGLogger::SBGLogger() { file_.open("SBG.log", std::ofstream::out); }
26+
SBGLogger::SBGLogger() { _file.open("SBG.log", std::ofstream::out); }
27+
28+
SBGLogger::~SBGLogger() { _file.close(); }
2929

30-
SBGLogger::~SBGLogger() { file_.close(); }
30+
SBGLogger& SBGLogger::instance()
31+
{
32+
static SBGLogger _instance;
33+
return _instance;
34+
}
3135

32-
void SBGLogger::setLevel(LogLevel lvl) { level_ = lvl; }
36+
void SBGLogger::setLevel(LogLevel lvl) { _level = lvl; }
3337

3438
std::ostream& SBGLogger::log(LogLevel msg_lvl)
3539
{
36-
return (msg_lvl <= level_) ? file_ : null_stream;
40+
return (msg_lvl <= _level) ? _file : null_stream;
3741
}
3842

3943
} // namespace Util

util/logger.hpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,7 @@ static std::ostream null_stream(&null_buffer);
4848

4949
class SBGLogger {
5050
public:
51-
static SBGLogger& instance()
52-
{
53-
static SBGLogger _instance;
54-
return _instance;
55-
}
51+
static SBGLogger& instance();
5652

5753
~SBGLogger();
5854

@@ -61,8 +57,8 @@ class SBGLogger {
6157

6258
private:
6359
SBGLogger();
64-
std::ofstream file_;
65-
LogLevel level_{LogLevel::Info};
60+
std::ofstream _file;
61+
LogLevel _level{LogLevel::Info};
6662
};
6763

6864
} // namespace Util

util/time_profiler.cpp

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,45 +23,43 @@ namespace SBG {
2323

2424
namespace Util {
2525

26-
2726
void time_profiler_results()
2827
{
29-
Internal::TimeProfiler::print_execution_time();
28+
Internal::TimeProfiler::print_execution_time();
3029
}
3130

32-
3331
namespace Internal{
3432

3533
std::unordered_map<std::string, double> TimeProfiler::_execution_time = {};
3634

3735
TimeProfiler::TimeProfiler(std::string&& function_name)
38-
: _function_name(move(function_name))
36+
: _function_name(move(function_name))
3937
{
40-
if (time_profiler_enabled) {
41-
_start = std::chrono::high_resolution_clock::now();
42-
}
38+
if (time_profiler_enabled) {
39+
_start = std::chrono::high_resolution_clock::now();
40+
}
4341
}
4442

4543

4644
TimeProfiler::~TimeProfiler()
4745
{
48-
if (time_profiler_enabled) {
49-
auto end = std::chrono::high_resolution_clock::now();
50-
auto exec_time = std::chrono::duration<double, std::milli>(end - _start).count();
51-
if (_execution_time.find(_function_name) == _execution_time.end()) {
52-
_execution_time.insert({_function_name, 0.0});
53-
}
54-
_execution_time[_function_name] += exec_time;
46+
if (time_profiler_enabled) {
47+
auto end = std::chrono::high_resolution_clock::now();
48+
auto exec_time = std::chrono::duration<double, std::milli>(end - _start).count();
49+
if (_execution_time.find(_function_name) == _execution_time.end()) {
50+
_execution_time.insert({_function_name, 0.0});
5551
}
52+
_execution_time[_function_name] += exec_time;
53+
}
5654
}
5755

5856

5957
void TimeProfiler::print_execution_time() {
60-
if (time_profiler_enabled) {
61-
for (auto&& pair : TimeProfiler::_execution_time) {
62-
std::cout << pair.first << ": " << pair.second << " ms" << std::endl;
63-
}
58+
if (time_profiler_enabled) {
59+
for (auto&& pair : TimeProfiler::_execution_time) {
60+
std::cout << pair.first << ": " << pair.second << " ms" << std::endl;
6461
}
62+
}
6563
}
6664

6765
}

util/time_profiler.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,17 @@ namespace Internal {
3737
* defining TimeProfiler objects.
3838
*/
3939
struct TimeProfiler {
40-
TimeProfiler(std::string&& function_name);
40+
public:
41+
TimeProfiler(std::string&& function_name);
4142

42-
~TimeProfiler();
43+
~TimeProfiler();
4344

44-
static void print_execution_time();
45+
static void print_execution_time();
4546

4647
private:
47-
std::string _function_name;
48-
std::chrono::_V2::system_clock::time_point _start;
49-
static std::unordered_map<std::string, double> _execution_time;
48+
std::string _function_name;
49+
std::chrono::_V2::system_clock::time_point _start;
50+
static std::unordered_map<std::string, double> _execution_time;
5051
};
5152

5253
} // namespace Internal

util/user_input_handler.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,23 @@ void version()
4545
// User Input Handler ----------------------------------------------------------
4646
////////////////////////////////////////////////////////////////////////////////
4747

48-
UserInputHandler::UserInputHandler() : generic_("Generic options")
49-
, config_("Configuration options"), hidden_("Hidden options")
50-
, cmd_line_opts_("Command line options")
51-
, cfg_file_opts_("Configuration file options"), positional_()
48+
UserInputHandler::UserInputHandler() : _generic("Generic options")
49+
, _config("Configuration options"), _hidden("Hidden options")
50+
, _cmd_line_opts("Command line options")
51+
, _cfg_file_opts("Configuration file options"), _positional()
5252
{
53-
generic_.add_options()
53+
_generic.add_options()
5454
("help,h", "Prints all available options")
5555
("version,v", "Displays version information")
5656
("debug,d", "Activates debug messages")
57-
("config,c", prog_opts::value(&config_file_), "Configuration filename");
57+
("config,c", prog_opts::value(&_config_file), "Configuration filename");
5858

59-
hidden_.add_options()
60-
("input-file", prog_opts::value(&input_file_)
59+
_hidden.add_options()
60+
("input-file", prog_opts::value(&_input_file)
6161
, "Input SBG program");
6262

6363
// First option without name is the input file
64-
positional_.add("input-file", 1);
64+
_positional.add("input-file", 1);
6565
}
6666

6767
} // namespace Util

util/user_input_handler.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ class UserInputHandler {
4646
virtual void execute(int arg_count, char* args[]) = 0;
4747

4848
protected:
49-
prog_opts::options_description generic_; ///< Descriptive info (version, etc.)
50-
prog_opts::options_description config_; ///< SBG Program configuration
51-
prog_opts::options_description hidden_; ///< Options hidden to the user
52-
prog_opts::options_description cmd_line_opts_; ///< Command line options
53-
prog_opts::options_description cfg_file_opts_; ///< Options in config files
54-
prog_opts::options_description visible_; ///< All visible options for the user
55-
prog_opts::positional_options_description positional_;
56-
boost::optional<std::string> config_file_;
57-
boost::optional<std::string> input_file_;
49+
prog_opts::options_description _generic; ///< Descriptive info (version, etc.)
50+
prog_opts::options_description _config; ///< SBG Program configuration
51+
prog_opts::options_description _hidden; ///< Options hidden to the user
52+
prog_opts::options_description _cmd_line_opts; ///< Command line options
53+
prog_opts::options_description _cfg_file_opts; ///< Options in config files
54+
prog_opts::options_description _visible; ///< All visible options for the user
55+
prog_opts::positional_options_description _positional;
56+
boost::optional<std::string> _config_file;
57+
boost::optional<std::string> _input_file;
5858
};
5959

6060
} // namespace Util

0 commit comments

Comments
 (0)