Chris@64: // Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors Chris@64: // Licensed under the MIT License: Chris@64: // Chris@64: // Permission is hereby granted, free of charge, to any person obtaining a copy Chris@64: // of this software and associated documentation files (the "Software"), to deal Chris@64: // in the Software without restriction, including without limitation the rights Chris@64: // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell Chris@64: // copies of the Software, and to permit persons to whom the Software is Chris@64: // furnished to do so, subject to the following conditions: Chris@64: // Chris@64: // The above copyright notice and this permission notice shall be included in Chris@64: // all copies or substantial portions of the Software. Chris@64: // Chris@64: // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR Chris@64: // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, Chris@64: // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE Chris@64: // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER Chris@64: // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, Chris@64: // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN Chris@64: // THE SOFTWARE. Chris@64: Chris@64: // This file contains a bunch of internal declarations that must appear before rpc.h can start. Chris@64: // We don't define these directly in rpc.h because it makes the file hard to read. Chris@64: Chris@64: #ifndef CAPNP_RPC_PRELUDE_H_ Chris@64: #define CAPNP_RPC_PRELUDE_H_ Chris@64: Chris@64: #if defined(__GNUC__) && !defined(CAPNP_HEADER_WARNINGS) Chris@64: #pragma GCC system_header Chris@64: #endif Chris@64: Chris@64: #include "capability.h" Chris@64: #include "persistent.capnp.h" Chris@64: Chris@64: namespace capnp { Chris@64: Chris@64: class OutgoingRpcMessage; Chris@64: class IncomingRpcMessage; Chris@64: Chris@64: template Chris@64: class RpcSystem; Chris@64: Chris@64: namespace _ { // private Chris@64: Chris@64: class VatNetworkBase { Chris@64: // Non-template version of VatNetwork. Ignore this class; see VatNetwork in rpc.h. Chris@64: Chris@64: public: Chris@64: class Connection; Chris@64: Chris@64: struct ConnectionAndProvisionId { Chris@64: kj::Own connection; Chris@64: kj::Own firstMessage; Chris@64: Orphan provisionId; Chris@64: }; Chris@64: Chris@64: class Connection { Chris@64: public: Chris@64: virtual kj::Own newOutgoingMessage(uint firstSegmentWordSize) = 0; Chris@64: virtual kj::Promise>> receiveIncomingMessage() = 0; Chris@64: virtual kj::Promise shutdown() = 0; Chris@64: virtual AnyStruct::Reader baseGetPeerVatId() = 0; Chris@64: }; Chris@64: virtual kj::Maybe> baseConnect(AnyStruct::Reader vatId) = 0; Chris@64: virtual kj::Promise> baseAccept() = 0; Chris@64: }; Chris@64: Chris@64: class SturdyRefRestorerBase { Chris@64: public: Chris@64: virtual Capability::Client baseRestore(AnyPointer::Reader ref) = 0; Chris@64: }; Chris@64: Chris@64: class BootstrapFactoryBase { Chris@64: // Non-template version of BootstrapFactory. Ignore this class; see BootstrapFactory in rpc.h. Chris@64: public: Chris@64: virtual Capability::Client baseCreateFor(AnyStruct::Reader clientId) = 0; Chris@64: }; Chris@64: Chris@64: class RpcSystemBase { Chris@64: // Non-template version of RpcSystem. Ignore this class; see RpcSystem in rpc.h. Chris@64: Chris@64: public: Chris@64: RpcSystemBase(VatNetworkBase& network, kj::Maybe bootstrapInterface, Chris@64: kj::Maybe::Client> gateway); Chris@64: RpcSystemBase(VatNetworkBase& network, BootstrapFactoryBase& bootstrapFactory, Chris@64: kj::Maybe::Client> gateway); Chris@64: RpcSystemBase(VatNetworkBase& network, SturdyRefRestorerBase& restorer); Chris@64: RpcSystemBase(RpcSystemBase&& other) noexcept; Chris@64: ~RpcSystemBase() noexcept(false); Chris@64: Chris@64: private: Chris@64: class Impl; Chris@64: kj::Own impl; Chris@64: Chris@64: Capability::Client baseBootstrap(AnyStruct::Reader vatId); Chris@64: Capability::Client baseRestore(AnyStruct::Reader vatId, AnyPointer::Reader objectId); Chris@64: void baseSetFlowLimit(size_t words); Chris@64: Chris@64: template Chris@64: friend class capnp::RpcSystem; Chris@64: }; Chris@64: Chris@64: template struct InternalRefFromRealmGateway_; Chris@64: template Chris@64: struct InternalRefFromRealmGateway_> { Chris@64: typedef InternalRef Type; Chris@64: }; Chris@64: template Chris@64: using InternalRefFromRealmGateway = typename InternalRefFromRealmGateway_::Type; Chris@64: template Chris@64: using InternalRefFromRealmGatewayClient = InternalRefFromRealmGateway; Chris@64: Chris@64: template struct ExternalRefFromRealmGateway_; Chris@64: template Chris@64: struct ExternalRefFromRealmGateway_> { Chris@64: typedef ExternalRef Type; Chris@64: }; Chris@64: template Chris@64: using ExternalRefFromRealmGateway = typename ExternalRefFromRealmGateway_::Type; Chris@64: template Chris@64: using ExternalRefFromRealmGatewayClient = ExternalRefFromRealmGateway; Chris@64: Chris@64: } // namespace _ (private) Chris@64: } // namespace capnp Chris@64: Chris@64: #endif // CAPNP_RPC_PRELUDE_H_