The MAUVE Toolchain
Shell.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_SHELL_HPP
19 #define MAUVE_RUNTIME_SHELL_HPP
20 
21 #include "HasProperty.hpp"
22 #include "HasPort.hpp"
23 #include "AbstractPort.hpp"
24 #include "ShellContainer.hpp"
25 #include "WithLogger.hpp"
26 #include "Configurable.hpp"
27 #include "WithHook.hpp"
28 #include "WithName.hpp"
29 
30 #include <exception>
31 #include <string>
32 #include <vector>
33 #include <type_traits>
34 
35 namespace mauve {
36  namespace runtime {
37 
38  class AbstractLogger;
39 
40  // ========================= Shell =========================
41 
48  class Shell
49  : virtual public HasProperty
50  , virtual public HasPort
51  , virtual public WithLogger
52  , virtual public Configurable
53  , virtual public WithHook
54  , virtual public WithName
55  {
56 
57  public:
58 
59  template <typename S, typename C, typename F>
60  friend class Component;
61  template <typename S, typename C, typename I>
62  friend class Resource;
63 
69  Shell(const Shell& shell) = delete;
70 
75  std::string type_name() const;
76 
77  inline AbstractLogger& logger() const override { return _container->logger(); }
78 
79  inline bool is_configured() const override final { return _configured; }
80 
81  inline bool configure() override final { return _container->configure_shell(); }
82  inline void cleanup() override final { _container->cleanup_shell(); }
83 
88  void print_model(std::ostream& out) const;
89 
93  virtual std::string name() const override final {
94  return this->_container->name(); };
95 
96  protected:
98  Shell();
100  virtual ~Shell() noexcept;
101 
102  private:
103  ShellContainer* _container;
104  bool _configured;
105 
106  bool _configure();
107  void _cleanup();
108  };
109 
116  std::ostream& operator<<(std::ostream& out, Shell const & shell);
117 
118  }
119 }
120 
121 #endif // SHELL_HPP
virtual std::string name() const =0
Get the name.
std::string type_name() const
Get the Shell type name.
Definition: ShellContainer.hpp:28
Shell()
Default constructor.
Definition: HasProperty.hpp:53
Object with a name.
Definition: WithName.hpp:27
Objects with hooks.
Definition: WithHook.hpp:27
Object with a Logger.
Definition: WithLogger.hpp:27
Component class.
Definition: Architecture.hpp:34
AbstractLogger & logger() const override
Get the logger.
Definition: Shell.hpp:77
Class of a generic MAUVE logger.
Definition: logger.hpp:39
Definition: HasPort.hpp:41
The MAUVE namespace.
Definition: tracing.hpp:24
virtual bool cleanup_shell()=0
Clean up the shell.
virtual AbstractLogger & logger() const =0
Get the logger.
Definition: Architecture.hpp:38
Configurable trait.
Definition: Configurable.hpp:25
void print_model(std::ostream &out) const
Print the Shell model.
A Shell is the interface of a component.
Definition: Shell.hpp:48
virtual ~Shell() noexcept
Default destructor.
void cleanup() overridefinal
Cleanup the object.
Definition: Shell.hpp:82
virtual std::string name() const overridefinal
Get Component name.
Definition: Shell.hpp:93
virtual bool configure_shell()=0
Configure th shell.
bool configure() overridefinal
Configure the object.
Definition: Shell.hpp:81
bool is_configured() const overridefinal
Get the configuration status of the configurable object.
Definition: Shell.hpp:79