CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

reco::parser::AnyMethodArgumentFixup Class Reference

#include <AnyMethodArgument.h>

List of all members.

Public Member Functions

 AnyMethodArgumentFixup (Reflex::Type type)
std::pair< AnyMethodArgument, int > operator() (const std::string &t) const
template<typename F >
boost::enable_if
< boost::is_floating_point< F >
, std::pair< AnyMethodArgument,
int > >::type 
operator() (const F &t) const
template<typename I >
boost::enable_if
< boost::is_integral< I >
, std::pair< AnyMethodArgument,
int > >::type 
operator() (const I &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_.

                                                    : 
                rflxType_(type),
                type_(type.Name() == "string" ? typeid(std::string) : type.TypeInfo()) // Otherwise Reflex does this wrong :-(
            {
                while (rflxType_.IsTypedef()) rflxType_ = rflxType_.ToType();
                /* // Code to print out enum table 
                if (rflxType_.IsEnum()) {
                    std::cerr << "Enum conversion: [" << rflxType_.Name() <<  "] => [" << type_.name() << "]" << std::endl;
                    std::cerr << "Enum has " << rflxType_.MemberSize() << ", members." << std::endl;
                    for (size_t i = 0; i < rflxType_.MemberSize(); ++i) {
                        Reflex::Member mem = rflxType_.MemberAt(i);
                        std::cerr << " member #"<<i<<", name = " << mem.Name() << ", rflxType_ = " << mem.TypeOf().Name() << std::endl; 
                    }
                } // */
            }

Member Function Documentation

std::pair<AnyMethodArgument,int> reco::parser::AnyMethodArgumentFixup::doInt ( int  t) const [inline, private]

Definition at line 62 of file AnyMethodArgument.h.

References lumiQTWidget::t, and type_.

Referenced by operator()().

                                                              {
                if (type_ == typeid(int8_t))   { return retOk_<int,int8_t>  (t,0); }
                if (type_ == typeid(uint8_t))  { return retOk_<int,uint8_t> (t,0); }
                if (type_ == typeid(int16_t))  { return retOk_<int,int16_t> (t,0); }
                if (type_ == typeid(uint16_t)) { return retOk_<int,uint16_t>(t,0); }
                if (type_ == typeid(int32_t))  { return retOk_<int,int32_t> (t,0); }
                if (type_ == typeid(uint32_t)) { return retOk_<int,uint32_t>(t,0); }
                if (type_ == typeid(int64_t))  { return retOk_<int,int64_t> (t,0); }
                if (type_ == typeid(uint64_t)) { return retOk_<int,uint64_t>(t,0); }
                if (type_ == typeid(unsigned long)) { return retOk_<int,unsigned long>  (t,0); } // harmless if unsigned long matches another type
                if (type_ == typeid(double))   { return retOk_<int,double>  (t,1); }
                if (type_ == typeid(float))    { return retOk_<int,float>   (t,1); }
                return std::pair<AnyMethodArgument,int>(t,-1);
            }
std::pair<AnyMethodArgument,int> reco::parser::AnyMethodArgumentFixup::operator() ( const std::string &  t) const [inline]

Definition at line 106 of file AnyMethodArgument.h.

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

                                                                                { 
                if (type_ == typeid(std::string)) { return std::pair<AnyMethodArgument,int>(t,0); }
                if (rflxType_.IsEnum()) {
                    if (rflxType_.MemberSize() == 0) {
                        throw parser::Exception(t.c_str()) << "Enumerator '" << rflxType_.Name() << "' has no keys.\nPerhaps the reflex dictionary is missing?\n";
                    }
                    Reflex::Member value = rflxType_.MemberByName(t);
                    //std::cerr << "Trying to convert '" << t << "'  to a value for enumerator '" << rflxType_.Name() << "'" << std::endl;
                    if (!value) // check for existing value
                        return std::pair<AnyMethodArgument,int>(t,-1);
                        // throw parser::Exception(t.c_str()) << "Can't convert '" << t << "' to a value for enumerator '" << rflxType_.Name() << "'\n";
                    //std::cerr << "  found member of type '" << value.TypeOf().Name() << "'" << std::endl;
                    if (value.TypeOf().TypeInfo() != typeid(int)) // check is backed by an Int
                        throw parser::Exception(t.c_str()) << "Enumerator '" << rflxType_.Name() << "' is not implemented by type 'int' !!??\n";
                    //std::cerr << "  value is @ " <<   reinterpret_cast<const int *>(value.Get().Address()) << std::endl;
                    int ival = * reinterpret_cast<const int *>(value.Get().Address());
                    //std::cerr << "  value is = " << ival << std::endl;
                    return std::pair<AnyMethodArgument,int>(ival,1);
                }
                return std::pair<AnyMethodArgument,int>(t,-1);
            }
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_.

                                         { 
                if (type_ == typeid(double)) { return retOk_<F,double>(t,0); }
                if (type_ == typeid(float))  { return retOk_<F,float> (t,0); }
                return std::pair<AnyMethodArgument,int>(t,-1);
            }
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().

{ return doInt(t); }
template<typename From , typename To >
std::pair<AnyMethodArgument, int> reco::parser::AnyMethodArgumentFixup::retOk_ ( const From &  f,
int  cast 
) const [inline, private]

Definition at line 57 of file AnyMethodArgument.h.

                                                                                  {
                return std::pair<AnyMethodArgument,int>(AnyMethodArgument(static_cast<To>(f)), cast);
            }

Member Data Documentation

Definition at line 54 of file AnyMethodArgument.h.

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

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

Definition at line 55 of file AnyMethodArgument.h.

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