The MAUVE Toolchain
AbstractComponent.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_ABSTRACT_COMPONENT_HPP
19 #define MAUVE_RUNTIME_ABSTRACT_COMPONENT_HPP
20 
21 #include "Configurable.hpp"
22 #include "WithName.hpp"
23 #include "WithAbstractShell.hpp"
24 #include "WithAbstractCore.hpp"
25 #include "WithAbstractFSM.hpp"
26 #include "WithLogger.hpp"
27 #include "common.hpp"
28 
29 #include <string>
30 #include <iostream>
31 #include <pthread.h>
32 
33 namespace mauve {
34  namespace runtime {
35 
36  class Task;
37  class AbstractState;
38  class ComponentLogger;
39 
44  : virtual public Configurable
45  , virtual public WithAbstractShell
46  , virtual public WithAbstractCore
47  , virtual public WithAbstractFSM
48  , virtual public WithLogger
49  , virtual public WithName
50  {
51  public:
52  friend class Task;
53 
57  AbstractComponent(std::string const & name);
59  virtual ~AbstractComponent();
60 
62  inline std::string name() const override final { return _name; };
64  std::string type_name() const;
65 
67  virtual AbstractState * current_state() = 0;
68 
70  virtual bool is_empty () const = 0;
72  virtual bool is_created () const = 0;
74  virtual bool is_activated () const = 0;
76  virtual bool is_running () const = 0;
77 
79  virtual bool clear() = 0;
80 
82  virtual void disconnect() = 0;
83 
85  virtual bool step() = 0;
86 
88  virtual time_ns_t get_time() const = 0;
89 
94  virtual int get_priority() const = 0;
95 
103  virtual bool set_priority(int priority) = 0;
104 
109  virtual int get_cpu() const = 0;
110 
119  virtual bool set_cpu(int cpu) = 0;
120 
121  protected:
123 
124  private:
125  std::string _name;
126  virtual bool run() = 0;
128  virtual void set_task(Task* task) = 0;
129  };
130 
131  } // namespace runtime
132 } // namespace mauve
133 
134 #endif // MAUVE_RUNTIME_ABSTRACT_COMPONENT_HPP
virtual bool set_cpu(int cpu)=0
Set the affinity of the task of the component to a single processor.
Trait for objects with an abstract FSM.
Definition: WithAbstractFSM.hpp:27
Class of a MAUVE logger for a component.
Definition: logger.hpp:188
virtual time_ns_t get_time() const =0
Get the component current time.
virtual bool is_activated() const =0
Check if the component is activated.
virtual int get_priority() const =0
Get the priority of the component real-time task.
virtual ~AbstractComponent()
Destructor.
virtual bool step()=0
Make one step on the component FSM.
Trait for objects with an abstract Core.
Definition: WithAbstractCore.hpp:27
virtual bool set_priority(int priority)=0
Sets the real-time task priority.
Object with a name.
Definition: WithName.hpp:27
Object with a Logger.
Definition: WithLogger.hpp:27
The MAUVE namespace.
Definition: tracing.hpp:24
virtual AbstractLogger & logger() const =0
Get the logger.
virtual AbstractState * current_state()=0
Get component current State.
Abstract State class.
Definition: AbstractState.hpp:34
Configurable trait.
Definition: Configurable.hpp:25
virtual int get_cpu() const =0
Get the cpu mapping of the component task.
std::string type_name() const
Get component type name.
virtual bool clear()=0
Clear the component.
std::string name() const overridefinal
Get component name.
Definition: AbstractComponent.hpp:62
virtual bool is_running() const =0
Check if the component is running.
virtual bool is_empty() const =0
Check if the component is empty (i.e.
AbstractComponent(std::string const &name)
Constructor.
virtual bool is_created() const =0
Check if the component is created.
virtual void disconnect()=0
Disconnect the component.
Trait for objects with an abstract Shell.
Definition: WithAbstractShell.hpp:27
Abstract Component class.
Definition: AbstractComponent.hpp:43
A system Task that executes a component.
Definition: Task.hpp:46