Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class application_impl {
options_description _cfg_options;

bfs::path _data_dir;
bfs::path _logging_conf;

string _version;
uint64_t _version_int;
uint64_t _version;
};

application::application()
Expand All @@ -35,20 +35,16 @@ application::application()

application::~application() { }

void application::set_version(string version) {
my->_version = version;
}

void application::set_version(uint64_t version) {
my->_version_int = version;
my->_version = version;
}

string application::version() const {
uint64_t application::version() const {
return my->_version;
}

uint64_t application::version_int() const {
return my->_version_int;
bfs::path application::get_logging_conf() const {
return my->_logging_conf;
}

void application::startup() {
Expand Down Expand Up @@ -87,6 +83,7 @@ void application::set_program_options()
("version,v", "Print version information.")
("data-dir,d", bpo::value<bfs::path>()->default_value( "data-dir" ), "Directory containing configuration file config.ini")
("config,c", bpo::value<bfs::path>()->default_value( "config.ini" ), "Configuration file name relative to data-dir");
("logconf,l", bpo::value<bfs::path>()->default_value( "logging.json" ), "Logging configuration file name/path for library users");

my->_cfg_options.add(app_cfg_opts);
my->_app_options.add(app_cfg_opts);
Expand All @@ -109,6 +106,15 @@ bool application::initialize_impl(int argc, char** argv, vector<abstract_plugin*
return false;
}

bfs::path logconf = "logging.json";
if( options.count("logconf") )
{
logconf = options["logconf"].as<bfs::path>();
if( logconf.is_relative() )
logconf = bfs::current_path() / logconf;
}
my->_logging_conf = logconf;

bfs::path data_dir = "data-dir";
if( options.count("data-dir") )
{
Expand Down
21 changes: 8 additions & 13 deletions include/appbase/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,21 @@ namespace appbase {
public:
~application();

/** @brief Sets version string
/** @brief Set version
*
* @param version Version string output verbatim with -v/--version
*/
void set_version(string version);
/** @overload
*
* @param version Integer version independent of the string output with -v/--version
* @param version Version output with -v/--version
*/
void set_version(uint64_t version);
/** @brief Gets version string
/** @brief Get version
*
* @return Version string output with -v/--version
* @return Version output with -v/--version
*/
string version() const;
/** @brief Gets version integer
uint64_t version() const;
/** @brief Get logging configuration path.
*
* @return Version integer independent of the string output with -v/--version
* @return Logging configuration location from command line
*/
uint64_t version_int() const;
bfs::path get_logging_conf() const;
/**
* @brief Looks for the --plugin commandline / config option and calls initialize on those plugins
*
Expand Down