Mir
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"
29 
30 namespace mir
31 {
32 namespace client
33 {
34 
48 namespace rpc
49 {
69 {
70 public:
75  virtual ~StreamTransport() = default;
76 
77  /* Delete CopyAssign */
78  StreamTransport() = default;
79  StreamTransport(StreamTransport const&) = delete;
80  StreamTransport& operator=(StreamTransport const&) = delete;
81 
87  class Observer
88  {
89  public:
90  Observer() = default;
91  virtual ~Observer() = default;
95  virtual void on_data_available() = 0;
101  virtual void on_disconnected() = 0;
102 
103  Observer(Observer const&) = delete;
104  Observer& operator=(Observer const&) = delete;
105  };
106 
111  virtual void register_observer(std::shared_ptr<Observer> const& observer) = 0;
112 
122  virtual void receive_data(void* buffer, size_t bytes_requested) = 0;
123 
137  virtual void receive_data(void* buffer, size_t bytes_requested, std::vector<Fd>& fds) = 0;
138 
146  virtual void send_message(std::vector<uint8_t> const& buffer, std::vector<Fd> const& fds) = 0;
147 };
148 
149 }
150 }
151 }
152 
153 #endif // MIR_CLIENT_RPC_STREAM_TRANSPORT_H_
StreamTransport & operator=(StreamTransport const &)=delete
All things Mir.
Definition: buffer_stream.h:37
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:68
virtual void send_message(std::vector< uint8_t > const &buffer, std::vector< Fd > const &fds)=0
Write message to the server.
virtual ~StreamTransport()=default
virtual void on_disconnected()=0
Called by the Transport when the connection to the server has been broken.
Definition: dispatchable.h:38
virtual void receive_data(void *buffer, size_t bytes_requested)=0
Read data from the server.
Observer of IO status.
Definition: stream_transport.h:87

Copyright © 2012,2013 Canonical Ltd.
Generated on Tue Mar 24 16:15:19 UTC 2015