The MAUVE Toolchain
AbstractPort.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_PORT_HPP
19 #define MAUVE_RUNTIME_ABSTRACT_PORT_HPP
20 
21 #include <string>
22 #include <vector>
23 
24 namespace mauve {
25  namespace runtime {
26 
28  enum connection_type { EVENT, READ, WRITE, CALL };
29 
30  class Service;
31 
35  class AbstractPort {
36  public:
37  AbstractPort() = delete;
41  AbstractPort(std::string const & name);
45  AbstractPort(const AbstractPort & other) = delete;
46  virtual ~AbstractPort() noexcept;
47 
49  const std::string name;
50 
52  virtual connection_type get_type() const = 0;
53 
55  virtual std::string type_name() const = 0;
56 
58  virtual bool is_connected() const = 0;
60  virtual bool disconnect() = 0;
61 
63  virtual bool connect_service (Service * service) = 0;
64 
66  virtual std::vector<Service*> connected_services() const = 0;
67 
69  virtual std::size_t connections_size() const = 0;
70 
72  virtual Service* get_connection(int index) const = 0;
73  };
74 
75  }
76 } /* namespace mauve */
77 
78 #endif
virtual connection_type get_type() const =0
Get port type.
Abstract Port class.
Definition: AbstractPort.hpp:35
const std::string name
Port name.
Definition: AbstractPort.hpp:49
virtual bool connect_service(Service *service)=0
Connect the port to a service.
virtual bool is_connected() const =0
Check if the port is connected.
virtual std::vector< Service * > connected_services() const =0
Get the list of connected services.
The MAUVE namespace.
Definition: tracing.hpp:24
A Service.
Definition: Service.hpp:30
connection_type
Port types.
Definition: AbstractPort.hpp:28
virtual Service * get_connection(int index) const =0
Get connected Service according to the index.
virtual std::size_t connections_size() const =0
Get the number of connected services.
virtual bool disconnect()=0
Disconnect the port.
virtual std::string type_name() const =0
Get port type name.