LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
fhicl::OptionalTableAs< T, Config > Class Template Reference

#include "type_traits.h"

Public Member Functions

 OptionalTableAs (Name &&name)
 
 OptionalTableAs (Name &&name, Comment &&comment)
 
 OptionalTableAs (Name &&name, Comment &&comment, std::function< bool()> maybeUse)
 
std::optional< T > operator() () const
 
bool operator() (T &result) const
 
bool hasValue () const
 
 operator detail::ParameterBase const & () const noexcept
 

Private Member Functions

Comment conversion_comment (Comment &&comment) const
 

Private Attributes

OptionalTable< Config > tableObj_
 

Detailed Description

template<typename T, typename Config>
class fhicl::OptionalTableAs< T, Config >

Definition at line 55 of file type_traits.h.

Constructor & Destructor Documentation

template<typename T , typename Config >
fhicl::OptionalTableAs< T, Config >::OptionalTableAs ( Name &&  name)
explicit

Definition at line 82 of file OptionalTableAs.h.

83  : OptionalTableAs{std::move(name), Comment("")}
84  {}
OptionalTableAs(Name &&name)
template<typename T , typename Config >
fhicl::OptionalTableAs< T, Config >::OptionalTableAs ( Name &&  name,
Comment &&  comment 
)
explicit

Definition at line 87 of file OptionalTableAs.h.

References fhicl::OptionalTableAs< T, Config >::conversion_comment().

88  : tableObj_{std::move(name), conversion_comment(std::move(comment))}
89  {}
Comment conversion_comment(Comment &&comment) const
OptionalTable< Config > tableObj_
template<typename T , typename Config >
fhicl::OptionalTableAs< T, Config >::OptionalTableAs ( Name &&  name,
Comment &&  comment,
std::function< bool()>  maybeUse 
)
explicit

Definition at line 92 of file OptionalTableAs.h.

References fhicl::OptionalTableAs< T, Config >::conversion_comment().

95  : tableObj_{std::move(name),
96  conversion_comment(std::move(comment)),
97  maybeUse}
98  {}
Comment conversion_comment(Comment &&comment) const
OptionalTable< Config > tableObj_

Member Function Documentation

template<typename T , typename Config >
Comment fhicl::OptionalTableAs< T, Config >::conversion_comment ( Comment &&  comment) const
inlineprivate

Definition at line 62 of file OptionalTableAs.h.

References fhicl::Comment::value.

Referenced by fhicl::OptionalTableAs< T, Config >::OptionalTableAs().

63  {
64  std::string const preface =
65  "N.B. The following table is converted to type:";
66  std::string const name =
67  " '" + cet::demangle_symbol(typeid(T).name()) + "'";
68  std::string const user_comment =
69  comment.value.empty() ? "" : "\n\n" + comment.value;
70 
71  std::ostringstream oss;
72  oss << preface << '\n' << name << user_comment;
73 
74  return Comment{oss.str().c_str()};
75  }
template<typename T , typename Config >
bool fhicl::OptionalTableAs< T, Config >::hasValue ( ) const
inline

Definition at line 49 of file OptionalTableAs.h.

References fhicl::OptionalTable< T >::hasValue(), and fhicl::OptionalTableAs< T, Config >::tableObj_.

50  {
51  return tableObj_.hasValue();
52  }
OptionalTable< Config > tableObj_
bool hasValue() const
Definition: OptionalTable.h:62
template<typename T , typename Config >
fhicl::OptionalTableAs< T, Config >::operator detail::ParameterBase const & ( ) const
inlinenoexcept

Definition at line 56 of file OptionalTableAs.h.

References fhicl::OptionalTableAs< T, Config >::tableObj_.

56 { return tableObj_; }
OptionalTable< Config > tableObj_
template<typename T , typename Config >
std::optional<T> fhicl::OptionalTableAs< T, Config >::operator() ( ) const
inline

Definition at line 29 of file OptionalTableAs.h.

References fhicl::OptionalTableAs< T, Config >::tableObj_.

Referenced by fhicl::OptionalTableAs< T, Config >::operator()().

30  {
31  if (auto via = tableObj_()) {
32  return std::make_optional(convert(*via));
33  }
34  return std::nullopt;
35  }
OptionalTable< Config > tableObj_
template<typename T , typename Config >
bool fhicl::OptionalTableAs< T, Config >::operator() ( T &  result) const
inline

Definition at line 39 of file OptionalTableAs.h.

References fhicl::OptionalTableAs< T, Config >::operator()().

40  {
41  auto t = operator()();
42  if (t) {
43  result = *t;
44  }
45  return t.has_value();
46  }
std::optional< T > operator()() const

Member Data Documentation


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