The MAUVE Toolchain
CallPort.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_CALL_PORT_HPP
19 #define MAUVE_RUNTIME_CALL_PORT_HPP
20 
21 #include "Port.hpp"
22 
23 namespace mauve {
24  namespace runtime {
25 
26  template <typename R, typename ...P>
27  class CallService;
28 
30  template <typename R, typename ...P>
31  class CallPort final: public Port<CallService<R, P...>> {
32  public:
33  friend class HasPort;
34  CallPort() = delete;
35  CallPort(CallPort const & other) = delete;
36 
37  connection_type get_type() const override { return CALL; }
38 
39  std::string type_name() const override;
40 
42  const R default_value;
43 
45  R call(P... parameters) const;
46 
48  inline R operator()(P... parameters) const { return call(parameters ...); };
49 
50  private:
51  CallPort(HasPort* container, std::string const & name, R default_value);
52  ~CallPort() noexcept;
53  };
54 
55  }
56 } // namespace
57 
58 #include "ipp/CallPort.ipp"
59 
60 #endif
std::string type_name() const override
Get port type name.
Definition: Port.hpp:31
Class of a Call service.
Definition: CallPort.hpp:27
const std::string name
Port name.
Definition: AbstractPort.hpp:49
Definition: HasPort.hpp:41
The MAUVE namespace.
Definition: tracing.hpp:24
connection_type get_type() const override
Get port type.
Definition: CallPort.hpp:37
R operator()(P...parameters) const
Helper to call the service implicitely.
Definition: CallPort.hpp:48
R call(P...parameters) const
Call a service with a set of parameters.
const R default_value
Default returned value.
Definition: CallPort.hpp:42
connection_type
Port types.
Definition: AbstractPort.hpp:28
A Port to call a service.
Definition: CallPort.hpp:31