MethodSetter

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
#ifndef CommonTools_Utils_MethodSetter_h
#define CommonTools_Utils_MethodSetter_h

/* \class reco::parser::MethodSetter
 *
 * \author Luca Lista, INFN
 *
 */

#include "CommonTools/Utils/interface/parser/MethodStack.h"
#include "CommonTools/Utils/interface/parser/TypeStack.h"
#include "CommonTools/Utils/interface/parser/MethodArgumentStack.h"

namespace reco {
  namespace parser {

    class MethodSetter {
    private:
      MethodStack& methStack_;
      LazyMethodStack& lazyMethStack_;
      TypeStack& typeStack_;
      MethodArgumentStack& intStack_;
      bool lazy_;

    public:
      explicit MethodSetter(MethodStack& methStack,
                            LazyMethodStack& lazyMethStack,
                            TypeStack& typeStack,
                            MethodArgumentStack& intStack,
                            bool lazy = false)
          : methStack_(methStack),
            lazyMethStack_(lazyMethStack),
            typeStack_(typeStack),
            intStack_(intStack),
            lazy_(lazy) {}

      void operator()(const char*, const char*) const;

      /// Resolve the name to either a function member or a data member,
      /// push a MethodInvoker on the MethodStack, and its return type to
      /// the 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 an edm::Ref/Ptr/RefToBase and the method is not
      /// found in the 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
      ///
      bool push(const std::string&, const std::vector<AnyMethodArgument>&, const char*, bool deep = true) const;
    };

  }  // namespace parser
}  // namespace reco

#endif  // CommonTools_Utils_MethodSetter_h