The MAUVE Toolchain
Architecture.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_ARCHITECTURE_HPP
19 #define MAUVE_RUNTIME_ARCHITECTURE_HPP
20 
21 #include <string>
22 #include <vector>
23 
24 #include "Configurable.hpp"
25 #include "WithHook.hpp"
26 #include "WithLogger.hpp"
27 #include "AbstractDeployer.hpp"
28 
29 namespace mauve {
30  namespace runtime {
31 
32  class AbstractComponent;
33  template <typename S, typename C, typename F>
34  class Component;
35 
36  class AbstractResource;
37  template <typename S, typename C, typename I>
38  class Resource;
39 
42  : virtual public Configurable
43  , virtual public WithHook
44  , virtual public WithLogger
45  {
46  public:
47  Architecture();
48  virtual ~Architecture();
49 
51  std::string type_name() const;
52 
54  inline bool is_configured() const override final { return _configured; };
56  bool configure() override final;
58  void cleanup() override final;
59 
60  bool configure_hook() override;
61  void cleanup_hook() override;
62 
64  const std::vector<AbstractComponent*> get_components();
65 
66  std::size_t get_components_size() const { return components.size(); }
67 
68  AbstractComponent* get_component(int id);
69 
71  const std::vector<AbstractResource *> get_resources();
72 
73  std::size_t get_resources_size() const { return resources.size(); }
74 
75  AbstractResource* get_resource(int id) const;
76 
77  AbstractResource* get_resource(const std::string & name) const;
78 
79  int get_resource_index(const AbstractResource* resource) const;
80 
81  int get_resource_index(const std::string & name) const;
82 
83  protected:
84 
85  inline AbstractLogger& logger() const override {
86  return *logger_;
87  }
88 
89  // ---------- Component ----------
90 
91  template <typename COMPONENT>
92  COMPONENT & mk_component(std::string const & name);
93 
94  template <typename COMPONENT, typename ...P>
95  COMPONENT & mk_component(std::string const & name, P... parameters);
96 
97  template <typename COMPONENT>
98  COMPONENT & mk_empty_component(std::string const & name);
99 
100  template <typename SHELL, typename CORE, typename FSM>
101  Component<SHELL, CORE, FSM> & mk_component(std::string const & name);
102 
103  template <typename SHELL, typename CORE, typename FSM, typename ...P>
104  Component<SHELL, CORE, FSM> & mk_component(std::string const & name, P... parameters);
105 
106  template <typename SHELL, typename CORE, typename FSM>
107  Component<SHELL, CORE, FSM> & mk_empty_component(std::string const & name);
108 
109  // ---------- Resource ----------
110 
111  template <typename RESOURCE>
112  RESOURCE & mk_resource(std::string const & name);
113 
114  template <typename RESOURCE, typename ...P>
115  RESOURCE & mk_resource(std::string const & name, P... parameters);
116 
117  template <typename RESOURCE>
118  RESOURCE & mk_empty_resource(std::string const & name);
119 
120  template <typename SHELL, typename CORE, typename INTERFACE>
121  Resource<SHELL, CORE, INTERFACE> & mk_resource(std::string const & name);
122 
123  template <typename SHELL, typename CORE, typename INTERFACE, typename ...P>
124  Resource<SHELL, CORE, INTERFACE> & mk_resource(std::string const & name, P... parameters);
125 
126  template <typename SHELL, typename CORE, typename INTERFACE>
127  Resource<SHELL, CORE, INTERFACE> & mk_empty_resource(std::string const & name);
128 
129  private:
130  bool _configured;
131 
132  AbstractLogger* logger_;
133 
134  std::vector<AbstractComponent*> components;
135  std::vector<AbstractResource *> resources;
136 
137  };
138 
139  }
140 } /* namespace mauve */
141 
142 #include "ipp/Architecture.ipp"
143 
144 #endif
const std::vector< AbstractResource * > get_resources()
Get the set of architecture resources.
bool configure_hook() override
Hook function called when configuring the shell.
Architecture class.
Definition: Architecture.hpp:41
void cleanup_hook() override
Hook function called when cleaning the shell.
Objects with hooks.
Definition: WithHook.hpp:27
Object with a Logger.
Definition: WithLogger.hpp:27
Component class.
Definition: Architecture.hpp:34
Class of a generic MAUVE logger.
Definition: logger.hpp:39
The MAUVE namespace.
Definition: tracing.hpp:24
Definition: Architecture.hpp:38
Configurable trait.
Definition: Configurable.hpp:25
bool is_configured() const overridefinal
Check if the architecture is configured.
Definition: Architecture.hpp:54
const std::vector< AbstractComponent * > get_components()
Get the set of architecture components.
void cleanup() overridefinal
Cleanup the architecture.
AbstractLogger & logger() const override
Get the logger.
Definition: Architecture.hpp:85
bool configure() overridefinal
Configure the architecture.
Abstract Resource class.
Definition: AbstractResource.hpp:37
Abstract Component class.
Definition: AbstractComponent.hpp:43
std::string type_name() const
Architecture type name.