comparison win64-msvc/include/capnp/rpc-prelude.h @ 47:d93140aac40b

Current Capnp libs and headers from git
author Chris Cannam
date Thu, 20 Oct 2016 18:15:38 +0100
parents
children 0f2d93caa50c
comparison
equal deleted inserted replaced
46:efe5b9f38b13 47:d93140aac40b
1 // Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors
2 // Licensed under the MIT License:
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a copy
5 // of this software and associated documentation files (the "Software"), to deal
6 // in the Software without restriction, including without limitation the rights
7 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 // copies of the Software, and to permit persons to whom the Software is
9 // furnished to do so, subject to the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 // THE SOFTWARE.
21
22 // This file contains a bunch of internal declarations that must appear before rpc.h can start.
23 // We don't define these directly in rpc.h because it makes the file hard to read.
24
25 #ifndef CAPNP_RPC_PRELUDE_H_
26 #define CAPNP_RPC_PRELUDE_H_
27
28 #if defined(__GNUC__) && !defined(CAPNP_HEADER_WARNINGS)
29 #pragma GCC system_header
30 #endif
31
32 #include "capability.h"
33 #include "persistent.capnp.h"
34
35 namespace capnp {
36
37 class OutgoingRpcMessage;
38 class IncomingRpcMessage;
39
40 template <typename SturdyRefHostId>
41 class RpcSystem;
42
43 namespace _ { // private
44
45 class VatNetworkBase {
46 // Non-template version of VatNetwork. Ignore this class; see VatNetwork in rpc.h.
47
48 public:
49 class Connection;
50
51 struct ConnectionAndProvisionId {
52 kj::Own<Connection> connection;
53 kj::Own<OutgoingRpcMessage> firstMessage;
54 Orphan<AnyPointer> provisionId;
55 };
56
57 class Connection {
58 public:
59 virtual kj::Own<OutgoingRpcMessage> newOutgoingMessage(uint firstSegmentWordSize) = 0;
60 virtual kj::Promise<kj::Maybe<kj::Own<IncomingRpcMessage>>> receiveIncomingMessage() = 0;
61 virtual kj::Promise<void> shutdown() = 0;
62 virtual AnyStruct::Reader baseGetPeerVatId() = 0;
63 };
64 virtual kj::Maybe<kj::Own<Connection>> baseConnect(AnyStruct::Reader vatId) = 0;
65 virtual kj::Promise<kj::Own<Connection>> baseAccept() = 0;
66 };
67
68 class SturdyRefRestorerBase {
69 public:
70 virtual Capability::Client baseRestore(AnyPointer::Reader ref) = 0;
71 };
72
73 class BootstrapFactoryBase {
74 // Non-template version of BootstrapFactory. Ignore this class; see BootstrapFactory in rpc.h.
75 public:
76 virtual Capability::Client baseCreateFor(AnyStruct::Reader clientId) = 0;
77 };
78
79 class RpcSystemBase {
80 // Non-template version of RpcSystem. Ignore this class; see RpcSystem in rpc.h.
81
82 public:
83 RpcSystemBase(VatNetworkBase& network, kj::Maybe<Capability::Client> bootstrapInterface,
84 kj::Maybe<RealmGateway<>::Client> gateway);
85 RpcSystemBase(VatNetworkBase& network, BootstrapFactoryBase& bootstrapFactory,
86 kj::Maybe<RealmGateway<>::Client> gateway);
87 RpcSystemBase(VatNetworkBase& network, SturdyRefRestorerBase& restorer);
88 RpcSystemBase(RpcSystemBase&& other) noexcept;
89 ~RpcSystemBase() noexcept(false);
90
91 private:
92 class Impl;
93 kj::Own<Impl> impl;
94
95 Capability::Client baseBootstrap(AnyStruct::Reader vatId);
96 Capability::Client baseRestore(AnyStruct::Reader vatId, AnyPointer::Reader objectId);
97 void baseSetFlowLimit(size_t words);
98
99 template <typename>
100 friend class capnp::RpcSystem;
101 };
102
103 template <typename T> struct InternalRefFromRealmGateway_;
104 template <typename InternalRef, typename ExternalRef, typename InternalOwner,
105 typename ExternalOwner>
106 struct InternalRefFromRealmGateway_<RealmGateway<InternalRef, ExternalRef, InternalOwner,
107 ExternalOwner>> {
108 typedef InternalRef Type;
109 };
110 template <typename T>
111 using InternalRefFromRealmGateway = typename InternalRefFromRealmGateway_<T>::Type;
112 template <typename T>
113 using InternalRefFromRealmGatewayClient = InternalRefFromRealmGateway<typename T::Calls>;
114
115 template <typename T> struct ExternalRefFromRealmGateway_;
116 template <typename InternalRef, typename ExternalRef, typename InternalOwner,
117 typename ExternalOwner>
118 struct ExternalRefFromRealmGateway_<RealmGateway<InternalRef, ExternalRef, InternalOwner,
119 ExternalOwner>> {
120 typedef ExternalRef Type;
121 };
122 template <typename T>
123 using ExternalRefFromRealmGateway = typename ExternalRefFromRealmGateway_<T>::Type;
124 template <typename T>
125 using ExternalRefFromRealmGatewayClient = ExternalRefFromRealmGateway<typename T::Calls>;
126
127 } // namespace _ (private)
128 } // namespace capnp
129
130 #endif // CAPNP_RPC_PRELUDE_H_