CatapultServer  v0.5.0.1 (Elephant)
ValidatorTypes.h
Go to the documentation of this file.
1 
21 #pragma once
23 #include "EntityValidator.h"
27 #include "catapult/functions.h"
28 #include <memory>
29 #include <vector>
30 
31 namespace catapult { namespace validators {
32 
33  struct ValidatorContext;
34 
35  template<typename... TArgs>
36  class AggregateEntityValidatorT;
37 
38  template<typename... TArgs>
39  class DemuxValidatorBuilderT;
40 
43 
45  template<typename... TArgs>
46  using ValidatorVectorT = std::vector<std::unique_ptr<const EntityValidatorT<TArgs...>>>;
47 
50 
52  using ValidationFunctions = std::vector<ValidationFunction>;
53 
55  template<typename TResult>
56  using ValidationPolicyFunc = std::function<TResult (const model::WeakEntityInfos&, const ValidationFunctions&)>;
57 
58  namespace stateless {
59  template<typename TNotification>
61 
62  template<typename TNotification>
63  using NotificationValidatorPointerT = std::unique_ptr<const NotificationValidatorT<TNotification>>;
64 
65  template<typename TNotification>
67 
70 
74  }
75 
76  namespace stateful {
77  template<typename TNotification>
79 
80  template<typename TNotification>
81  using NotificationValidatorPointerT = std::unique_ptr<const NotificationValidatorT<TNotification>>;
82 
83  template<typename TNotification>
86 
89 
93  }
94 
96 #define DECLARE_STATELESS_VALIDATOR(NAME, NOTIFICATION_TYPE) \
97  stateless::NotificationValidatorPointerT<NOTIFICATION_TYPE> Create##NAME##Validator
98 
101 #define MAKE_STATELESS_VALIDATOR(NAME, HANDLER) \
102  std::make_unique<stateless::FunctionalNotificationValidatorT<validators::Notification>>(#NAME "Validator", HANDLER);
103 
106 #define DEFINE_STATELESS_VALIDATOR(NAME, HANDLER) \
107  DECLARE_STATELESS_VALIDATOR(NAME, validators::Notification)() { \
108  return MAKE_STATELESS_VALIDATOR(NAME, HANDLER); \
109  }
110 
112 #define DEFINE_STATELESS_VALIDATOR_WITH_TYPE(NAME, NOTIFICATION_TYPE, HANDLER) \
113  DECLARE_STATELESS_VALIDATOR(NAME, NOTIFICATION_TYPE)() { \
114  return std::make_unique<stateless::FunctionalNotificationValidatorT<NOTIFICATION_TYPE>>(#NAME "Validator", HANDLER); \
115  }
116 
118 #define DECLARE_STATEFUL_VALIDATOR(NAME, NOTIFICATION_TYPE) \
119  stateful::NotificationValidatorPointerT<NOTIFICATION_TYPE> Create##NAME##Validator
120 
123 #define MAKE_STATEFUL_VALIDATOR(NAME, HANDLER) \
124  std::make_unique<stateful::FunctionalNotificationValidatorT<validators::Notification>>(#NAME "Validator", HANDLER);
125 
128 #define DEFINE_STATEFUL_VALIDATOR(NAME, HANDLER) \
129  DECLARE_STATEFUL_VALIDATOR(NAME, validators::Notification)() { \
130  return MAKE_STATEFUL_VALIDATOR(NAME, HANDLER); \
131  }
132 
134 #define DEFINE_STATEFUL_VALIDATOR_WITH_TYPE(NAME, NOTIFICATION_TYPE, HANDLER) \
135  DECLARE_STATEFUL_VALIDATOR(NAME, NOTIFICATION_TYPE)() { \
136  return std::make_unique<stateful::FunctionalNotificationValidatorT<NOTIFICATION_TYPE>>(#NAME "Validator", HANDLER); \
137  }
138 }}
catapult::validators::ValidationFunction
std::function< ValidationResult(const model::WeakEntityInfo &)> ValidationFunction
A validation function.
Definition: ValidatorTypes.h:49
AggregateNotificationValidator.h
catapult::validators::DemuxValidatorBuilderT
A demultiplexing validator builder.
Definition: DemuxValidatorBuilder.h:31
catapult::validators::FunctionalNotificationValidatorT
Notification validator that wraps a function.
Definition: FunctionalNotificationValidator.h:29
catapult::validators::ValidationPolicyFunc
std::function< TResult(const model::WeakEntityInfos &, const ValidationFunctions &)> ValidationPolicyFunc
Function signature for validation policies.
Definition: ValidatorTypes.h:56
catapult::predicate
std::function< bool(TArgs...)> predicate
A predicate function.
Definition: functions.h:31
catapult::validators::NotificationValidatorT
A strongly typed notification validator.
Definition: NotificationValidator.h:30
catapult::validators::ValidationResult
ValidationResult
Enumeration of all possible validation results.
Definition: ValidationResult.h:51
WeakEntityInfo.h
catapult::validators::stateless::NotificationValidatorPointerT
std::unique_ptr< const NotificationValidatorT< TNotification > > NotificationValidatorPointerT
Definition: ValidatorTypes.h:63
FunctionalNotificationValidator.h
functions.h
catapult::model::WeakEntityInfoT
Wrapper around a strongly typed entity and its associated metadata.
Definition: WeakEntityInfo.h:33
catapult::validators::EntityValidatorT
Definition: EntityValidator.h:31
catapult::validators::AggregateNotificationValidatorT
A strongly typed aggregate notification validator.
Definition: AggregateNotificationValidator.h:29
VerifiableEntity.h
catapult::validators::AggregateEntityValidatorT
An aggregate validator.
Definition: AggregateEntityValidator.h:31
EntityValidator.h
catapult::validators::ValidationResultPredicate
predicate< ValidationResult > ValidationResultPredicate
Validation result predicate.
Definition: ValidatorTypes.h:42
catapult::validators::ValidatorVectorT
std::vector< std::unique_ptr< const EntityValidatorT< TArgs... > >> ValidatorVectorT
A vector of validators.
Definition: ValidatorTypes.h:46
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::validators::stateful::NotificationValidatorPointerT
std::unique_ptr< const NotificationValidatorT< TNotification > > NotificationValidatorPointerT
Definition: ValidatorTypes.h:81
catapult::validators::ValidationFunctions
std::vector< ValidationFunction > ValidationFunctions
A vector of validation functions.
Definition: ValidatorTypes.h:52
catapult::model::WeakEntityInfos
std::vector< WeakEntityInfo > WeakEntityInfos
A container of weak entity infos.
Definition: WeakEntityInfo.h:144