SpECTRE Documentation Coverage Report
Current view: top level - DataStructures/DataBox - TagTraits.hpp Hit Total Coverage
Commit: 3ffcbc8ecf43797401b60bcca17d6040ee06f013 Lines: 14 15 93.3 %
Date: 2026-03-03 02:01:44
Legend: Lines: hit not hit

          Line data    Source code
       1           0 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : #pragma once
       5             : 
       6             : #include <concepts>
       7             : #include <type_traits>
       8             : 
       9             : /// \cond
      10             : namespace db {
      11             : struct SimpleTag;
      12             : struct ComputeTag;
      13             : struct ReferenceTag;
      14             : }  // namespace db
      15             : namespace Parallel::Tags {
      16             : struct Metavariables;
      17             : }  // namespace Parallel::Tags
      18             : /// \endcond
      19             : 
      20             : namespace db {
      21             : /*!
      22             :  * \ingroup DataBoxGroup
      23             :  * \brief Check if `Tag` derives off of db::ComputeTag.
      24             :  *
      25             :  * \see is_compute_tag_v ComputeTag
      26             :  */
      27             : template <typename Tag>
      28           1 : struct is_compute_tag : std::is_base_of<db::ComputeTag, Tag> {};
      29             : 
      30             : /// \ingroup DataBoxGroup
      31             : /// \brief True if `Tag` derives from db::ComputeTag.
      32             : template <typename Tag>
      33           1 : constexpr bool is_compute_tag_v = is_compute_tag<Tag>::value;
      34             : 
      35             : /*!
      36             :  * \ingroup DataBoxGroup
      37             :  * \brief Check if `Tag` derives off of db::ReferenceTag.
      38             :  *
      39             :  * \see is_reference_tag_v ReferenceTag
      40             :  */
      41             : template <typename Tag>
      42           1 : struct is_reference_tag : std::is_base_of<db::ReferenceTag, Tag> {};
      43             : 
      44             : /// \ingroup DataBoxGroup
      45             : /// \brief True if `Tag` derives from db::ReferenceTag.
      46             : template <typename Tag>
      47           1 : constexpr bool is_reference_tag_v = is_reference_tag<Tag>::value;
      48             : 
      49             : /*!
      50             :  * \ingroup DataBoxGroup
      51             :  * \brief Check if `Tag` is a DataBox tag for an immutable item, i.e. a
      52             :  * ComputeTag or ReferenceTag
      53             :  *
      54             :  * \see is_immutable_item_tag_v
      55             :  */
      56             : template <typename Tag>
      57           1 : struct is_immutable_item_tag
      58             :     : std::bool_constant<std::is_base_of_v<db::ReferenceTag, Tag> or
      59             :                          std::is_base_of_v<db::ComputeTag, Tag>> {};
      60             : 
      61             : /// \ingroup DataBoxGroup
      62             : /// \brief True if `Tag` is a DataBox tag for an immutable item, i.e. a
      63             : /// ComputeTag or ReferenceTag.
      64             : template <typename Tag>
      65           1 : constexpr bool is_immutable_item_tag_v = is_immutable_item_tag<Tag>::value;
      66             : 
      67             : /*!
      68             :  * \ingroup DataBoxGroup
      69             :  * \brief Check if `Tag` is a DataBox tag for a mutable item, i.e. a SimpleTag
      70             :  *
      71             :  * \see is_mutable_item_tag_v
      72             :  */
      73             : template <typename Tag>
      74           1 : struct is_mutable_item_tag
      75             :     : std::bool_constant<std::is_base_of_v<db::SimpleTag, Tag> and
      76             :                          not is_compute_tag_v<Tag> and
      77             :                          not is_reference_tag_v<Tag>> {};
      78             : 
      79             : /// \ingroup DataBoxGroup
      80             : /// \brief True if `Tag` is a DataBox tag for a mutable item, i.e. a SimpleTag
      81             : template <typename Tag>
      82           1 : constexpr bool is_mutable_item_tag_v = is_mutable_item_tag<Tag>::value;
      83             : 
      84             : /*!
      85             :  * \ingroup DataBoxGroup
      86             :  * \brief Check if `Tag` is a simple tag.
      87             :  *
      88             :  * \details This is done by deriving from std::true_type if `Tag` is derived
      89             :  * from db::SimpleTag, but not from db::ComputeTag or db::ReferenceTag.
      90             :  *
      91             :  * \see is_simple_tag_v SimpleTag
      92             :  */
      93             : template <typename Tag>
      94           1 : struct is_simple_tag
      95             :     : std::bool_constant<std::is_base_of_v<db::SimpleTag, Tag> and
      96             :                          not is_compute_tag_v<Tag> and
      97             :                          not is_reference_tag_v<Tag>> {};
      98             : 
      99             : /// \ingroup DataBoxGroup
     100             : /// \brief True if `Tag` is a simple tag.
     101             : template <typename Tag>
     102           1 : constexpr bool is_simple_tag_v = is_simple_tag<Tag>::value;
     103             : 
     104             : /*!
     105             :  * \ingroup DataBoxGroup
     106             :  * \brief Check if `Tag` is a simple, compute, or reference tag.
     107             :  *
     108             :  * \see is_non_base_tag_v BaseTag
     109             :  */
     110             : template <typename Tag>
     111           1 : struct is_creation_tag : std::is_base_of<db::SimpleTag, Tag> {};
     112             : 
     113             : /// \ingroup DataBoxGroup
     114             : /// \brief True if `Tag` is not a base tag.
     115             : template <typename Tag>
     116           1 : constexpr bool is_creation_tag_v = is_creation_tag<Tag>::value;
     117             : 
     118             : /*!
     119             :  * \ingroup DataBoxGroup
     120             :  * \brief Check if `Tag` is a DataBox tag, i.e. a SimpleTag, ComputeTag,
     121             :  * ReferenceTag, or the special tag Parallel::Tags::Metavariables.
     122             :  *
     123             :  * \see is_tag_v
     124             :  */
     125             : template <typename Tag>
     126           1 : struct is_tag
     127             :     : std::bool_constant<std::is_base_of_v<db::SimpleTag, Tag> or
     128             :                          std::is_same_v<Tag, Parallel::Tags::Metavariables>> {};
     129             : 
     130             : /// \ingroup DataBoxGroup
     131             : /// \brief True if `Tag` is a DataBox tag.
     132             : template <typename Tag>
     133           1 : constexpr bool is_tag_v = is_tag<Tag>::value;
     134             : 
     135             : /*!
     136             :  * \ingroup DataBoxGroup
     137             :  * Concept for a SimpleTag.
     138             :  *
     139             :  * \see is_simple_tag
     140             :  */
     141             : template <typename Tag>
     142             : concept simple_tag = is_simple_tag_v<Tag>;
     143             : 
     144             : /*!
     145             :  * \ingroup DataBoxGroup
     146             :  * Concept for a ComputeTag.
     147             :  *
     148             :  * \see is_compute_tag
     149             :  */
     150             : template <typename Tag>
     151             : concept compute_tag = is_compute_tag_v<Tag>;
     152             : 
     153             : /*!
     154             :  * \ingroup DataBoxGroup
     155             :  * Concept for a ReferenceTag.
     156             :  *
     157             :  * \see is_reference_tag
     158             :  */
     159             : template <typename Tag>
     160             : concept reference_tag = is_reference_tag_v<Tag>;
     161             : 
     162             : /*!
     163             :  * \ingroup DataBoxGroup
     164             :  * Concept for an immutable item tag.
     165             :  *
     166             :  * \see is_immutable_item_tag
     167             :  */
     168             : template <typename Tag>
     169             : concept immutable_item_tag = reference_tag<Tag> or compute_tag<Tag>;
     170             : 
     171             : /*!
     172             :  * \ingroup DataBoxGroup
     173             :  * Concept for a mutable item tag.
     174             :  *
     175             :  * \see is_mutable_item_tag
     176             :  */
     177             : template <typename Tag>
     178             : concept mutable_item_tag = simple_tag<Tag>;
     179             : 
     180             : /*!
     181             :  * \ingroup DataBoxGroup
     182             :  * Concept for a DataBox tag.
     183             :  *
     184             :  * \see is_tag
     185             :  */
     186             : template <typename Tag>
     187             : concept tag = immutable_item_tag<Tag> or mutable_item_tag<Tag> or
     188             :               std::same_as<Tag, Parallel::Tags::Metavariables>;
     189             : }  // namespace db

Generated by: LCOV version 1.14