CMS 3D CMS Logo

Public Member Functions | Private Attributes

reco::parser::MethodSetter Struct Reference

#include <MethodSetter.h>

List of all members.

Public Member Functions

 MethodSetter (MethodStack &methStack, LazyMethodStack &lazyMethStack, TypeStack &typeStack, MethodArgumentStack &intStack, bool lazy=false)
void operator() (const char *, const char *) const
bool push (const std::string &, const std::vector< AnyMethodArgument > &, const char *, bool deep=true) const

Private Attributes

MethodArgumentStackintStack_
bool lazy_
LazyMethodStacklazyMethStack_
MethodStackmethStack_
TypeStacktypeStack_

Detailed Description

Definition at line 15 of file MethodSetter.h.


Constructor & Destructor Documentation

reco::parser::MethodSetter::MethodSetter ( MethodStack methStack,
LazyMethodStack lazyMethStack,
TypeStack typeStack,
MethodArgumentStack intStack,
bool  lazy = false 
) [inline, explicit]

Definition at line 16 of file MethodSetter.h.

                                                                             : 
        methStack_(methStack), lazyMethStack_(lazyMethStack), typeStack_(typeStack),
        intStack_(intStack), lazy_(lazy) { }

Member Function Documentation

void MethodSetter::operator() ( const char *  begin,
const char *  end 
) const

Definition at line 12 of file MethodSetter.cc.

References harvestRelVal::args, begin, Exception, i, and mergeVDriftHistosByStation::name.

                                                                        {
  string name(begin, end);
  string::size_type parenthesis = name.find_first_of('(');
  if (*begin == '[' || *begin == '(') {
    name.insert(0, "operator..");           // operator..[arg];
    parenthesis = 10;                       //           ^--- idx = 10
    name[8] = *begin;                       // operator[.[arg];
    name[9] =  name[name.size()-1];         // operator[][arg];
    name[10] = '(';                         // operator[](arg];
    name[name.size()-1] = ')';              // operator[](arg);    
    // we don't actually need the last two, but just for extra care
    //std::cout << "Transformed {" << string(begin,end) << "} into {"<< name <<"}" << std::endl;
  }
  std::vector<AnyMethodArgument> args;
  if(parenthesis != string::npos) {
    name.erase(parenthesis, name.size());
    if(intStack_.size()==0)
      throw Exception(begin)
        << "expected method argument, but non given.";    
    for(vector<AnyMethodArgument>::const_iterator i = intStack_.begin(); i != intStack_.end(); ++i)
      args.push_back(*i);
    intStack_.clear();
  }
  string::size_type endOfExpr = name.find_last_of(' ');
  if(endOfExpr != string::npos)
    name.erase(endOfExpr, name.size());
  //std::cerr << "Pushing [" << name << "] with " << args.size() << " args " << (lazy_ ? "(lazy)" : "(immediate)") << std::endl;
  if (lazy_) lazyMethStack_.push_back(LazyInvoker(name, args)); // for lazy parsing we just push method name and arguments
  else push(name, args,begin);  // otherwise we really have to resolve the method
  //std::cerr << "Pushed [" << name << "] with " << args.size() << " args " << (lazy_ ? "(lazy)" : "(immediate)") << std::endl;
}
bool reco::parser::MethodSetter::push ( const std::string &  ,
const std::vector< AnyMethodArgument > &  ,
const char *  ,
bool  deep = true 
) const

Resolve the method, push a MethodInvoker on the MethodStack and it's return type to TypeStack (after stripping "*" and "&") This method is used also by the LazyInvoker to perform the fetch once the final type is known If the object is a Ref/Ptr/RefToBase and the method is not found in that class: 1) it pushes a no-argument 'get()' method 2) if deep = true, it attempts to resolve and push the method on the object to which the edm ref points to. In that case, the MethodStack will contain two more items after this call instead of just one. This behaviour is what you want for non-lazy parsing 2b) if instead deep = false, it just pushes the 'get' on the stack. this will allow the LazyInvoker to then re-discover the runtime type of the pointee The method will:

  • throw exception, if the member can't be resolved
  • return 'false' if deep = false and it only pushed a 'get' on the stack
  • return true otherwise

Referenced by reco::parser::SingleInvoker::SingleInvoker().


Member Data Documentation

Definition at line 39 of file MethodSetter.h.

Definition at line 40 of file MethodSetter.h.

Definition at line 37 of file MethodSetter.h.

Definition at line 36 of file MethodSetter.h.

Definition at line 38 of file MethodSetter.h.