CatapultServer  v0.5.0.1 (Elephant)
PacketPayloadFactory.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "PacketPayloadBuilder.h"
23 
24 namespace catapult { namespace ionet {
25 
28  public:
30  template<typename TEntity>
31  static PacketPayload FromEntity(PacketType type, const std::shared_ptr<TEntity>& pEntity) {
32  return FromEntities<TEntity>(type, { pEntity });
33  }
34 
36  template<typename TEntity>
37  static PacketPayload FromEntities(PacketType type, const std::vector<std::shared_ptr<TEntity>>& entities) {
38  PacketPayloadBuilder builder(type);
39  builder.appendEntities(entities);
40  return builder.build();
41  }
42 
44  template<typename TStructure>
46  PacketPayloadBuilder builder(type);
47  builder.appendRange(std::move(range));
48  return builder.build();
49  }
50  };
51 }}
catapult::model::EntityRange
Represents a range of entities.
Definition: EntityRange.h:31
catapult::ionet::PacketType
PacketType
An enumeration of known packet types.
Definition: PacketType.h:171
catapult::ionet::PacketPayloadBuilder
A packet payload builder for creating payloads composed of heterogeneous data.
Definition: PacketPayloadBuilder.h:29
PacketPayloadBuilder.h
catapult::ionet::PacketPayloadFactory::FromFixedSizeRange
static PacketPayload FromFixedSizeRange(PacketType type, model::EntityRange< TStructure > &&range)
Creates a packet payload with the specified packet type around a fixed size structure range.
Definition: PacketPayloadFactory.h:45
catapult::ionet::PacketPayloadFactory
A factory for creating common packet payloads.
Definition: PacketPayloadFactory.h:27
catapult::ionet::PacketPayloadBuilder::build
PacketPayload build()
Builds the packet payload.
Definition: PacketPayloadBuilder.h:141
catapult::ionet::PacketPayload
A packet payload that can be written.
Definition: PacketPayload.h:29
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::ionet::PacketPayloadFactory::FromEntities
static PacketPayload FromEntities(PacketType type, const std::vector< std::shared_ptr< TEntity >> &entities)
Creates a packet payload with the specified packet type around multiple entities.
Definition: PacketPayloadFactory.h:37
catapult::ionet::PacketPayloadFactory::FromEntity
static PacketPayload FromEntity(PacketType type, const std::shared_ptr< TEntity > &pEntity)
Creates a packet payload with the specified packet type around a single entity (pEntity).
Definition: PacketPayloadFactory.h:31
catapult::ionet::PacketPayloadBuilder::appendRange
bool appendRange(model::EntityRange< TEntity > &&range)
Appends a fixed size range to the payload.
Definition: PacketPayloadBuilder.h:80
catapult::ionet::PacketPayloadBuilder::appendEntities
bool appendEntities(const std::vector< std::shared_ptr< TEntity >> &entities)
Appends all entities to the payload.
Definition: PacketPayloadBuilder.h:56