CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
reco::parser::AnyMethodArgumentFixup Class Reference

#include <AnyMethodArgument.h>

Inheritance diagram for reco::parser::AnyMethodArgumentFixup:

Public Member Functions

 AnyMethodArgumentFixup (Reflex::Type type)
 
template<typename I >
boost::enable_if
< boost::is_integral< I >
, std::pair< AnyMethodArgument,
int > >::type 
operator() (const I &t) const
 
template<typename F >
boost::enable_if
< boost::is_floating_point< F >
, std::pair< AnyMethodArgument,
int > >::type 
operator() (const F &t) const
 
std::pair< AnyMethodArgument, int > operator() (const std::string &t) const
 

Private Member Functions

std::pair< AnyMethodArgument, int > doInt (int t) const
 
template<typename From , typename To >
std::pair< AnyMethodArgument, int > retOk_ (const From &f, int cast) const
 

Private Attributes

Reflex::Type rflxType_
 
const std::type_info & type_
 

Detailed Description

Definition at line 52 of file AnyMethodArgument.h.

Constructor & Destructor Documentation

reco::parser::AnyMethodArgumentFixup::AnyMethodArgumentFixup ( Reflex::Type  type)
inline

Definition at line 77 of file AnyMethodArgument.h.

References rflxType_.

77  :
78  rflxType_(type),
79  type_(type.Name() == "string" ? typeid(std::string) : type.TypeInfo()) // Otherwise Reflex does this wrong :-(
80  {
81  while (rflxType_.IsTypedef()) rflxType_ = rflxType_.ToType();
82  /* // Code to print out enum table
83  if (rflxType_.IsEnum()) {
84  std::cerr << "Enum conversion: [" << rflxType_.Name() << "] => [" << type_.name() << "]" << std::endl;
85  std::cerr << "Enum has " << rflxType_.MemberSize() << ", members." << std::endl;
86  for (size_t i = 0; i < rflxType_.MemberSize(); ++i) {
87  Reflex::Member mem = rflxType_.MemberAt(i);
88  std::cerr << " member #"<<i<<", name = " << mem.Name() << ", rflxType_ = " << mem.TypeOf().Name() << std::endl;
89  }
90  } // */
91  }
type
Definition: HCALResponse.h:22

Member Function Documentation

std::pair<AnyMethodArgument,int> reco::parser::AnyMethodArgumentFixup::doInt ( int  t) const
inlineprivate

Definition at line 62 of file AnyMethodArgument.h.

References lumiQTWidget::t, and type_.

Referenced by operator()().

62  {
63  if (type_ == typeid(int8_t)) { return retOk_<int,int8_t> (t,0); }
64  if (type_ == typeid(uint8_t)) { return retOk_<int,uint8_t> (t,0); }
65  if (type_ == typeid(int16_t)) { return retOk_<int,int16_t> (t,0); }
66  if (type_ == typeid(uint16_t)) { return retOk_<int,uint16_t>(t,0); }
67  if (type_ == typeid(int32_t)) { return retOk_<int,int32_t> (t,0); }
68  if (type_ == typeid(uint32_t)) { return retOk_<int,uint32_t>(t,0); }
69  if (type_ == typeid(int64_t)) { return retOk_<int,int64_t> (t,0); }
70  if (type_ == typeid(uint64_t)) { return retOk_<int,uint64_t>(t,0); }
71  if (type_ == typeid(unsigned long)) { return retOk_<int,unsigned long> (t,0); } // harmless if unsigned long matches another type
72  if (type_ == typeid(double)) { return retOk_<int,double> (t,1); }
73  if (type_ == typeid(float)) { return retOk_<int,float> (t,1); }
74  return std::pair<AnyMethodArgument,int>(t,-1);
75  }
unsigned long long uint64_t
Definition: Time.h:15
template<typename I >
boost::enable_if<boost::is_integral<I>, std::pair<AnyMethodArgument,int> >::type reco::parser::AnyMethodArgumentFixup::operator() ( const I &  t) const
inline

Definition at line 96 of file AnyMethodArgument.h.

References doInt().

96 { return doInt(t); }
std::pair< AnyMethodArgument, int > doInt(int t) const
template<typename F >
boost::enable_if<boost::is_floating_point<F>, std::pair<AnyMethodArgument,int> >::type reco::parser::AnyMethodArgumentFixup::operator() ( const F t) const
inline

Definition at line 100 of file AnyMethodArgument.h.

References lumiQTWidget::t, and type_.

100  {
101  if (type_ == typeid(double)) { return retOk_<F,double>(t,0); }
102  if (type_ == typeid(float)) { return retOk_<F,float> (t,0); }
103  return std::pair<AnyMethodArgument,int>(t,-1);
104  }
std::pair<AnyMethodArgument,int> reco::parser::AnyMethodArgumentFixup::operator() ( const std::string &  t) const
inline

Definition at line 106 of file AnyMethodArgument.h.

References edm::hlt::Exception, rflxType_, lumiQTWidget::t, type_, and relativeConstraints::value.

106  {
107  if (type_ == typeid(std::string)) { return std::pair<AnyMethodArgument,int>(t,0); }
108  if (rflxType_.IsEnum()) {
109  if (rflxType_.MemberSize() == 0) {
110  throw parser::Exception(t.c_str()) << "Enumerator '" << rflxType_.Name() << "' has no keys.\nPerhaps the reflex dictionary is missing?\n";
111  }
112  Reflex::Member value = rflxType_.MemberByName(t);
113  //std::cerr << "Trying to convert '" << t << "' to a value for enumerator '" << rflxType_.Name() << "'" << std::endl;
114  if (!value) // check for existing value
115  return std::pair<AnyMethodArgument,int>(t,-1);
116  // throw parser::Exception(t.c_str()) << "Can't convert '" << t << "' to a value for enumerator '" << rflxType_.Name() << "'\n";
117  //std::cerr << " found member of type '" << value.TypeOf().Name() << "'" << std::endl;
118  if (value.TypeOf().TypeInfo() != typeid(int)) // check is backed by an Int
119  throw parser::Exception(t.c_str()) << "Enumerator '" << rflxType_.Name() << "' is not implemented by type 'int' !!??\n";
120  //std::cerr << " value is @ " << reinterpret_cast<const int *>(value.Get().Address()) << std::endl;
121  int ival = * reinterpret_cast<const int *>(value.Get().Address());
122  //std::cerr << " value is = " << ival << std::endl;
123  return std::pair<AnyMethodArgument,int>(ival,1);
124  }
125  return std::pair<AnyMethodArgument,int>(t,-1);
126  }
template<typename From , typename To >
std::pair<AnyMethodArgument, int> reco::parser::AnyMethodArgumentFixup::retOk_ ( const From &  f,
int  cast 
) const
inlineprivate

Definition at line 57 of file AnyMethodArgument.h.

57  {
58  return std::pair<AnyMethodArgument,int>(AnyMethodArgument(static_cast<To>(f)), cast);
59  }
double f[11][100]
boost::mpl::if_< matches_another_integral_type< unsigned long >, boost::variant< int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, uint64_t, double, float, std::string >, boost::variant< int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, uint64_t, unsigned long, double, float, std::string > >::type AnyMethodArgument

Member Data Documentation

Reflex::Type reco::parser::AnyMethodArgumentFixup::rflxType_
private

Definition at line 54 of file AnyMethodArgument.h.

Referenced by AnyMethodArgumentFixup(), and operator()().

const std::type_info& reco::parser::AnyMethodArgumentFixup::type_
private