annotate win64-msvc/include/capnp/rpc-prelude.h @ 133:1ac99bfc383d

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