Fawkes API  Fawkes Development Version
execution_time_estimator_thread.cpp
1 /***************************************************************************
2  * execution_time_estimator_thread.cpp -
3  *
4  * Created: Thu 23 Apr 2020 17:07:11 CEST 17:07
5  * Copyright 2020 Till Hofmann <hofmann@kbsg.rwth-aachen.de>
6  ****************************************************************************/
7 
8 /* This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Library General Public License for more details.
17  *
18  * Read the full text in the LICENSE.GPL file in the doc directory.
19  */
20 
21 #include "execution_time_estimator_thread.h"
22 
23 #include "estimators/config_estimator.h"
24 
25 /** @class ExecutionTimeEstimatorsThread
26  * The plugin thread, initializes the aspect.
27  *
28  * @author Till Hofmann
29  */
30 
31 constexpr char ExecutionTimeEstimatorsThread::cfg_prefix_[];
32 
33 ExecutionTimeEstimatorsThread::ExecutionTimeEstimatorsThread()
34 : Thread("ExecutionTimeEstimatorThread", Thread::OPMODE_WAITFORWAKEUP),
35  AspectProviderAspect(&provider_inifin_),
36  provider_inifin_(&execution_time_estimator_manager_)
37 {
38 }
39 
40 void
42 {
43  execution_time_estimator_manager_.register_provider(
44  std::make_shared<fawkes::ConfigExecutionTimeEstimator>(config, cfg_prefix_),
45  config->get_int_or_default((std::string{cfg_prefix_} + "priority").c_str(), 0));
46 }
ExecutionTimeEstimatorsThread::init
void init() override
Initialize the thread.
Definition: execution_time_estimator_thread.cpp:41
fawkes::ExecutionTimeEstimatorManager::register_provider
void register_provider(std::shared_ptr< ExecutionTimeEstimator > provider, int priority=0)
Add an execution time provider.
Definition: execution_time_estimator.cpp:58
fawkes::ConfigurableAspect::config
Configuration * config
This is the Configuration member used to access the configuration.
Definition: configurable.h:41
fawkes::Configuration::get_int_or_default
virtual int get_int_or_default(const char *path, const int &default_val)
Get value from configuration which is of type int, or the given default if the path does not exist.
Definition: config.cpp:716