Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
stream_transport.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2014 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17  */
18 
19 
20 #ifndef MIR_CLIENT_RPC_STREAM_TRANSPORT_H_
21 #define MIR_CLIENT_RPC_STREAM_TRANSPORT_H_
22 
23 #include <vector>
24 #include <memory>
25 #include <stdint.h>
26 
27 #include "mir/fd.h"
28 
29 namespace mir
30 {
31 namespace client
32 {
33 
47 namespace rpc
48 {
68 {
69 public:
74  virtual ~StreamTransport() = default;
75 
76  /* Delete CopyAssign */
77  StreamTransport() = default;
78  StreamTransport(StreamTransport const&) = delete;
79  StreamTransport& operator=(StreamTransport const&) = delete;
80 
86  class Observer
87  {
88  public:
89  Observer() = default;
90  virtual ~Observer() = default;
94  virtual void on_data_available() = 0;
100  virtual void on_disconnected() = 0;
101 
102  Observer(Observer const&) = delete;
103  Observer& operator=(Observer const&) = delete;
104  };
105 
112  virtual void register_observer(std::shared_ptr<Observer> const& observer) = 0;
113 
123  virtual void receive_data(void* buffer, size_t bytes_requested) = 0;
124 
138  virtual void receive_data(void* buffer, size_t bytes_requested, std::vector<Fd>& fds) = 0;
139 
146  virtual void send_data(std::vector<uint8_t> const& buffer) = 0;
147 };
148 
149 }
150 }
151 }
152 
153 #endif // MIR_CLIENT_RPC_STREAM_TRANSPORT_H_
StreamTransport & operator=(StreamTransport const &)=delete
All things Mir.
Definition: aging_buffer.h:24
virtual void register_observer(std::shared_ptr< Observer > const &observer)=0
Register an IO observer.
virtual void on_data_available()=0
Called by the Transport when data is available for reading.
Observer & operator=(Observer const &)=delete
Responsible for shuttling bytes to and from the server.
Definition: stream_transport.h:67
virtual void send_data(std::vector< uint8_t > const &buffer)=0
Write data to the server.
virtual ~StreamTransport()=default
virtual void on_disconnected()=0
Called by the Transport when the connection to the server has been broken.
virtual void receive_data(void *buffer, size_t bytes_requested)=0
Read data from the server.
Observer of IO status.
Definition: stream_transport.h:86

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Oct 10 14:07:14 UTC 2014