ProxyPipe.h
1 /*
2  * qb - C++ Actor Framework
3  * Copyright (C) 2011-2019 isndev (www.qbaf.io). All rights reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef QB_PROXYPIPE_H
19 #define QB_PROXYPIPE_H
20 # include <qb/system/allocator/pipe.h>
21 # include "ActorId.h"
22 # include "Event.h"
23 
24 namespace qb {
25  using Pipe = allocator::pipe<CacheLine>;
26 
33  class ProxyPipe {
34  Pipe *pipe;
35  ActorId dest;
36  ActorId source;
37 
38  public:
39  ProxyPipe() = default;
40  ProxyPipe(ProxyPipe const &) = default;
41  ProxyPipe &operator=(ProxyPipe const &) = default;
42 
43  ProxyPipe(Pipe &i_pipe, ActorId i_dest, ActorId i_source)
44  : pipe(&i_pipe), dest(i_dest), source(i_source) {}
45 
53  template<typename T, typename ..._Args>
54  T &push(_Args &&...args);
55 
64  template<typename T, typename ..._Args>
65  T &allocated_push(std::size_t size, _Args &&...args);
66 
71  inline ActorId getDestination() const {
72  return dest;
73  }
74 
79  inline ActorId getSource() const {
80  return source;
81  }
82 
83  };
84 
85 } // namespace qb
86 
87 #endif //QB_PROXYPIPE_H
T & allocated_push(std::size_t size, _Args &&...args)
ActorId getSource() const
Definition: ProxyPipe.h:79
Object returned by Actor::getPipe()
Definition: ProxyPipe.h:33
ActorId getDestination() const
Definition: ProxyPipe.h:71
Actor unique identifier.
Definition: ActorId.h:35
T & push(_Args &&...args)
Definition: pipe.h:35