COMMS
Template library intended to help with implementation of communication protocols.
Loading...
Searching...
No Matches
CustomValidator.h
1//
2// Copyright 2015 - 2024 (C). Alex Robenko. All rights reserved.
3//
4// This Source Code Form is subject to the terms of the Mozilla Public
5// License, v. 2.0. If a copy of the MPL was not distributed with this
6// file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
8#pragma once
9
10namespace comms
11{
12
13namespace field
14{
15
16namespace adapter
17{
18
19template <typename TValidator, typename TBase>
20class CustomValidator : public TBase
21{
22 using BaseImpl = TBase;
23 using Validator = TValidator;
24
25public:
26
27 using ValueType = typename BaseImpl::ValueType;
28
29 CustomValidator() = default;
30
31 explicit CustomValidator(const ValueType& val)
32 : BaseImpl(val)
33 {
34 }
35
36 explicit CustomValidator(ValueType&& val)
37 : BaseImpl(std::move(val))
38 {
39 }
40
41 CustomValidator(const CustomValidator&) = default;
42 CustomValidator(CustomValidator&&) = default;
43 CustomValidator& operator=(const CustomValidator&) = default;
44 CustomValidator& operator=(CustomValidator&&) = default;
45
46 bool valid() const
47 {
48 return BaseImpl::valid() && (Validator()(*this));
49 }
50};
51
52} // namespace adapter
53
54} // namespace field
55
56} // namespace comms
57
58
59
60
Main namespace for all classes / functions of COMMS library.
STL namespace.