CatapultServer
v0.5.0.1 (Elephant)
|
Go to the documentation of this file.
26 namespace catapult {
namespace ionet {
44 template<
typename TEntity>
49 m_payload.
m_buffers.push_back({ reinterpret_cast<const uint8_t*>(pEntity.get()), pEntity->Size });
55 template<
typename TEntity>
57 for (
const auto& pEntity : entities) {
66 template<
typename TEntityGenerator>
69 auto pEntity = generator();
79 template<
typename TEntity>
81 auto rangeSize = static_cast<uint32_t>(
sizeof(TEntity) * range.size());
86 m_payload.
m_buffers.push_back({ reinterpret_cast<const uint8_t*>(range.data()), rangeSize });
94 template<
typename TValue>
99 auto pValue = std::make_shared<TValue>(value);
100 m_payload.
m_buffers.push_back({ reinterpret_cast<const uint8_t*>(pValue.get()),
sizeof(TValue) });
106 template<
typename TValue>
108 auto valuesSize = static_cast<uint32_t>(
sizeof(TValue) * values.size());
112 if (!values.empty()) {
113 auto pValues = utils::MakeSharedWithSize<uint8_t>(valuesSize);
114 std::memcpy(pValues.get(), values.data(), valuesSize);
124 template<
typename TValueGenerator>
126 using ValueType = std::remove_const_t<std::remove_reference_t<decltype(*generator())>>;
127 std::vector<ValueType> values;
129 auto pValue = generator();
133 values.push_back(*pValue);
bool appendGeneratedValues(TValueGenerator &&generator)
Definition: PacketPayloadBuilder.h:125
std::vector< RawBuffer > m_buffers
Definition: PacketPayload.h:56
std::vector< std::shared_ptr< const void > > m_entities
Definition: PacketPayload.h:59
Represents a range of entities.
Definition: EntityRange.h:31
bool appendEntity(const std::shared_ptr< TEntity > &pEntity)
Appends a single entity (pEntity) to the payload.
Definition: PacketPayloadBuilder.h:45
bool appendValue(const TValue &value)
Appends a fixed size value to the payload.
Definition: PacketPayloadBuilder.h:95
PacketType
An enumeration of known packet types.
Definition: PacketType.h:171
A packet payload builder for creating payloads composed of heterogeneous data.
Definition: PacketPayloadBuilder.h:29
uint32_t m_maxPacketDataSize
Definition: PacketPayloadBuilder.h:158
constexpr bool IsPacketDataSizeValid(const PacketHeader &header, size_t maxPacketDataSize)
Determines if header indicates a valid packet data size no greater than maxPacketDataSize.
Definition: PacketHeader.h:41
bool appendValues(const std::vector< TValue > &values)
Appends fixed size values to the payload.
Definition: PacketPayloadBuilder.h:107
bool appendGeneratedEntities(TEntityGenerator &&generator)
Appends all entities produced by generator to the payload.
Definition: PacketPayloadBuilder.h:67
PacketHeader m_header
Definition: PacketPayload.h:55
PacketPayloadBuilder(PacketType type, uint32_t maxPacketDataSize)
Creates builder for a packet with the specified type and max packet data size (maxPacketDataSize).
Definition: PacketPayloadBuilder.h:36
PacketPayload m_payload
Definition: PacketPayloadBuilder.h:159
PacketPayload build()
Builds the packet payload.
Definition: PacketPayloadBuilder.h:141
A packet payload that can be written.
Definition: PacketPayload.h:29
Definition: AddressExtractionExtension.cpp:28
PacketPayloadBuilder(PacketType type)
Creates builder for a packet with the specified type.
Definition: PacketPayloadBuilder.h:32
bool m_hasError
Definition: PacketPayloadBuilder.h:160
bool increaseSize(uint32_t numBytes)
Definition: PacketPayloadBuilder.h:146
bool appendRange(model::EntityRange< TEntity > &&range)
Appends a fixed size range to the payload.
Definition: PacketPayloadBuilder.h:80
bool CheckedAdd(T &value, T delta)
Adds delta to value if and only if there is no overflow.
Definition: IntegerMath.h:30
bool appendEntities(const std::vector< std::shared_ptr< TEntity >> &entities)
Appends all entities to the payload.
Definition: PacketPayloadBuilder.h:56