Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:17

0001 #ifndef CommonTools_Utils_MethodSetter_h
0002 #define CommonTools_Utils_MethodSetter_h
0003 
0004 /* \class reco::parser::MethodSetter
0005  *
0006  * \author Luca Lista, INFN
0007  *
0008  */
0009 
0010 #include "CommonTools/Utils/interface/parser/MethodStack.h"
0011 #include "CommonTools/Utils/interface/parser/TypeStack.h"
0012 #include "CommonTools/Utils/interface/parser/MethodArgumentStack.h"
0013 
0014 namespace reco {
0015   namespace parser {
0016 
0017     class MethodSetter {
0018     private:
0019       MethodStack& methStack_;
0020       LazyMethodStack& lazyMethStack_;
0021       TypeStack& typeStack_;
0022       MethodArgumentStack& intStack_;
0023       bool lazy_;
0024 
0025     public:
0026       explicit MethodSetter(MethodStack& methStack,
0027                             LazyMethodStack& lazyMethStack,
0028                             TypeStack& typeStack,
0029                             MethodArgumentStack& intStack,
0030                             bool lazy = false)
0031           : methStack_(methStack),
0032             lazyMethStack_(lazyMethStack),
0033             typeStack_(typeStack),
0034             intStack_(intStack),
0035             lazy_(lazy) {}
0036 
0037       void operator()(const char*, const char*) const;
0038 
0039       /// Resolve the name to either a function member or a data member,
0040       /// push a MethodInvoker on the MethodStack, and its return type to
0041       /// the TypeStack (after stripping "*" and "&").
0042       ///
0043       /// This method is used also by the LazyInvoker to perform the fetch once
0044       /// the final type is known.
0045       ///
0046       /// If the object is an edm::Ref/Ptr/RefToBase and the method is not
0047       /// found in the class:
0048       ///
0049       ///  1)  it pushes a no-argument 'get()' method
0050       ///
0051       ///  2)  if deep = true, it attempts to resolve and push the method on
0052       ///      the object to which the edm ref points to.  In that case, the
0053       ///      MethodStack will contain two more items after this call instead
0054       ///      of just one.  This behaviour is what you want for non-lazy parsing.
0055       ///
0056       ///  2b) if instead deep = false, it just pushes the 'get' on the stack.
0057       ///      this will allow the LazyInvoker to then re-discover the runtime
0058       ///      type of the pointee
0059       ///
0060       ///  The method will:
0061       ///     - throw exception, if the member can't be resolved
0062       ///     - return 'false' if deep = false and it only pushed
0063       //        a 'get' on the stack
0064       ///     - return true otherwise
0065       ///
0066       bool push(const std::string&, const std::vector<AnyMethodArgument>&, const char*, bool deep = true) const;
0067     };
0068 
0069   }  // namespace parser
0070 }  // namespace reco
0071 
0072 #endif  // CommonTools_Utils_MethodSetter_h