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

#include "type_traits.h"

Public Types

using default_type = T
 
using via_type = typename OptionalTable< Config >::value_type
 
using value_type = T
 

Public Member Functions

 TableAs (Name &&name)
 
 TableAs (Name &&name, Comment &&comment)
 
 TableAs (Name &&name, Comment &&comment, std::function< bool()> maybeUse)
 
 TableAs (Name &&name, T const &t)
 
 TableAs (Name &&name, Comment &&comment, T const &t)
 
 TableAs (Name &&name, Comment &&comment, std::function< bool()> maybeUse, T const &t)
 
operator() () const
 
 operator detail::ParameterBase const & () const noexcept
 
 operator detail::ParameterBase & () noexcept
 

Private Member Functions

Comment conversion_comment (Comment &&comment) const
 
Comment conversion_comment (Comment &&comment, T const &t) const
 

Private Attributes

OptionalTable< Config > tableObj_
 
std::shared_ptr< T > t_ {}
 

Detailed Description

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

Definition at line 53 of file type_traits.h.

Member Typedef Documentation

template<typename T, typename Config>
using fhicl::TableAs< T, Config >::default_type = T

Definition at line 50 of file TableAs.h.

template<typename T, typename Config>
using fhicl::TableAs< T, Config >::value_type = T

Definition at line 52 of file TableAs.h.

template<typename T, typename Config>
using fhicl::TableAs< T, Config >::via_type = typename OptionalTable<Config>::value_type

Definition at line 51 of file TableAs.h.

Constructor & Destructor Documentation

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

Definition at line 104 of file TableAs.h.

105  : TableAs{std::move(name), Comment("")}
106  {}
TableAs(Name &&name)
Definition: TableAs.h:104
template<typename T , typename Config >
fhicl::TableAs< T, Config >::TableAs ( Name &&  name,
Comment &&  comment 
)
explicit

Definition at line 109 of file TableAs.h.

References fhicl::TableAs< T, Config >::conversion_comment(), fhicl::REQUIRED, fhicl::detail::ParameterBase::set_par_style(), and fhicl::TableAs< T, Config >::tableObj_.

110  : tableObj_{std::move(name), conversion_comment(std::move(comment))}
111  {
113  }
OptionalTable< Config > tableObj_
Definition: TableAs.h:92
Comment conversion_comment(Comment &&comment) const
Definition: TableAs.h:157
void set_par_style(par_style const vt)
template<typename T , typename Config >
fhicl::TableAs< T, Config >::TableAs ( Name &&  name,
Comment &&  comment,
std::function< bool()>  maybeUse 
)
explicit

Definition at line 116 of file TableAs.h.

References fhicl::TableAs< T, Config >::conversion_comment(), fhicl::REQUIRED_CONDITIONAL, fhicl::detail::ParameterBase::set_par_style(), and fhicl::TableAs< T, Config >::tableObj_.

119  : tableObj_{std::move(name),
120  conversion_comment(std::move(comment)),
121  maybeUse}
122  {
124  }
OptionalTable< Config > tableObj_
Definition: TableAs.h:92
Comment conversion_comment(Comment &&comment) const
Definition: TableAs.h:157
void set_par_style(par_style const vt)
template<typename T , typename Config >
fhicl::TableAs< T, Config >::TableAs ( Name &&  name,
T const &  t 
)
explicit

Definition at line 128 of file TableAs.h.

129  : TableAs{std::move(name), Comment(""), t}
130  {}
TableAs(Name &&name)
Definition: TableAs.h:104
template<typename T , typename Config >
fhicl::TableAs< T, Config >::TableAs ( Name &&  name,
Comment &&  comment,
T const &  t 
)
explicit

Definition at line 133 of file TableAs.h.

References fhicl::TableAs< T, Config >::conversion_comment(), fhicl::DEFAULT, fhicl::detail::ParameterBase::set_par_style(), fhicl::TableAs< T, Config >::t_, and fhicl::TableAs< T, Config >::tableObj_.

134  : tableObj_{std::move(name), conversion_comment(std::move(comment), t)}
135  , t_{std::make_shared<T>(t)}
136  {
138  }
OptionalTable< Config > tableObj_
Definition: TableAs.h:92
Comment conversion_comment(Comment &&comment) const
Definition: TableAs.h:157
std::shared_ptr< T > t_
Definition: TableAs.h:94
void set_par_style(par_style const vt)
template<typename T , typename Config >
fhicl::TableAs< T, Config >::TableAs ( Name &&  name,
Comment &&  comment,
std::function< bool()>  maybeUse,
T const &  t 
)
explicit

Definition at line 141 of file TableAs.h.

References fhicl::TableAs< T, Config >::conversion_comment(), fhicl::DEFAULT_CONDITIONAL, fhicl::detail::ParameterBase::set_par_style(), fhicl::TableAs< T, Config >::t_, and fhicl::TableAs< T, Config >::tableObj_.

145  : tableObj_{std::move(name),
146  conversion_comment(std::move(comment), t),
147  maybeUse}
148  , t_{std::make_shared<T>(t)}
149  {
151  }
OptionalTable< Config > tableObj_
Definition: TableAs.h:92
Comment conversion_comment(Comment &&comment) const
Definition: TableAs.h:157
std::shared_ptr< T > t_
Definition: TableAs.h:94
void set_par_style(par_style const vt)

Member Function Documentation

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

Definition at line 157 of file TableAs.h.

References fhicl::Comment::value.

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

158  {
159  std::string const preface =
160  "N.B. The following table is converted to type:";
161  std::string const name =
162  " '" + cet::demangle_symbol(typeid(T).name()) + "'";
163  std::string const user_comment =
164  comment.value.empty() ? "" : "\n\n" + comment.value;
165 
166  std::ostringstream oss;
167  oss << preface << '\n' << name << user_comment;
168  return Comment{oss.str().c_str()};
169  }
template<typename T , typename Config >
Comment fhicl::TableAs< T, Config >::conversion_comment ( Comment &&  comment,
T const &  t 
) const
private

Definition at line 173 of file TableAs.h.

References fhicl::detail::maybe_insert(), and fhicl::Comment::value.

174  {
175  std::string const preface{"N.B. The following table is converted to type:"};
176  std::string const name{" '" +
177  cet::demangle_symbol(typeid(T).name()) + "'"};
178 
179  std::string const user_comment{
180  comment.value.empty() ? "" : "\n\n" + comment.value};
181 
182  std::ostringstream oss;
183  oss << preface << '\n'
184  << name << '\n'
185  << detail::maybe_insert(t) << user_comment;
186  return Comment{oss.str().c_str()};
187  }
std::string maybe_insert(T const &t)
Definition: maybe_insert.h:23
template<typename T, typename Config>
fhicl::TableAs< T, Config >::operator detail::ParameterBase & ( )
inlinenoexcept

Definition at line 89 of file TableAs.h.

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

89 { return tableObj_; }
OptionalTable< Config > tableObj_
Definition: TableAs.h:92
template<typename T, typename Config>
fhicl::TableAs< T, Config >::operator detail::ParameterBase const & ( ) const
inlinenoexcept

Definition at line 81 of file TableAs.h.

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

81 { return tableObj_; }
OptionalTable< Config > tableObj_
Definition: TableAs.h:92
template<typename T, typename Config>
T fhicl::TableAs< T, Config >::operator() ( ) const
inline

Definition at line 69 of file TableAs.h.

References fhicl::cant_find, fhicl::detail::ParameterBase::has_default(), fhicl::TableAs< T, Config >::t_, and fhicl::TableAs< T, Config >::tableObj_.

70  {
71  via_type via;
72  return tableObj_(via) ? convert(via) :
73  tableObj_.has_default() ?
74  *t_ :
75  throw fhicl::exception(
76  cant_find); // fix this exception category!
77  }
OptionalTable< Config > tableObj_
Definition: TableAs.h:92
typename OptionalTable< Config >::value_type via_type
Definition: TableAs.h:51
parameter set interface
std::shared_ptr< T > t_
Definition: TableAs.h:94
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33

Member Data Documentation

template<typename T, typename Config>
std::shared_ptr<T> fhicl::TableAs< T, Config >::t_ {}
private

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