Leosac  0.8.0
Open Source Access Control
CoreUtils.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014-2016 Leosac
3 
4  This file is part of Leosac.
5 
6  Leosac is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Affero General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Leosac is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Affero General Public License for more details.
15 
16  You should have received a copy of the GNU Affero General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #include "CoreUtils.hpp"
21 #include "kernel.hpp"
22 #include "tools/db/db_fwd.hpp"
23 #include "tools/log.hpp"
24 
26  Leosac::ConfigCheckerPtr cfgcheck, bool strict_mode)
27  : kptr_(kptr)
28  , scheduler_(sched)
29  , config_checker_(cfgcheck)
30  , strict_mode_(strict_mode)
31 {
32 }
33 
35  : kptr_(nullptr)
36  , strict_mode_(false)
37 {
38 }
39 
41 {
42  ASSERT_LOG(scheduler_, "No scheduler object in CoreUtils.");
43  return *scheduler_;
44 }
45 
47 {
48  ASSERT_LOG(config_checker_, "No ConfigChecker object in CoreUtils.");
49  return *config_checker_;
50 }
51 
53 {
54  return kernel().database();
55 }
56 
58 {
59  return strict_mode_;
60 }
61 
63 {
64  ASSERT_LOG(kptr_, "Kernel pointer is NULL in CoreUtils");
65  return *kptr_;
66 }
67 
69 {
70  return Leosac::CoreAPI(kernel());
71 }
72 
74 {
75  return kernel().zmqpp_context();
76 }
77 
79 {
80  return kernel().service_registry();
81 }
Leosac::CoreUtils::core_api
CoreAPI core_api()
Instantiate a new, ready to use, CoreAPI object.
Definition: CoreUtils.cpp:68
Leosac::CoreUtils::kernel
Kernel & kernel()
Definition: CoreUtils.cpp:62
Leosac::ConfigCheckerPtr
std::shared_ptr< ConfigChecker > ConfigCheckerPtr
Definition: LeosacFwd.hpp:32
Leosac::CoreUtils::CoreUtils
CoreUtils()
Definition: CoreUtils.cpp:34
ASSERT_LOG
#define ASSERT_LOG(cond, msg)
Definition: log.hpp:190
Leosac::DBPtr
std::shared_ptr< odb::database > DBPtr
Definition: db_fwd.hpp:31
Leosac::CoreUtils::scheduler
Scheduler & scheduler()
Definition: CoreUtils.cpp:40
Leosac::CoreUtils::is_strict
bool is_strict() const
Are we running in strict mode ?
Definition: CoreUtils.cpp:57
kernel.hpp
Leosac::ConfigChecker
This class is here to help check the validity of the configuration.
Definition: ConfigChecker.hpp:46
Leosac::Scheduler
This is a scheduler that is used internally to schedule asynchronous / long running tasks.
Definition: Scheduler.hpp:47
Leosac::ServiceRegistry
A class that manages services.
Definition: ServiceRegistry.hpp:110
Leosac::CoreUtils::database
DBPtr database()
Definition: CoreUtils.cpp:52
Leosac::Kernel
Core of Leosac.
Definition: kernel.hpp:73
Leosac::SchedulerPtr
std::shared_ptr< Scheduler > SchedulerPtr
Definition: LeosacFwd.hpp:31
log.hpp
CoreUtils.hpp
db_fwd.hpp
Leosac::CoreUtils::config_checker
ConfigChecker & config_checker()
Definition: CoreUtils.cpp:46
Leosac::CoreUtils::zmqpp_context
zmqpp::context & zmqpp_context()
Definition: CoreUtils.cpp:73
Leosac::CoreUtils::service_registry
ServiceRegistry & service_registry()
Definition: CoreUtils.cpp:78
Leosac::CoreAPI
CoreAPI is a class for interact with Leosac's core.
Definition: CoreAPI.hpp:47