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 390 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 393 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 510 of file BitSpec.h.

510 {
511 if (A::lo <= B::hi && B::lo <= A::hi) {
512 return true;
513 }
514 return false;
515 }

◆ 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 398 of file BitSpec.h.

398 {
400 }

◆ forEachField()

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

Definition at line 410 of file BitSpec.h.

410 {
411 std::apply([&](const auto *... field) { (func(*field), ...); }, Derived::fields);
412 }
static constexpr decltype(auto) field()
Definition BitSpec.h:398

◆ json()

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

Definition at line 415 of file BitSpec.h.

415 {
417 j["data_width"] = width;
418 j["fields"] = nlohmann::json::array();
419 forEachField([&](const auto &field) {
421 f["name"] = field.name();
422 f["description"] = field.description();
423 f["start"] = field.lo;
424 f["width"] = field.width;
425 j["fields"].push_back(f);
426 });
427 return j.dump(4);
428 }
static constexpr void forEachField(auto &&func)
Definition BitSpec.h:410
static constexpr std::size_t width
Definition BitSpec.h:392

◆ makeFields()

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

Definition at line 434 of file BitSpec.h.

434 {
435 return std::tuple{&fields...};
436 }

◆ numFields()

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

Definition at line 405 of file BitSpec.h.

405 {
407 }

◆ 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 444 of file BitSpec.h.

444 {
446
448 [&](const auto *... field) {
449 (field->pack(result, obj), ...);
450 },
451 fields);
452
453 return result;
454 }
std::bitset< N > bitset_type
Definition BitSpec.h:393

◆ validateField()

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

Definition at line 501 of file BitSpec.h.

501 {
502 return Field::lo <= Field::hi && Field::hi < N;
503 }

◆ validateFieldList()

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

Definition at line 485 of file BitSpec.h.

486 {
487 if constexpr (sizeof...(Rest) == 0)
488 {
489 return validateField<First>();
490 }
491 else
492 {
493 return validateField<First>() &&
494 (validateField<Rest>() && ...) &&
495 ((!checkOverlap<First, Rest>()) && ...) &&
497 }
498 }
static consteval bool validateFieldList()
Definition BitSpec.h:485
static consteval bool validateField()
Definition BitSpec.h:501
static consteval bool checkOverlap()
Definition BitSpec.h:510

◆ validateFields()

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

Definition at line 468 of file BitSpec.h.

469 {
470 return std::apply(
471 []<typename... FieldPtrs>(FieldPtrs... field) {
472 return validateFieldList<
473 std::remove_cvref_t<decltype(*field)>...
474 >();
475 },
477 }

Member Data Documentation

◆ width

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

Definition at line 392 of file BitSpec.h.


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