The MAUVE Toolchain
Core.hpp
1 /*
2  * Copyright 2017 ONERA
3  *
4  * This file is part of the MAUVE Runtime project.
5  *
6  * MAUVE Runtime is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License version 3 as
8  * published by the Free Software Foundation.
9  *
10  * MAUVE Runtime is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with MAUVE. If not, see <https://www.gnu.org/licenses/lgpl-3.0>.
17  */
18 #ifndef MAUVE_RUNTIME_CORE_HPP
19 #define MAUVE_RUNTIME_CORE_HPP
20 
21 #include "AbstractCore.hpp"
22 #include "WithHook.hpp"
23 #include "CoreContainer.hpp"
24 
25 namespace mauve {
26  namespace runtime {
27 
28  template <typename S>
29  class HasShell;
30 
31  class AbstractLogger;
32 
37  template <typename SHELL>
38  class Core
39  : public AbstractCore
40  , virtual public WithLogger
41  , virtual public WithHook
42  {
43 
44  public:
45  template <typename S, typename C, typename F>
46  friend class Component;
47  template <typename S, typename C, typename I>
48  friend class Resource;
49 
50  template <typename C>
51  friend class ExecState;
52  template <typename C>
53  friend class SynchroState;
54 
59  Core(Core const & core) = delete;
65  Core & operator=(Core const & core) = delete;
66 
67  std::string shell_type_name() const override;
68 
69  inline std::string container_name() const override { return _container->name(); };
70 
71  inline AbstractLogger& logger() const override { return _container->logger(); }
72 
73  inline bool is_configured() const override final { return _configured; }
74 
75  inline bool configure() override final { return _container->configure_core(); }
76  inline void cleanup() override final { _container->cleanup_core(); }
77 
78  protected:
80  Core();
82  virtual ~Core() noexcept;
83 
88  inline SHELL & shell() const { return _container->shell(); };
89 
90  private:
91  CoreContainer<SHELL>* _container;
92  bool _configured;
93 
94  bool _configure();
95  void _cleanup();
96  };
97 
98  }
99 } // namespace
100 
101 #include "ipp/Core.ipp"
102 
103 #endif // CORE_HPP
bool configure() overridefinal
Configure the object.
Definition: Core.hpp:75
SHELL & shell() const
Access to the instantiated shell.
Definition: Core.hpp:88
Core()
Default constructor.
Definition: Core.ipp:31
Objects with hooks.
Definition: WithHook.hpp:27
Object with a Logger.
Definition: WithLogger.hpp:27
Component class.
Definition: Architecture.hpp:34
virtual ~Core() noexcept
Default descructor.
Definition: Core.ipp:41
Class of a generic MAUVE logger.
Definition: logger.hpp:39
The MAUVE namespace.
Definition: tracing.hpp:24
Definition: AbstractCore.hpp:32
AbstractLogger & logger() const override
Get the logger.
Definition: Core.hpp:71
Core container.
Definition: CoreContainer.hpp:33
Definition: Architecture.hpp:38
Core & operator=(Core const &core)=delete
Copy operator.
bool is_configured() const overridefinal
Get the configuration status of the configurable object.
Definition: Core.hpp:73
Definition: Core.hpp:29
Definition: AbstractCore.hpp:30
The Core defines the methods of the component.
Definition: Core.hpp:38
void cleanup() overridefinal
Cleanup the object.
Definition: Core.hpp:76
std::string shell_type_name() const override
Get the shell type name.
Definition: Core.ipp:50
The Core defines the methods of the component.
Definition: AbstractCore.hpp:37
std::string container_name() const override
Get the core container name.
Definition: Core.hpp:69