Fawkes API Fawkes Development Version
lookup_thread.cpp
1/***************************************************************************
2 * lookup_thread.cpp - Get skill exec times from db lookups
3 *
4 * Created: Tue 24 Mar 2020 09:02:38 CET 09:02
5 * Copyright 2020 Tarik Viehmann <viehmann@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 "lookup_thread.h"
22
23#include "lookup_estimator.h"
24
25/** @class ExecutionTimeEstimatorLookupEstimatorThread
26 * Get estimates for skill execution times from samples of a mongodb database.
27 */
28
29/** Constructor. */
31: Thread("ExecutionTimeEstimatorLookupEstimatorThread", Thread::OPMODE_WAITFORWAKEUP)
32{
33}
34
35/** Register the estimator. */
36void
38{
39 estimator_ =
40 std::make_shared<fawkes::LookupEstimator>(mongodb_connmgr, config, cfg_prefix_, logger);
42 estimator_, config->get_int_or_default((std::string{cfg_prefix_} + "priority").c_str(), 0));
43}
44
45/** Unregister the estimator. */
46void
48{
50}
void finalize()
Unregister the estimator.
void init()
Register the estimator.
Configuration * config
This is the Configuration member used to access the configuration.
Definition: configurable.h:41
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
void register_provider(std::shared_ptr< ExecutionTimeEstimator > provider, int priority=0)
Add an execution time provider.
void unregister_provider(std::shared_ptr< ExecutionTimeEstimator > provider)
Remove an execution time estimate provider.
ExecutionTimeEstimatorManager * execution_time_estimator_manager_
The ExecutionTimeEstimatorManager that is used to manage the estimators.
Logger * logger
This is the Logger member used to access the logger.
Definition: logging.h:41
MongoDBConnCreator * mongodb_connmgr
Connection manager to retrieve more client connections from if necessary.
Definition: mongodb.h:55