CatapultServer  v0.5.0.1 (Elephant)
AggregateEntityValidator.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "ValidatorTypes.h"
25 #include <memory>
26 
27 namespace catapult { namespace validators {
28 
30  template<typename... TArgs>
32  public:
33  using ValidatorVector = ValidatorVectorT<TArgs...>;
34 
35  public:
38  : m_validators(std::move(validators))
39  {}
40 
41  public:
44  public:
46  explicit DispatchForwarder(ValidationFunctions&& validationFunctions)
47  : m_validationFunctions(std::move(validationFunctions))
48  {}
49 
50  public:
52  template<typename TDispatcher>
53  auto dispatch(const TDispatcher& dispatcher, const model::WeakEntityInfos& entityInfos) const {
54  return dispatcher(entityInfos, m_validationFunctions);
55  }
56 
57  private:
59  };
60 
61 #ifdef __clang__
62 #pragma clang diagnostic push
63 // clang generates this warning when curry() is called without arguments
64 #pragma clang diagnostic ignored "-Wunused-lambda-capture"
65 #endif
66 
68  template<typename... TCurryArgs>
69  DispatchForwarder curry(TCurryArgs&&... args) const {
70  ValidationFunctions validationFunctions;
71  validationFunctions.reserve(m_validators.size());
72  auto forwardedArgs = std::make_tuple(std::forward<TCurryArgs>(args)...);
73  for (const auto& pValidator : m_validators) {
74  validationFunctions.emplace_back([&pValidator, forwardedArgs](const auto& entityInfo) {
75  return pValidator->validate(entityInfo, std::get<TArgs>(forwardedArgs)...);
76  });
77  }
78 
79  return DispatchForwarder(std::move(validationFunctions));
80  }
81 
82 #ifdef __clang__
83 #pragma clang diagnostic pop
84 #endif
85 
87  std::vector<std::string> names() const {
89  }
90 
91  private:
93  };
94 }}
catapult::utils::ExtractNames
std::vector< std::string > ExtractNames(const TNamedObjects &namedObjects)
Extracts all names from namedObjects.
Definition: NamedObject.h:46
catapult::validators::AggregateEntityValidatorT::names
std::vector< std::string > names() const
Gets the names of all sub validators.
Definition: AggregateEntityValidator.h:87
catapult::validators::AggregateEntityValidatorT::DispatchForwarder::dispatch
auto dispatch(const TDispatcher &dispatcher, const model::WeakEntityInfos &entityInfos) const
Dispatches validation of entityInfos to dispatcher.
Definition: AggregateEntityValidator.h:53
catapult::validators::AggregateEntityValidatorT::DispatchForwarder::DispatchForwarder
DispatchForwarder(ValidationFunctions &&validationFunctions)
Creates a forwarder around validators.
Definition: AggregateEntityValidator.h:46
catapult::validators::AggregateEntityValidatorT::DispatchForwarder
Helper for invoking curried validators.
Definition: AggregateEntityValidator.h:43
catapult::validators::AggregateEntityValidatorT::DispatchForwarder::m_validationFunctions
ValidationFunctions m_validationFunctions
Definition: AggregateEntityValidator.h:58
catapult::validators::AggregateEntityValidatorT::m_validators
ValidatorVector m_validators
Definition: AggregateEntityValidator.h:92
VerifiableEntity.h
catapult::validators::AggregateEntityValidatorT::AggregateEntityValidatorT
AggregateEntityValidatorT(ValidatorVector &&validators)
Creates an aggregate validator around validators.
Definition: AggregateEntityValidator.h:37
NamedObject.h
catapult::validators::AggregateEntityValidatorT
An aggregate validator.
Definition: AggregateEntityValidator.h:31
catapult::validators::ValidatorVectorT
std::vector< std::unique_ptr< const EntityValidatorT< TArgs... > >> ValidatorVectorT
A vector of validators.
Definition: ValidatorTypes.h:46
ValidatorTypes.h
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::validators::AggregateEntityValidatorT::ValidatorVector
ValidatorVectorT< TArgs... > ValidatorVector
Definition: AggregateEntityValidator.h:33
catapult::validators::AggregateEntityValidatorT::curry
DispatchForwarder curry(TCurryArgs &&... args) const
Prepares the invocation of sub validators by currying args to invocations made on the returned forwar...
Definition: AggregateEntityValidator.h:69
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