class final
#include <core/reflection/type_client.hpp>
TypeClient Manages the client-side of a reflection channel on top of a stream.
This class allows the client to receive type information of types unknown by the client from the server. It also makes it possible to then receive and send values of these types.
Received types can be either structured or non-structured. Only values of structured types can be communicated between the client and the server. For a type to be structured, it must have a structural trait, so that the client can create new instances of the type.
Structural traits are traits which define the memory layout of a type. A structural trait should add the TypeClient::
See TypeServer for more information on the protocol.
Public types
-
using Deserialize = memory::
Function<bool(const TypeRegistry&, Type&, data:: Deserializer&) const > - Function type for deserializing traits.
-
using DiscoverTypes = void(*)(const Type&, memory::
Function<void(const Type&) const >&) - Function type for discovering new types from a trait.
Constructors, destructors, conversion operators
- TypeClient()
- Default constructor.
Public functions
- void addTrait(bool isStructural, const Type& traitType, Deserialize deserialize, DiscoverTypes discoverTypes)
- Registers a trait to be supported by the channel.
-
template<typename T>void addTrait(bool isStructural, Deserialize deserialize, DiscoverTypes discoverTypes)
- Registers a trait to be supported by the channel.
- void addType(const Type& type)
- Adds a known type to the channel.
-
template<typename T>void addType()
- Adds a known type to the channel.
-
auto connect(memory::
Stream& stream) const -> memory:: Opt<Connection> - Connects to a server, using the given stream.
Function documentation
void cubos:: core:: reflection:: TypeClient:: addTrait(bool isStructural,
const Type& traitType,
Deserialize deserialize,
DiscoverTypes discoverTypes)
Registers a trait to be supported by the channel.
Parameters | |
---|---|
isStructural | Whether the trait is a structural trait. |
traitType | Trait type to be registered. |
deserialize | Function to deserialize the trait. |
discoverTypes | Function to discover new types from the trait. |
template<typename T>
void cubos:: core:: reflection:: TypeClient:: addTrait(bool isStructural,
Deserialize deserialize,
DiscoverTypes discoverTypes)
Registers a trait to be supported by the channel.
Template parameters | |
---|---|
T | Trait type. |
Parameters | |
isStructural | Whether the trait is a structural trait. |
deserialize | Function to deserialize the trait. |
discoverTypes | Function to discover new types from the trait. |
memory:: Opt<Connection> cubos:: core:: reflection:: TypeClient:: connect(memory:: Stream& stream) const
Connects to a server, using the given stream.
Parameters | |
---|---|
stream | Stream. |
Returns | Connection information, or nothing if the connection failed. |