ATLAS Offline Software
Loading...
Searching...
No Matches
GlobalSim::BitSpec< Derived, N > Class Template Reference

#include <BitSpec.h>

Collaboration diagram for GlobalSim::BitSpec< Derived, N >:

Public Types

using bitset_type = std::bitset<N>

Static Public Member Functions

template<std::size_t I>
static constexpr decltype(auto) field ()
static constexpr std::size_t numFields ()
static constexpr void forEachField (auto &&func)
static constexpr std::string json ()
template<typename Fields>
static bitset_type packFields (const Fields &fields, const SG::AuxElement &obj)

Static Public Attributes

static constexpr std::size_t width = N

Static Protected Member Functions

template<typename... Fields>
static constexpr auto makeFields (Fields &... fields)
static consteval bool validateFields ()

Static Private Member Functions

template<typename First, typename... Rest>
static consteval bool validateFieldList ()
template<typename Field>
static consteval bool validateField ()
template<typename A, typename B>
static consteval bool checkOverlap ()

Detailed Description

template<typename Derived, std::size_t N>
class GlobalSim::BitSpec< Derived, N >

Definition at line 396 of file BitSpec.h.

Member Typedef Documentation

◆ bitset_type

template<typename Derived, std::size_t N>
using GlobalSim::BitSpec< Derived, N >::bitset_type = std::bitset<N>

Definition at line 399 of file BitSpec.h.

Member Function Documentation

◆ checkOverlap()

template<typename Derived, std::size_t N>
template<typename A, typename B>
consteval bool GlobalSim::BitSpec< Derived, N >::checkOverlap ( )
inlinestaticconstevalprivate

Definition at line 516 of file BitSpec.h.

516 {
517 if (A::lo <= B::hi && B::lo <= A::hi) {
518 return true;
519 }
520 return false;
521 }

◆ field()

template<typename Derived, std::size_t N>
template<std::size_t I>
constexpr decltype(auto) GlobalSim::BitSpec< Derived, N >::field ( )
inlinestaticconstexpr

Definition at line 404 of file BitSpec.h.

404 {
406 }

◆ forEachField()

template<typename Derived, std::size_t N>
constexpr void GlobalSim::BitSpec< Derived, N >::forEachField ( auto && func)
inlinestaticconstexpr

Definition at line 416 of file BitSpec.h.

416 {
417 std::apply([&](const auto *... field) { (func(*field), ...); }, Derived::fields);
418 }
static constexpr decltype(auto) field()
Definition BitSpec.h:404

◆ json()

template<typename Derived, std::size_t N>
constexpr std::string GlobalSim::BitSpec< Derived, N >::json ( )
inlinestaticconstexpr

Definition at line 421 of file BitSpec.h.

421 {
423 j["data_width"] = width;
424 j["fields"] = nlohmann::json::array();
425 forEachField([&](const auto &field) {
427 f["name"] = field.name();
428 f["description"] = field.description();
429 f["start"] = field.lo;
430 f["width"] = field.width;
431 j["fields"].push_back(f);
432 });
433 return j.dump(4);
434 }
static constexpr void forEachField(auto &&func)
Definition BitSpec.h:416
static constexpr std::size_t width
Definition BitSpec.h:398

◆ makeFields()

template<typename Derived, std::size_t N>
template<typename... Fields>
constexpr auto GlobalSim::BitSpec< Derived, N >::makeFields ( Fields &... fields)
inlinestaticconstexprprotected

Definition at line 440 of file BitSpec.h.

440 {
441 return std::tuple{&fields...};
442 }

◆ numFields()

template<typename Derived, std::size_t N>
constexpr std::size_t GlobalSim::BitSpec< Derived, N >::numFields ( )
inlinestaticconstexpr

Definition at line 411 of file BitSpec.h.

411 {
413 }

◆ packFields()

template<typename Derived, std::size_t N>
template<typename Fields>
bitset_type GlobalSim::BitSpec< Derived, N >::packFields ( const Fields & fields,
const SG::AuxElement & obj )
inlinestatic

Definition at line 450 of file BitSpec.h.

450 {
452
454 [&](const auto *... field) {
455 (field->pack(result, obj), ...);
456 },
457 fields);
458
459 return result;
460 }
std::bitset< N > bitset_type
Definition BitSpec.h:399

◆ validateField()

template<typename Derived, std::size_t N>
template<typename Field>
consteval bool GlobalSim::BitSpec< Derived, N >::validateField ( )
inlinestaticconstevalprivate

Definition at line 507 of file BitSpec.h.

507 {
508 return Field::lo <= Field::hi && Field::hi < N;
509 }

◆ validateFieldList()

template<typename Derived, std::size_t N>
template<typename First, typename... Rest>
consteval bool GlobalSim::BitSpec< Derived, N >::validateFieldList ( )
inlinestaticconstevalprivate

Definition at line 491 of file BitSpec.h.

492 {
493 if constexpr (sizeof...(Rest) == 0)
494 {
495 return validateField<First>();
496 }
497 else
498 {
499 return validateField<First>() &&
500 (validateField<Rest>() && ...) &&
501 ((!checkOverlap<First, Rest>()) && ...) &&
503 }
504 }
static consteval bool validateFieldList()
Definition BitSpec.h:491
static consteval bool validateField()
Definition BitSpec.h:507
static consteval bool checkOverlap()
Definition BitSpec.h:516

◆ validateFields()

template<typename Derived, std::size_t N>
consteval bool GlobalSim::BitSpec< Derived, N >::validateFields ( )
inlinestaticconstevalprotected

Definition at line 474 of file BitSpec.h.

475 {
476 return std::apply(
477 []<typename... FieldPtrs>(FieldPtrs... field) {
478 return validateFieldList<
479 std::remove_cvref_t<decltype(*field)>...
480 >();
481 },
483 }

Member Data Documentation

◆ width

template<typename Derived, std::size_t N>
std::size_t GlobalSim::BitSpec< Derived, N >::width = N
staticconstexpr

Definition at line 398 of file BitSpec.h.


The documentation for this class was generated from the following file: