diff options
Diffstat (limited to 'src/components/application_manager/src/policies/delegates/statistics_delegate.cc')
-rw-r--r-- | src/components/application_manager/src/policies/delegates/statistics_delegate.cc | 144 |
1 files changed, 72 insertions, 72 deletions
diff --git a/src/components/application_manager/src/policies/delegates/statistics_delegate.cc b/src/components/application_manager/src/policies/delegates/statistics_delegate.cc index a1f46a0373..e668be4ed1 100644 --- a/src/components/application_manager/src/policies/delegates/statistics_delegate.cc +++ b/src/components/application_manager/src/policies/delegates/statistics_delegate.cc @@ -33,83 +33,83 @@ #include "application_manager/policies/delegates/statistics_delegate.h" #include "application_manager/policies/policy_handler.h" -CREATE_LOGGERPTR_GLOBAL(logger_, "StatisticDelegate") +CREATE_LOGGERPTR_GLOBAL(logger_, "PolicyHandler") namespace policy { - StatisticsDelegate::StatisticsDelegate(usage_statistics::GlobalCounterId type) - : type_(INCREMENT_GLOBAL), - global_counter_(type), - app_counter_(usage_statistics::AppCounterId::APP_COUNTER_NONE), - app_info_(usage_statistics::AppInfoId::APP_INFO_NONE), - stop_watch_(usage_statistics::AppStopwatchId::STOPWATCH_NONE), - app_id_(""), - value_(""), - timespan_seconds_(0) { - - } - - StatisticsDelegate::StatisticsDelegate(const std::string& app_id, +StatisticsDelegate::StatisticsDelegate(PolicyHandler& policy_handler, + usage_statistics::GlobalCounterId type) + : type_(INCREMENT_GLOBAL) + , global_counter_(type) + , app_counter_(usage_statistics::AppCounterId::APP_COUNTER_NONE) + , app_info_(usage_statistics::AppInfoId::APP_INFO_NONE) + , stop_watch_(usage_statistics::AppStopwatchId::STOPWATCH_NONE) + , app_id_("") + , value_("") + , timespan_seconds_(0) + , policy_handler_(policy_handler) {} + +StatisticsDelegate::StatisticsDelegate(PolicyHandler& policy_handler, + const std::string& app_id, usage_statistics::AppCounterId type) - : type_(INCREMENT_APP), - global_counter_(usage_statistics::GlobalCounterId::GLOBAL_COUNTER_NONE), - app_counter_(type), - app_info_(usage_statistics::AppInfoId::APP_INFO_NONE), - stop_watch_(usage_statistics::AppStopwatchId::STOPWATCH_NONE), - app_id_(app_id), - value_(""), - timespan_seconds_(0) { - - } - - StatisticsDelegate::StatisticsDelegate(const std::string& app_id, + : type_(INCREMENT_APP) + , global_counter_(usage_statistics::GlobalCounterId::GLOBAL_COUNTER_NONE) + , app_counter_(type) + , app_info_(usage_statistics::AppInfoId::APP_INFO_NONE) + , stop_watch_(usage_statistics::AppStopwatchId::STOPWATCH_NONE) + , app_id_(app_id) + , value_("") + , timespan_seconds_(0) + , policy_handler_(policy_handler) {} + +StatisticsDelegate::StatisticsDelegate(PolicyHandler& policy_handler, + const std::string& app_id, usage_statistics::AppInfoId type, const std::string& value) - : type_(SET), - global_counter_(usage_statistics::GlobalCounterId::GLOBAL_COUNTER_NONE), - app_counter_(usage_statistics::AppCounterId::APP_COUNTER_NONE), - app_info_(type), - stop_watch_(usage_statistics::AppStopwatchId::STOPWATCH_NONE), - app_id_(app_id), - value_(value), - timespan_seconds_(0) { - - } - - StatisticsDelegate::StatisticsDelegate(const std::string& app_id, + : type_(SET) + , global_counter_(usage_statistics::GlobalCounterId::GLOBAL_COUNTER_NONE) + , app_counter_(usage_statistics::AppCounterId::APP_COUNTER_NONE) + , app_info_(type) + , stop_watch_(usage_statistics::AppStopwatchId::STOPWATCH_NONE) + , app_id_(app_id) + , value_(value) + , timespan_seconds_(0) + , policy_handler_(policy_handler) {} + +StatisticsDelegate::StatisticsDelegate(PolicyHandler& policy_handler, + const std::string& app_id, usage_statistics::AppStopwatchId type, int32_t timespan_seconds) - : type_(ADD), - global_counter_(usage_statistics::GlobalCounterId::GLOBAL_COUNTER_NONE), - app_counter_(usage_statistics::AppCounterId::APP_COUNTER_NONE), - app_info_(usage_statistics::AppInfoId::APP_INFO_NONE), - stop_watch_(type), - app_id_(app_id), - value_(""), - timespan_seconds_(timespan_seconds) { - + : type_(ADD) + , global_counter_(usage_statistics::GlobalCounterId::GLOBAL_COUNTER_NONE) + , app_counter_(usage_statistics::AppCounterId::APP_COUNTER_NONE) + , app_info_(usage_statistics::AppInfoId::APP_INFO_NONE) + , stop_watch_(type) + , app_id_(app_id) + , value_("") + , timespan_seconds_(timespan_seconds) + , policy_handler_(policy_handler) {} + +void StatisticsDelegate::threadMain() { + LOG4CXX_AUTO_TRACE(logger_); + switch (type_) { + case INCREMENT_GLOBAL: + policy_handler_.Increment(global_counter_); + break; + case INCREMENT_APP: + policy_handler_.Increment(app_id_, app_counter_); + break; + case SET: + policy_handler_.Set(app_id_, app_info_, value_); + break; + case ADD: + policy_handler_.Add(app_id_, stop_watch_, timespan_seconds_); + break; + default: + LOG4CXX_ERROR(logger_, "Unknown statistics operator"); + break; } +} - void StatisticsDelegate::threadMain() { - LOG4CXX_AUTO_TRACE(logger_); - switch (type_) { - case INCREMENT_GLOBAL: - PolicyHandler::instance()->Increment(global_counter_); - break; - case INCREMENT_APP: - PolicyHandler::instance()->Increment(app_id_, app_counter_); - break; - case SET: - PolicyHandler::instance()->Set(app_id_, app_info_, value_); - break; - case ADD: - PolicyHandler::instance()->Add(app_id_, stop_watch_, timespan_seconds_); - break; - default: - LOG4CXX_ERROR(logger_,"Unknown statistics operator"); - break; - } - } - - void StatisticsDelegate::exitThreadMain() { - // Do nothing - } -} // namespace policy +void StatisticsDelegate::exitThreadMain() { + // Do nothing +} +} // namespace policy |