SpECTRE Documentation Coverage Report
Current view: top level - DataStructures/DataBox - TagName.hpp Hit Total Coverage
Commit: 2db722c93a8e9b106e406b439b79c8e05c2057fb Lines: 1 2 50.0 %
Date: 2021-03-03 22:01:00
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 <string>
       7             : #include <type_traits>
       8             : 
       9             : #include "DataStructures/DataBox/TagTraits.hpp"
      10             : #include "Utilities/PrettyType.hpp"
      11             : #include "Utilities/TypeTraits/CreateIsCallable.hpp"
      12             : 
      13             : /// \cond
      14             : namespace db {
      15             : struct PrefixTag;
      16             : }  // namespace db
      17             : /// \endcond
      18             : 
      19             : namespace db {
      20             : 
      21             : namespace detail {
      22             : CREATE_IS_CALLABLE(name)
      23             : CREATE_IS_CALLABLE_V(name)
      24             : }  // namespace detail
      25             : 
      26             : /*!
      27             :  * \ingroup DataBoxGroup
      28             :  * \brief Get the name of a DataBox tag, including prefixes
      29             :  *
      30             :  * \details
      31             :  * Given a DataBox tag returns the name of the DataBox tag as a std::string. If
      32             :  * the DataBox tag is also a PrefixTag then the prefix is added.
      33             :  *
      34             :  * \tparam Tag the DataBox tag whose name to get
      35             :  * \return string holding the DataBox tag's name
      36             :  */
      37             : template <typename Tag>
      38           1 : std::string tag_name() noexcept {
      39             :   if constexpr (detail::is_name_callable_v<Tag>) {
      40             :     return Tag::name();
      41             :   } else if constexpr (db::is_immutable_item_tag_v<Tag>) {
      42             :     return tag_name<typename Tag::base>();
      43             :   } else if constexpr (std::is_base_of_v<db::PrefixTag, Tag>) {
      44             :     return pretty_type::short_name<Tag>() + "(" +
      45             :            tag_name<typename Tag::tag>() + ")";
      46             :   } else {
      47             :     return pretty_type::short_name<Tag>();
      48             :   }
      49             : }
      50             : }  // namespace db

Generated by: LCOV version 1.14