summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDirk Huss <dirk_huss@mentor.com>2015-11-25 14:38:28 +0100
committerDirk Huss <dirk_huss@mentor.com>2015-11-25 14:38:28 +0100
commitb6f81b22fcf8d9cf8ee9248408b7d2a72fbff1d9 (patch)
tree8b0b1438ccaa9450ca4b21221eb9cd74f14b10f5 /src
parent3d2fb21d0e93b6b595610285e910ac80c099a174 (diff)
downloadgenivi-common-api-runtime-b6f81b22fcf8d9cf8ee9248408b7d2a72fbff1d9.tar.gz
CommonAPI 3.1.4
Diffstat (limited to 'src')
-rw-r--r--src/CommonAPI/Address.cpp90
-rw-r--r--src/CommonAPI/IniFileReader.cpp146
-rw-r--r--src/CommonAPI/Logger.cpp138
-rw-r--r--src/CommonAPI/MainLoopContext.cpp2
-rw-r--r--src/CommonAPI/Proxy.cpp2
-rw-r--r--src/CommonAPI/ProxyManager.cpp6
-rw-r--r--src/CommonAPI/Runtime.cpp42
-rw-r--r--src/CommonAPI/Utils.cpp18
8 files changed, 225 insertions, 219 deletions
diff --git a/src/CommonAPI/Address.cpp b/src/CommonAPI/Address.cpp
index 2315a9c..0a7344a 100644
--- a/src/CommonAPI/Address.cpp
+++ b/src/CommonAPI/Address.cpp
@@ -10,22 +10,22 @@
namespace CommonAPI {
Address::Address(const std::string &_address) {
- // TODO: handle error situation (_address is no valid CommonAPI address)
- setAddress(_address);
+ // TODO: handle error situation (_address is no valid CommonAPI address)
+ setAddress(_address);
}
Address::Address(const std::string &_domain,
- const std::string &_interface,
- const std::string &_instance)
- : domain_(_domain),
- interface_(_interface),
- instance_(_instance) {
+ const std::string &_interface,
+ const std::string &_instance)
+ : domain_(_domain),
+ interface_(_interface),
+ instance_(_instance) {
}
Address::Address(const Address &_source)
- : domain_(_source.domain_),
- interface_(_source.interface_),
- instance_(_source.instance_) {
+ : domain_(_source.domain_),
+ interface_(_source.interface_),
+ instance_(_source.instance_) {
}
Address::~Address() {
@@ -33,90 +33,90 @@ Address::~Address() {
bool
Address::operator ==(const Address &_other) const {
- return (domain_ == _other.domain_ &&
- interface_ == _other.interface_ &&
- instance_ == _other.instance_);
+ return (domain_ == _other.domain_ &&
+ interface_ == _other.interface_ &&
+ instance_ == _other.instance_);
}
bool
Address::operator !=(const Address &_other) const {
- return (domain_ != _other.domain_ ||
- interface_ != _other.interface_ ||
- instance_ != _other.instance_);
+ return (domain_ != _other.domain_ ||
+ interface_ != _other.interface_ ||
+ instance_ != _other.instance_);
}
bool
Address::operator<(const Address &_other) const {
- if (domain_ < _other.domain_)
- return true;
+ if (domain_ < _other.domain_)
+ return true;
- if (domain_ == _other.domain_) {
- if (interface_ < _other.interface_)
- return true;
+ if (domain_ == _other.domain_) {
+ if (interface_ < _other.interface_)
+ return true;
- if (interface_ == _other.interface_) {
- if (instance_ < _other.instance_)
- return true;
- }
- }
+ if (interface_ == _other.interface_) {
+ if (instance_ < _other.instance_)
+ return true;
+ }
+ }
- return false;
+ return false;
}
std::string
Address::getAddress() const {
- return (domain_ + ":" + interface_ + ":" + instance_);
+ return (domain_ + ":" + interface_ + ":" + instance_);
}
void
Address::setAddress(const std::string &_address) {
- std::istringstream addressStream(_address);
+ std::istringstream addressStream(_address);
if (std::getline(addressStream, domain_, ':')) {
- if (std::getline(addressStream, interface_, ':')) {
- if(!std::getline(addressStream, instance_, ':')) {
- if(std::getline(addressStream, instance_)) {
- }
- }
- }
+ if (std::getline(addressStream, interface_, ':')) {
+ if(!std::getline(addressStream, instance_, ':')) {
+ if(std::getline(addressStream, instance_)) {
+ }
+ }
+ }
}
}
const std::string &
Address::getDomain() const {
- return domain_;
+ return domain_;
}
void
Address::setDomain(const std::string &_domain) {
- domain_ = _domain;
+ domain_ = _domain;
}
const std::string &
Address::getInterface() const {
- return interface_;
+ return interface_;
}
void
Address::setInterface(const std::string &_interface) {
- interface_ = _interface;
+ interface_ = _interface;
}
const std::string &
Address::getInstance() const {
- return instance_;
+ return instance_;
}
void
Address::setInstance(const std::string &_instance) {
- instance_ = _instance;
+ instance_ = _instance;
}
std::ostream &
operator<<(std::ostream &_out, const Address &_address) {
- _out << _address.domain_
- << ":" << _address.interface_
- << ":" << _address.instance_;
- return _out;
+ _out << _address.domain_
+ << ":" << _address.interface_
+ << ":" << _address.instance_;
+ return _out;
}
} // namespace CommonAPI
diff --git a/src/CommonAPI/IniFileReader.cpp b/src/CommonAPI/IniFileReader.cpp
index 1637591..b1c96f1 100644
--- a/src/CommonAPI/IniFileReader.cpp
+++ b/src/CommonAPI/IniFileReader.cpp
@@ -14,101 +14,101 @@ namespace CommonAPI {
const std::map<std::string, std::string> &
IniFileReader::Section::getMappings() const {
- return mappings_;
+ return mappings_;
}
std::string
IniFileReader::Section::getValue(const std::string &_key) const {
- auto it = mappings_.find(_key);
- if (it != mappings_.end()) {
- return it->second;
- }
- return ("");
+ auto it = mappings_.find(_key);
+ if (it != mappings_.end()) {
+ return it->second;
+ }
+ return ("");
}
bool
IniFileReader::load(const std::string &_path) {
- std::ifstream configStream(_path);
- if (configStream.is_open()) {
- COMMONAPI_INFO("Loading ini file from ", _path);
+ std::ifstream configStream(_path);
+ if (configStream.is_open()) {
+ COMMONAPI_INFO("Loading ini file from ", _path);
- int lineCounter(0);
- std::string currentSectionName;
- std::shared_ptr<Section> currentSection;
+ int lineCounter(0);
+ std::string currentSectionName;
+ std::shared_ptr<Section> currentSection;
- while (!configStream.eof()) {
- std::string line;
- std::getline(configStream, line);
- lineCounter++;
+ while (!configStream.eof()) {
+ std::string line;
+ std::getline(configStream, line);
+ lineCounter++;
- trim(line);
+ trim(line);
- std::size_t start = line.find('[');
- if (start == 0) {
- std::size_t end = line.find(']');
- if (end != line.npos) {
- currentSectionName = line.substr(++start, --end);
- if (sections_.end() == sections_.find(currentSectionName)) {
- currentSection = std::make_shared<Section>();
- if (currentSection) {
- sections_[currentSectionName] = currentSection;
- }
- } else {
- COMMONAPI_ERROR("Double definition of section \'",
- currentSectionName,
- "\' ignoring definition (line ",
- lineCounter,
- ")");
- currentSection = nullptr;
- }
- } else {
- COMMONAPI_ERROR("Missing \']\' in section definition (line ",
- lineCounter, ")");
- }
- } else if (currentSection) {
- std::size_t pos = line.find('=');
- if (pos != line.npos) {
- std::string key = line.substr(0, pos);
- trim(key);
- if (currentSection->mappings_.end()
- != currentSection->mappings_.find(key)) {
- COMMONAPI_ERROR("Double definition for key \'",
- key,
- "'\' in section \'",
- currentSectionName,
- "\' (line ",
- lineCounter,
- ")");
- } else {
- std::string value = line.substr(pos+1);
- trim(value);
- currentSection->mappings_[key] = value;
- }
- } else if (line.size() > 0) {
- COMMONAPI_ERROR("Missing \'=\' in key=value definition (line ",
- lineCounter, ")");
- }
- }
- }
- }
- return true;
+ std::size_t start = line.find('[');
+ if (start == 0) {
+ std::size_t end = line.find(']');
+ if (end != line.npos) {
+ currentSectionName = line.substr(++start, --end);
+ if (sections_.end() == sections_.find(currentSectionName)) {
+ currentSection = std::make_shared<Section>();
+ if (currentSection) {
+ sections_[currentSectionName] = currentSection;
+ }
+ } else {
+ COMMONAPI_ERROR("Double definition of section \'",
+ currentSectionName,
+ "\' ignoring definition (line ",
+ lineCounter,
+ ")");
+ currentSection = nullptr;
+ }
+ } else {
+ COMMONAPI_ERROR("Missing \']\' in section definition (line ",
+ lineCounter, ")");
+ }
+ } else if (currentSection) {
+ std::size_t pos = line.find('=');
+ if (pos != line.npos) {
+ std::string key = line.substr(0, pos);
+ trim(key);
+ if (currentSection->mappings_.end()
+ != currentSection->mappings_.find(key)) {
+ COMMONAPI_ERROR("Double definition for key \'",
+ key,
+ "'\' in section \'",
+ currentSectionName,
+ "\' (line ",
+ lineCounter,
+ ")");
+ } else {
+ std::string value = line.substr(pos+1);
+ trim(value);
+ currentSection->mappings_[key] = value;
+ }
+ } else if (line.size() > 0) {
+ COMMONAPI_ERROR("Missing \'=\' in key=value definition (line ",
+ lineCounter, ")");
+ }
+ }
+ }
+ }
+ return true;
}
const std::map<std::string, std::shared_ptr<IniFileReader::Section>> &
IniFileReader::getSections() const {
- return sections_;
+ return sections_;
}
std::shared_ptr<IniFileReader::Section>
IniFileReader::getSection(const std::string &_name) const {
- std::shared_ptr<IniFileReader::Section> section;
+ std::shared_ptr<IniFileReader::Section> section;
- auto sectionIterator = sections_.find(_name);
- if (sectionIterator != sections_.end()) {
- section = sectionIterator->second;
- }
+ auto sectionIterator = sections_.find(_name);
+ if (sectionIterator != sections_.end()) {
+ section = sectionIterator->second;
+ }
- return section;
+ return section;
}
} // namespace CommonAPI
diff --git a/src/CommonAPI/Logger.cpp b/src/CommonAPI/Logger.cpp
index f7e2de3..9527431 100644
--- a/src/CommonAPI/Logger.cpp
+++ b/src/CommonAPI/Logger.cpp
@@ -32,10 +32,10 @@ Logger::Level Logger::maximumLogLevel_(Logger::Level::LL_INFO);
Logger::Logger() {
#ifdef USE_DLT
- DLT_REGISTER_APP("CAPI", "CAPI");
- std::string context = Runtime::getProperty("LogContext");
- if (context == "") context = "CAPI";
- DLT_REGISTER_CONTEXT(dlt_, context.c_str(), "CAPI");
+ DLT_REGISTER_APP("CAPI", "CAPI");
+ std::string context = Runtime::getProperty("LogContext");
+ if (context == "") context = "CAPI";
+ DLT_REGISTER_CONTEXT(dlt_, context.c_str(), "CAPI");
#endif
}
@@ -49,110 +49,116 @@ Logger::~Logger() {
void
Logger::init(bool _useConsole, const std::string &_fileName, bool _useDlt, const std::string &_level) {
#ifdef USE_CONSOLE
- useConsole_ = _useConsole;
+ useConsole_ = _useConsole;
+#else
+ (void)_useConsole;
#endif
#ifdef USE_FILE
- if (_fileName != "") {
- file_ = std::make_shared<std::ofstream>();
- if (file_)
- file_->open(_fileName.c_str(), std::ofstream::out | std::ofstream::app);
- }
+ if (_fileName != "") {
+ file_ = std::make_shared<std::ofstream>();
+ if (file_)
+ file_->open(_fileName.c_str(), std::ofstream::out | std::ofstream::app);
+ }
+#else
+ (void)_fileName;
#endif
#ifdef USE_DLT
- useDlt_ = _useDlt;
+ useDlt_ = _useDlt;
+#else
+ (void)_useDlt;
#endif
#if defined(USE_CONSOLE) || defined(USE_FILE) || defined(USE_DLT)
- maximumLogLevel_ = stringAsLevel(_level);
+ maximumLogLevel_ = stringAsLevel(_level);
#endif
}
void
Logger::doLog(Level _level, const std::string &_message) {
#ifdef USE_CONSOLE
- if (useConsole_) {
+ if (useConsole_) {
std::lock_guard<std::mutex> itsLock(mutex_);
- std::cout << "[CAPI][" << levelAsString(_level) << "] " << _message << std::endl;
- }
+ std::cout << "[CAPI][" << levelAsString(_level) << "] " << _message << std::endl;
+ }
#endif
#ifdef USE_FILE
- if (file_ && file_->is_open()) {
+ if (file_ && file_->is_open()) {
std::lock_guard<std::mutex> itsLock(mutex_);
- (*(file_.get())) << "[CAPI][" << levelAsString(_level) << "] " << _message << std::endl;
- }
+ (*(file_.get())) << "[CAPI][" << levelAsString(_level) << "] " << _message << std::endl;
+ }
#endif
#ifdef USE_DLT
- if (useDlt_) {
- DLT_LOG_STRING(dlt_, levelAsDlt(_level), _message.c_str());
- }
+ if (useDlt_) {
+ DLT_LOG_STRING(dlt_, levelAsDlt(_level), _message.c_str());
+ }
#endif
}
#if defined(USE_CONSOLE) || defined(USE_FILE) || defined(USE_DLT)
Logger::Level
Logger::stringAsLevel(const std::string &_level) {
- if (_level == "fatal")
- return Level::LL_FATAL;
+ if (_level == "fatal")
+ return Level::LL_FATAL;
- if (_level == "error")
- return Level::LL_ERROR;
+ if (_level == "error")
+ return Level::LL_ERROR;
- if (_level == "warning")
- return Level::LL_WARNING;
+ if (_level == "warning")
+ return Level::LL_WARNING;
- if (_level == "info")
- return Level::LL_INFO;
+ if (_level == "info")
+ return Level::LL_INFO;
- if (_level == "debug")
- return Level::LL_DEBUG;
+ if (_level == "debug")
+ return Level::LL_DEBUG;
- if (_level == "verbose")
- return Level::LL_VERBOSE;
+ if (_level == "verbose")
+ return Level::LL_VERBOSE;
- return Level::LL_INFO;
+ return Level::LL_INFO;
}
#endif
#if defined(USE_CONSOLE) || defined(USE_FILE)
std::string
Logger::levelAsString(Logger::Level _level) {
- switch (_level) {
- case Level::LL_FATAL:
- return "FATAL";
- case Level::LL_ERROR:
- return "ERROR";
- case Level::LL_WARNING:
- return "WARNING";
- case Level::LL_INFO:
- return "INFO";
- case Level::LL_DEBUG:
- return "DEBUG";
- case Level::LL_VERBOSE:
- return "VERBOSE";
- default:
- return "";
- }
+ switch (_level) {
+ case Level::LL_FATAL:
+ return "FATAL";
+ case Level::LL_ERROR:
+ return "ERROR";
+ case Level::LL_WARNING:
+ return "WARNING";
+ case Level::LL_INFO:
+ return "INFO";
+ case Level::LL_DEBUG:
+ return "DEBUG";
+ case Level::LL_VERBOSE:
+ return "VERBOSE";
+ default:
+ return "";
+ }
}
#endif
#ifdef USE_DLT
DltLogLevelType
Logger::levelAsDlt(Logger::Level _level) {
- switch (_level) {
- case Level::LL_FATAL:
- return DLT_LOG_FATAL;
- case Level::LL_ERROR:
- return DLT_LOG_ERROR;
- case Level::LL_WARNING:
- return DLT_LOG_WARN;
- case Level::LL_INFO:
- return DLT_LOG_INFO;
- case Level::LL_DEBUG:
- return DLT_LOG_DEBUG;
- case Level::LL_VERBOSE:
- return DLT_LOG_VERBOSE;
- default:
- return DLT_LOG_DEFAULT;
- }
+ switch (_level) {
+ case Level::LL_FATAL:
+ return DLT_LOG_FATAL;
+ case Level::LL_ERROR:
+ return DLT_LOG_ERROR;
+ case Level::LL_WARNING:
+ return DLT_LOG_WARN;
+ case Level::LL_INFO:
+ return DLT_LOG_INFO;
+ case Level::LL_DEBUG:
+ return DLT_LOG_DEBUG;
+ case Level::LL_VERBOSE:
+ return DLT_LOG_VERBOSE;
+ default:
+ return DLT_LOG_DEFAULT;
+ }
}
#endif
diff --git a/src/CommonAPI/MainLoopContext.cpp b/src/CommonAPI/MainLoopContext.cpp
index c8bcb41..65346a6 100644
--- a/src/CommonAPI/MainLoopContext.cpp
+++ b/src/CommonAPI/MainLoopContext.cpp
@@ -12,7 +12,7 @@ int64_t getCurrentTimeInMs() {
}
const std::string &MainLoopContext::getName() const {
- return name_;
+ return name_;
}
DispatchSourceListenerSubscription MainLoopContext::subscribeForDispatchSources(DispatchSourceAddedCallback dispatchAddedCallback, DispatchSourceRemovedCallback dispatchRemovedCallback) {
diff --git a/src/CommonAPI/Proxy.cpp b/src/CommonAPI/Proxy.cpp
index 072fc30..8f672d2 100644
--- a/src/CommonAPI/Proxy.cpp
+++ b/src/CommonAPI/Proxy.cpp
@@ -9,7 +9,7 @@ namespace CommonAPI {
const Address &
Proxy::getAddress() const {
- return address_;
+ return address_;
}
} // namespace CommonAPI
diff --git a/src/CommonAPI/ProxyManager.cpp b/src/CommonAPI/ProxyManager.cpp
index ac3b263..3d55ff9 100644
--- a/src/CommonAPI/ProxyManager.cpp
+++ b/src/CommonAPI/ProxyManager.cpp
@@ -10,9 +10,9 @@ namespace CommonAPI {
std::shared_ptr<Proxy>
ProxyManager::createProxy(
- const std::string &_domain, const std::string &_interface, const std::string &_instance,
- const ConnectionId_t &_connection) const {
- return Runtime::get()->createProxy(_domain, _interface, _instance, _connection);
+ const std::string &_domain, const std::string &_interface, const std::string &_instance,
+ const ConnectionId_t &_connection) const {
+ return Runtime::get()->createProxy(_domain, _interface, _instance, _connection);
}
} // namespace CommonAPI
diff --git a/src/CommonAPI/Runtime.cpp b/src/CommonAPI/Runtime.cpp
index 9cd73eb..b226e52 100644
--- a/src/CommonAPI/Runtime.cpp
+++ b/src/CommonAPI/Runtime.cpp
@@ -161,10 +161,10 @@ Runtime::readConfiguration() {
std::shared_ptr<IniFileReader::Section> section
= reader.getSection("logging");
if (section) {
- std::string itsConsole = section->getValue("console");
- std::string itsFile = section->getValue("file");
- std::string itsDlt = section->getValue("dlt");
- std::string itsLevel = section->getValue("level");
+ itsConsole = section->getValue("console");
+ itsFile = section->getValue("file");
+ itsDlt = section->getValue("dlt");
+ itsLevel = section->getValue("level");
}
Logger::init((itsConsole == "true"),
@@ -208,13 +208,13 @@ Runtime::createProxy(
const ConnectionId_t &_connectionId) {
// Check whether we already know how to create such proxies...
- std::shared_ptr<Proxy> proxy = createProxyHelper(_domain, _interface, _instance, _connectionId);
+ std::shared_ptr<Proxy> proxy = createProxyHelper(_domain, _interface, _instance, _connectionId, false);
if (!proxy) {
// ...it seems do not, lets try to load a library that does...
std::lock_guard<std::mutex> itsGuard(loadMutex_);
std::string library = getLibrary(_domain, _interface, _instance, true);
if (loadLibrary(library)) {
- proxy = createProxyHelper(_domain, _interface, _instance, _connectionId);
+ proxy = createProxyHelper(_domain, _interface, _instance, _connectionId, true);
}
}
return proxy;
@@ -226,13 +226,13 @@ Runtime::createProxy(
std::shared_ptr<MainLoopContext> _context) {
// Check whether we already know how to create such proxies...
- std::shared_ptr<Proxy> proxy = createProxyHelper(_domain, _interface, _instance, _context);
+ std::shared_ptr<Proxy> proxy = createProxyHelper(_domain, _interface, _instance, _context, false);
if (!proxy) {
// ...it seems do not, lets try to load a library that does...
std::lock_guard<std::mutex> itsGuard(loadMutex_);
std::string library = getLibrary(_domain, _interface, _instance, true);
if (loadLibrary(library)) {
- proxy = createProxyHelper(_domain, _interface, _instance, _context);
+ proxy = createProxyHelper(_domain, _interface, _instance, _context, true);
}
}
return proxy;
@@ -243,12 +243,12 @@ bool
Runtime::registerStub(const std::string &_domain, const std::string &_interface, const std::string &_instance,
std::shared_ptr<StubBase> _stub, const ConnectionId_t &_connectionId) {
- bool isRegistered = registerStubHelper(_domain, _interface, _instance, _stub, _connectionId);
+ bool isRegistered = registerStubHelper(_domain, _interface, _instance, _stub, _connectionId, false);
if (!isRegistered) {
std::string library = getLibrary(_domain, _interface, _instance, false);
std::lock_guard<std::mutex> itsGuard(loadMutex_);
if (loadLibrary(library)) {
- isRegistered = registerStubHelper(_domain, _interface, _instance, _stub, _connectionId);
+ isRegistered = registerStubHelper(_domain, _interface, _instance, _stub, _connectionId, true);
}
}
return isRegistered;
@@ -258,12 +258,12 @@ bool
Runtime::registerStub(const std::string &_domain, const std::string &_interface, const std::string &_instance,
std::shared_ptr<StubBase> _stub, std::shared_ptr<MainLoopContext> _context) {
- bool isRegistered = registerStubHelper(_domain, _interface, _instance, _stub, _context);
+ bool isRegistered = registerStubHelper(_domain, _interface, _instance, _stub, _context, false);
if (!isRegistered) {
std::string library = getLibrary(_domain, _interface, _instance, false);
std::lock_guard<std::mutex> itsGuard(loadMutex_);
if (loadLibrary(library)) {
- isRegistered = registerStubHelper(_domain, _interface, _instance, _stub, _context);
+ isRegistered = registerStubHelper(_domain, _interface, _instance, _stub, _context, true);
}
}
return isRegistered;
@@ -304,7 +304,7 @@ Runtime::getLibrary(
library = getProperty("LibraryBase");
if (library != "") {
#ifdef WIN32
- library = library + "-" + defaultBinding_;
+ library = library + "-" + defaultBinding_;
#else
library = "lib" + library + "-" + defaultBinding_;
#endif
@@ -357,7 +357,7 @@ Runtime::loadLibrary(const std::string &_library) {
std::shared_ptr<Proxy>
Runtime::createProxyHelper(const std::string &_domain, const std::string &_interface, const std::string &_instance,
- const std::string &_connectionId) {
+ const std::string &_connectionId, bool _useDefault) {
std::lock_guard<std::mutex> itsLock(factoriesMutex_);
for (auto factory : factories_) {
std::shared_ptr<Proxy> proxy
@@ -365,14 +365,14 @@ Runtime::createProxyHelper(const std::string &_domain, const std::string &_inter
if (proxy)
return proxy;
}
- return (defaultFactory_ ?
+ return (_useDefault && defaultFactory_ ?
defaultFactory_->createProxy(_domain, _interface, _instance, _connectionId)
: nullptr);
}
std::shared_ptr<Proxy>
Runtime::createProxyHelper(const std::string &_domain, const std::string &_interface, const std::string &_instance,
- std::shared_ptr<MainLoopContext> _context ) {
+ std::shared_ptr<MainLoopContext> _context, bool _useDefault) {
std::lock_guard<std::mutex> itsLock(factoriesMutex_);
for (auto factory : factories_) {
std::shared_ptr<Proxy> proxy
@@ -380,14 +380,14 @@ Runtime::createProxyHelper(const std::string &_domain, const std::string &_inter
if (proxy)
return proxy;
}
- return (defaultFactory_ ?
+ return (_useDefault && defaultFactory_ ?
defaultFactory_->createProxy(_domain, _interface, _instance, _context) :
nullptr);
}
bool
Runtime::registerStubHelper(const std::string &_domain, const std::string &_interface, const std::string &_instance,
- std::shared_ptr<StubBase> _stub, const std::string &_connectionId) {
+ std::shared_ptr<StubBase> _stub, const std::string &_connectionId, bool _useDefault) {
bool isRegistered(false);
std::lock_guard<std::mutex> itsLock(factoriesMutex_);
for (auto factory : factories_) {
@@ -395,14 +395,14 @@ Runtime::registerStubHelper(const std::string &_domain, const std::string &_inte
if (isRegistered)
return isRegistered;
}
- return (defaultFactory_ ?
+ return (_useDefault && defaultFactory_ ?
defaultFactory_->registerStub(_domain, _interface, _instance, _stub, _connectionId) :
false);
}
bool
Runtime::registerStubHelper(const std::string &_domain, const std::string &_interface, const std::string &_instance,
- std::shared_ptr<StubBase> _stub, std::shared_ptr<MainLoopContext> _context) {
+ std::shared_ptr<StubBase> _stub, std::shared_ptr<MainLoopContext> _context, bool _useDefault) {
bool isRegistered(false);
std::lock_guard<std::mutex> itsLock(factoriesMutex_);
for (auto factory : factories_) {
@@ -410,7 +410,7 @@ Runtime::registerStubHelper(const std::string &_domain, const std::string &_inte
if (isRegistered)
return isRegistered;
}
- return (defaultFactory_ ?
+ return (_useDefault && defaultFactory_ ?
defaultFactory_->registerStub(_domain, _interface, _instance, _stub, _context) :
false);
}
diff --git a/src/CommonAPI/Utils.cpp b/src/CommonAPI/Utils.cpp
index 2540a86..31d9986 100644
--- a/src/CommonAPI/Utils.cpp
+++ b/src/CommonAPI/Utils.cpp
@@ -27,17 +27,17 @@ std::vector<std::string> split(const std::string& s, char delim) {
void trim(std::string& toTrim) {
toTrim.erase(
- toTrim.begin(),
- std::find_if(
- toTrim.begin(),
- toTrim.end(),
- std::not1(std::ptr_fun(isspace))
- )
- );
+ toTrim.begin(),
+ std::find_if(
+ toTrim.begin(),
+ toTrim.end(),
+ std::not1(std::ptr_fun(isspace))
+ )
+ );
toTrim.erase(
- std::find_if(
- toTrim.rbegin(),
+ std::find_if(
+ toTrim.rbegin(),
toTrim.rend(),
std::not1(std::ptr_fun(isspace))).base(),
toTrim.end()