CatapultServer  v0.5.0.1 (Elephant)
EntityType.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "FacilityCode.h"
23 #include "catapult/utils/Casting.h"
24 #include <iosfwd>
25 #include <stdint.h>
26 
27 namespace catapult { namespace model {
28 
31  enum class BasicEntityType : uint8_t {
33  Other = 0x0,
34 
36  Transaction = 0x1,
37 
39  Block = 0x2
40  };
41 
43  enum class EntityType : uint16_t {};
44 
46  constexpr EntityType MakeEntityType(BasicEntityType basicEntityType, FacilityCode facilityCode, uint8_t code) {
47  return static_cast<EntityType>(
48  (static_cast<uint16_t>(basicEntityType) & 0x03) << 14 | // 01..02: type
49  ((code & 0xF) << 8) | // 05..08: code
50  (static_cast<uint8_t>(facilityCode) & 0xFF)); // 09..16: facility
51  }
52 
54 #define DEFINE_ENTITY_TYPE(BASIC_TYPE, FACILITY, DESCRIPTION, CODE) \
55  constexpr auto Entity_Type_##DESCRIPTION = model::MakeEntityType( \
56  (model::BasicEntityType::BASIC_TYPE), \
57  (model::FacilityCode::FACILITY), \
58  CODE)
59 
61  DEFINE_ENTITY_TYPE(Block, Core, Nemesis_Block, 0);
62 
64  DEFINE_ENTITY_TYPE(Block, Core, Block, 1);
65 
67 #define DEFINE_TRANSACTION_TYPE(FACILITY, DESCRIPTION, CODE) DEFINE_ENTITY_TYPE(Transaction, FACILITY, DESCRIPTION, CODE)
68 
71  // - 0x8000: block bit
72  // - 0x4000: transaction bit
73  return 0x8000 == (utils::to_underlying_type(type) & 0xC000)
76  }
77 
79  std::ostream& operator<<(std::ostream& out, EntityType entityType);
80 }}
catapult::model::BasicEntityType::Block
Block type.
HashLockEntityType.h
catapult::utils::HexFormat
constexpr void HexFormat(const ByteArray< N, TTag > &)
catapult::model::MakeEntityType
constexpr EntityType MakeEntityType(BasicEntityType basicEntityType, FacilityCode facilityCode, uint8_t code)
Makes entity type given basicEntityType, facilityCode and code.
Definition: EntityType.h:46
catapult::model::EntityType
EntityType
Enumeration of entity types.
Definition: EntityType.h:43
catapult::utils::to_underlying_type
constexpr std::underlying_type_t< TEnum > to_underlying_type(TEnum value)
Converts a strongly typed enumeration value to its underlying integral value.
Definition: Casting.h:37
catapult::model::ToBasicEntityType
constexpr BasicEntityType ToBasicEntityType(EntityType type)
Converts an entity type into a basic entity type.
Definition: EntityType.h:70
EntityType.h
catapult::model::DEFINE_ENTITY_TYPE
DEFINE_ENTITY_TYPE(Block, Core, Nemesis_Block, 0)
Nemesis block.
catapult::model::FacilityCode
FacilityCode
Possible facility codes.
Definition: model/FacilityCode.h:27
TransferEntityType.h
MosaicEntityType.h
AccountLinkEntityType.h
SecretLockEntityType.h
MultisigEntityType.h
MacroBasedEnumIncludes.h
AccountRestrictionEntityType.h
catapult::model::BasicEntityType::Other
Some other type.
CASE_WELL_KNOWN_ENTITY_TYPE
#define CASE_WELL_KNOWN_ENTITY_TYPE(NAME)
Definition: EntityType.cpp:28
catapult::model::operator<<
std::ostream & operator<<(std::ostream &out, const EmbeddedTransaction &transaction)
Insertion operator for outputting transaction to out.
Definition: EmbeddedTransaction.cpp:28
catapult::model::Block
Binary layout for a block.
Definition: Block.h:69
AggregateEntityType.h
NamespaceEntityType.h
Casting.h
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::model::BasicEntityType::Transaction
Transaction type.
FacilityCode.h
catapult::model::BasicEntityType
BasicEntityType
Definition: EntityType.h:31
catapult::model::Transaction
Binary layout for a transaction.
Definition: Transaction.h:32