|
| 1 | +#pragma once |
| 2 | +#include <vector> |
| 3 | +#include "adm/detail/auto_base.hpp" |
| 4 | +#include "adm/detail/named_option_helper.hpp" |
| 5 | +#include "adm/detail/optional_comparison.hpp" |
| 6 | + |
| 7 | +namespace adm { |
| 8 | + struct ProfileValueTag {}; |
| 9 | + using ProfileValue = detail::NamedType<std::string, ProfileValueTag>; |
| 10 | + |
| 11 | + struct ProfileNameTag {}; |
| 12 | + using ProfileName = detail::NamedType<std::string, ProfileNameTag>; |
| 13 | + |
| 14 | + struct ProfileVersionTag {}; |
| 15 | + using ProfileVersion = detail::NamedType<std::string, ProfileVersionTag>; |
| 16 | + |
| 17 | + struct ProfileLevelTag {}; |
| 18 | + using ProfileLevel = detail::NamedType<std::string, ProfileLevelTag>; |
| 19 | + |
| 20 | + struct ProfileTag {}; |
| 21 | + |
| 22 | + namespace detail { |
| 23 | + extern template class ADM_EXPORT_TEMPLATE_METHODS |
| 24 | + RequiredParameter<ProfileValue>; |
| 25 | + extern template class ADM_EXPORT_TEMPLATE_METHODS |
| 26 | + RequiredParameter<ProfileName>; |
| 27 | + extern template class ADM_EXPORT_TEMPLATE_METHODS |
| 28 | + RequiredParameter<ProfileVersion>; |
| 29 | + extern template class ADM_EXPORT_TEMPLATE_METHODS |
| 30 | + RequiredParameter<ProfileLevel>; |
| 31 | + |
| 32 | + using ProfileBase = HasParameters< |
| 33 | + RequiredParameter<ProfileValue>, RequiredParameter<ProfileName>, |
| 34 | + RequiredParameter<ProfileVersion>, RequiredParameter<ProfileLevel>>; |
| 35 | + } // namespace detail |
| 36 | + |
| 37 | + class Profile : private detail::ProfileBase, |
| 38 | + public detail::AddWrapperMethods<Profile> { |
| 39 | + public: |
| 40 | + using tag = ProfileTag; |
| 41 | + |
| 42 | + template <typename... Parameters> |
| 43 | + explicit Profile(Parameters... namedArgs) { |
| 44 | + detail::setNamedOptionHelper(this, std::move(namedArgs)...); |
| 45 | + static_assert(detail::optionInList<ProfileValue, Parameters...>(), |
| 46 | + "ProfileValue must be specified"); |
| 47 | + static_assert(detail::optionInList<ProfileName, Parameters...>(), |
| 48 | + "ProfileName must be specified"); |
| 49 | + static_assert(detail::optionInList<ProfileVersion, Parameters...>(), |
| 50 | + "ProfileVersion must be specified"); |
| 51 | + static_assert(detail::optionInList<ProfileLevel, Parameters...>(), |
| 52 | + "ProfileLevel must be specified"); |
| 53 | + } |
| 54 | + |
| 55 | + using detail::ProfileBase::set; |
| 56 | + using detail::AddWrapperMethods<Profile>::get; |
| 57 | + using detail::AddWrapperMethods<Profile>::has; |
| 58 | + using detail::AddWrapperMethods<Profile>::isDefault; |
| 59 | + using detail::AddWrapperMethods<Profile>::unset; |
| 60 | + |
| 61 | + private: |
| 62 | + using detail::ProfileBase::get; |
| 63 | + using detail::ProfileBase::has; |
| 64 | + |
| 65 | + friend class detail::AddWrapperMethods<Profile>; |
| 66 | + }; |
| 67 | + |
| 68 | + inline bool operator==(const Profile &a, const Profile &b) { |
| 69 | + return detail::optionalsEqual<ProfileValue, ProfileName, ProfileVersion, |
| 70 | + ProfileLevel>(a, b); |
| 71 | + } |
| 72 | + |
| 73 | + inline bool operator!=(const Profile &a, const Profile &b) { |
| 74 | + return !(a == b); |
| 75 | + } |
| 76 | + |
| 77 | + struct ProfilesTag {}; |
| 78 | + |
| 79 | + using Profiles = std::vector<Profile>; |
| 80 | + ADD_TRAIT(Profiles, ProfilesTag); |
| 81 | + |
| 82 | + namespace detail { |
| 83 | + extern template class ADM_EXPORT_TEMPLATE_METHODS VectorParameter<Profiles>; |
| 84 | + |
| 85 | + using ProfileListBase = HasParameters<VectorParameter<Profiles>>; |
| 86 | + } // namespace detail |
| 87 | + |
| 88 | + struct ProfileceListTag {}; |
| 89 | + |
| 90 | + class ProfileList : private detail::ProfileListBase, |
| 91 | + public detail::AddWrapperMethods<ProfileList> { |
| 92 | + public: |
| 93 | + using tag = ProfileceListTag; |
| 94 | + |
| 95 | + template <typename... Parameters> |
| 96 | + explicit ProfileList(Parameters... namedArgs) { |
| 97 | + detail::setNamedOptionHelper(this, std::move(namedArgs)...); |
| 98 | + } |
| 99 | + |
| 100 | + using detail::ProfileListBase::set; |
| 101 | + using detail::AddWrapperMethods<ProfileList>::get; |
| 102 | + using detail::AddWrapperMethods<ProfileList>::has; |
| 103 | + using detail::AddWrapperMethods<ProfileList>::isDefault; |
| 104 | + using detail::AddWrapperMethods<ProfileList>::unset; |
| 105 | + using detail::ProfileListBase::add; |
| 106 | + using detail::ProfileListBase::remove; |
| 107 | + |
| 108 | + private: |
| 109 | + using detail::ProfileListBase::get; |
| 110 | + using detail::ProfileListBase::has; |
| 111 | + using detail::ProfileListBase::isDefault; |
| 112 | + using detail::ProfileListBase::unset; |
| 113 | + |
| 114 | + friend class detail::AddWrapperMethods<ProfileList>; |
| 115 | + }; |
| 116 | +} // namespace adm |
0 commit comments