X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?p=sim%2Fe2-interface.git;a=blobdiff_plain;f=e2sim%2Fe2apv1sim%2Fsrc%2FASN1%2Fasn%2Fconstraints.hpp;fp=e2sim%2Fe2apv1sim%2Fsrc%2FASN1%2Fasn%2Fconstraints.hpp;h=0000000000000000000000000000000000000000;hp=e8e787d9a00936e0928668ed1ae50527eef21874;hb=a9733dbcc47e93a3b2843056f1d587196296c324;hpb=3ebf932d23dcbec9ed19f4a51f9d00a0a54f5124 diff --git a/e2sim/e2apv1sim/src/ASN1/asn/constraints.hpp b/e2sim/e2apv1sim/src/ASN1/asn/constraints.hpp deleted file mode 100755 index e8e787d..0000000 --- a/e2sim/e2apv1sim/src/ASN1/asn/constraints.hpp +++ /dev/null @@ -1,140 +0,0 @@ -#pragma once - -/****************************************************************************** -* -* Copyright (c) 2019 AT&T Intellectual Property. -* Copyright (c) 2018-2019 Nokia. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* -******************************************************************************/ - -// Standard Includes: ANSI C/C++, MSA, and Third-Party Libraries -#include -#include -#include -#include - -// Local Includes: Application specific classes, functions, and libraries - -namespace asn { - -using bound_t = int64_t; - -enum class constraint_type : uint8_t -{ - UNCONSTRAINED, - CONSTRAINED, - SEMICONSTRAINED, - CONSTRAINED_EXTENDED, - SEMICONSTRAINED_EXTENDED -}; - -template -struct span -{ - static_assert(UB >= LB, "UPPER >= LOWER"); - static constexpr bound_t lower_bound = LB; - static constexpr bound_t upper_bound = UB; -}; - -template -struct pair -{ - T const lower_bound; - T const upper_bound; -}; - -template -struct one : span {}; - -struct max : one::max()> {}; -struct min : one::min()> {}; - -static constexpr bound_t MAX = std::numeric_limits::max(); -static constexpr bound_t MIN = std::numeric_limits::min(); - -template -struct constraints -{ - static constexpr bool extended = Extended; - static constexpr bound_t lower_bound = std::min({RANGE::lower_bound...}); - static constexpr bound_t upper_bound = std::max({RANGE::upper_bound...}); - - static constexpr constraint_type type = - (Extended && lower_bound > min::lower_bound && upper_bound < max::upper_bound) ? constraint_type::CONSTRAINED_EXTENDED : - (!Extended && lower_bound > min::lower_bound && upper_bound < max::upper_bound) ? constraint_type::CONSTRAINED : - (Extended && lower_bound > min::lower_bound && upper_bound == max::upper_bound) ? constraint_type::SEMICONSTRAINED_EXTENDED : - (!Extended && lower_bound == min::lower_bound && upper_bound < max::upper_bound) ? constraint_type::SEMICONSTRAINED : - (Extended && lower_bound == min::lower_bound && upper_bound < max::upper_bound) ? constraint_type::SEMICONSTRAINED_EXTENDED : - (!Extended && lower_bound > min::lower_bound && upper_bound == max::upper_bound) ? constraint_type::SEMICONSTRAINED : constraint_type::UNCONSTRAINED; - - static constexpr bool is_signed = lower_bound < 0; - - static constexpr bound_t num_spans = static_cast(sizeof...(RANGE)); - static constexpr pair bounds[] = {{RANGE::lower_bound, RANGE::upper_bound}...}; - - using boundary_type = bound_t; - - static constexpr bool is_extended(bound_t val) - { - for (bound_t i = 0; i < num_spans; ++i) - { - auto const& p = bounds[i]; - if (val <= p.upper_bound) - { - if(val < p.lower_bound) - return true; - return false; - } - } - return true; - } -}; - -template -constexpr pair constraints::bounds[]; - -template -struct constraints -{ - static constexpr bool extended = Extended; - static constexpr constraint_type type = constraint_type::UNCONSTRAINED; - static constexpr bound_t lower_bound = std::numeric_limits::min(); - static constexpr bound_t upper_bound = std::numeric_limits::max(); - - static constexpr bool is_extended(bound_t val) {return true;} -}; - -/*************************************************************************************** -* RANGE for sequences -***************************************************************************************/ -template -struct seq_range -{ - static_assert(Extended || TotalNumEntries > 0, "TotalNumEntries must be > 0"); - static_assert(NumExtEntries <= TotalNumEntries, "NumExtEntries must be <= TotalNumEntries"); - - static constexpr constraint_type type = Extended ? constraint_type::CONSTRAINED_EXTENDED : constraint_type::CONSTRAINED; - static constexpr bool extended = Extended; - static constexpr bound_t lower_bound = 0; - static constexpr bound_t upper_bound = TotalNumEntries - NumExtEntries - 1; - static constexpr bound_t default_value = lower_bound; - static constexpr bound_t total_num_entries = TotalNumEntries; - - using boundary_type = bound_t; - using value_type = uint32_t; -}; - -} // namespace asn