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
// -*- C++ -*-
//
// Package:     Utilities
// Class  :     findDataMember
//
// Implementation:
//     <Notes on implementation>
//
// Original Author:  Chris Jones
//         Created:  Wed Aug 13 10:07:46 EDT 2008
// $Id: findDataMember.cc,v 1.3 2012/08/03 18:08:11 wmtan Exp $
//

// system include files
#include "TInterpreter.h"
#include "TVirtualMutex.h"

#include "FWCore/Reflection/interface/BaseWithDict.h"

// user include files
#include "CommonTools/Utils/src/findDataMember.h"
#include "CommonTools/Utils/src/ErrorCodes.h"

//
// constants, enums and typedefs
//

namespace reco {

  edm::MemberWithDict findDataMember(const edm::TypeWithDict& iType, const std::string& iName, int& oError) {
    edm::MemberWithDict ret;
    oError = parser::kNameDoesNotExist;
    edm::TypeWithDict type = iType;
    if (!bool(type)) {
      return ret;
    }
    if (type.isPointer()) {
      type = type.toType();
    }
    ret = type.dataMemberByName(iName);
    if (!bool(ret)) {
      // check base classes
      edm::TypeBases bases(type);
      for (auto const& B : bases) {
        ret = findDataMember(edm::BaseWithDict(B).typeOf(), iName, oError);
        //only stop if we found it or some other error happened
        if (bool(ret) || (oError != parser::kNameDoesNotExist)) {
          break;
        }
      }
    }
    if (bool(ret) && !ret.isPublic()) {
      ret = edm::MemberWithDict();
      oError = parser::kIsNotPublic;
    } else if (bool(ret)) {
      oError = parser::kNoError;
    }
    return ret;
  }

}  // namespace reco