Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
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 & ()
 

Private Member Functions

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

Private Attributes

OptionalTable< ConfigtableObj_
 
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 101 of file TableAs.h.

102  : TableAs{std::move(name), Comment("")}
103  {}
static QCString name
Definition: declinfo.cpp:673
TableAs(Name &&name)
Definition: TableAs.h:101
def move(depos, offset)
Definition: depos.py:107
#define Comment
template<typename T , typename Config >
fhicl::TableAs< T, Config >::TableAs ( Name &&  name,
Comment &&  comment 
)
explicit

Definition at line 106 of file TableAs.h.

108  {
110  }
static QCString name
Definition: declinfo.cpp:673
OptionalTable< Config > tableObj_
Definition: TableAs.h:89
Comment conversion_comment(Comment &&comment) const
Definition: TableAs.h:152
int comment
def move(depos, offset)
Definition: depos.py:107
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 113 of file TableAs.h.

118  maybeUse}
119  {
121  }
static QCString name
Definition: declinfo.cpp:673
OptionalTable< Config > tableObj_
Definition: TableAs.h:89
Comment conversion_comment(Comment &&comment) const
Definition: TableAs.h:152
int comment
def move(depos, offset)
Definition: depos.py:107
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 125 of file TableAs.h.

126  : TableAs{std::move(name), Comment(""), t}
127  {}
static QCString name
Definition: declinfo.cpp:673
TableAs(Name &&name)
Definition: TableAs.h:101
def move(depos, offset)
Definition: depos.py:107
#define Comment
template<typename T , typename Config >
fhicl::TableAs< T, Config >::TableAs ( Name &&  name,
Comment &&  comment,
T const &  t 
)
explicit

Definition at line 130 of file TableAs.h.

132  , t_{std::make_shared<T>(t)}
133  {
135  }
static QCString name
Definition: declinfo.cpp:673
OptionalTable< Config > tableObj_
Definition: TableAs.h:89
Comment conversion_comment(Comment &&comment) const
Definition: TableAs.h:152
int comment
def move(depos, offset)
Definition: depos.py:107
std::shared_ptr< T > t_
Definition: TableAs.h:91
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 138 of file TableAs.h.

144  maybeUse}
145  , t_{std::make_shared<T>(t)}
146  {
148  }
static QCString name
Definition: declinfo.cpp:673
OptionalTable< Config > tableObj_
Definition: TableAs.h:89
Comment conversion_comment(Comment &&comment) const
Definition: TableAs.h:152
int comment
def move(depos, offset)
Definition: depos.py:107
std::shared_ptr< T > t_
Definition: TableAs.h:91
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 152 of file TableAs.h.

153  {
154  std::string const preface =
155  "N.B. The following table is converted to type:";
156  std::string const name =
157  " '" + cet::demangle_symbol(typeid(T).name()) + "'";
158  std::string const user_comment =
159  comment.value.empty() ? "" : "\n\n" + comment.value;
160 
161  std::ostringstream oss;
162  oss << preface << '\n' << name << user_comment;
163  return Comment{oss.str().c_str()};
164  }
static QCString name
Definition: declinfo.cpp:673
std::string string
Definition: nybbler.cc:12
int comment
#define Comment
template<typename T , typename Config >
Comment fhicl::TableAs< T, Config >::conversion_comment ( Comment &&  comment,
T const &  t 
) const
private

Definition at line 223 of file TableAs.h.

224  {
225  std::string const preface{"N.B. The following table is converted to type:"};
226  std::string const name{" '" +
227  cet::demangle_symbol(typeid(T).name()) + "'"};
228 
230  stringified_default;
231 
232  std::string const user_comment{
233  comment.value.empty() ? "" : "\n\n" + comment.value};
234 
235  std::ostringstream oss;
236  oss << preface << '\n'
237  << name << '\n'
238  << stringified_default(t) << user_comment;
239  return Comment{oss.str().c_str()};
240  }
static QCString name
Definition: declinfo.cpp:673
std::string string
Definition: nybbler.cc:12
int comment
#define Comment
template<typename T, typename Config>
fhicl::TableAs< T, Config >::operator detail::ParameterBase & ( )
inline

Definition at line 82 of file TableAs.h.

83  {
84  return tableObj_;
85  } // Allows implicit conversion from
OptionalTable< Config > tableObj_
Definition: TableAs.h:89
template<typename T, typename Config>
T fhicl::TableAs< T, Config >::operator() ( ) const
inline

Definition at line 69 of file TableAs.h.

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:89
typename OptionalTable< Config >::value_type via_type
Definition: TableAs.h:51
def convert(inputfile, outputfile="wire-cell-garfield-fine-response.json.bz2", average=False, shaped=False)
Definition: garfield.py:262
std::shared_ptr< T > t_
Definition: TableAs.h:91
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

Definition at line 91 of file TableAs.h.

template<typename T, typename Config>
OptionalTable<Config> fhicl::TableAs< T, Config >::tableObj_
private

Definition at line 89 of file TableAs.h.


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