00001 // -*- C++ -*- 00002 // 00003 // Package: Utilities 00004 // Class : findDataMember 00005 // 00006 // Implementation: 00007 // <Notes on implementation> 00008 // 00009 // Original Author: Chris Jones 00010 // Created: Wed Aug 13 10:07:46 EDT 2008 00011 // $Id: findDataMember.cc,v 1.3 2012/08/03 18:08:11 wmtan Exp $ 00012 // 00013 00014 // system include files 00015 #include "FWCore/Utilities/interface/BaseWithDict.h" 00016 00017 // user include files 00018 #include "CommonTools/Utils/src/findDataMember.h" 00019 #include "CommonTools/Utils/src/ErrorCodes.h" 00020 00021 // 00022 // constants, enums and typedefs 00023 // 00024 00025 namespace reco { 00026 edm::MemberWithDict findDataMember(const edm::TypeWithDict& iType, const std::string& iName, int& oError) { 00027 edm::MemberWithDict returnValue; 00028 oError = parser::kNameDoesNotExist; 00029 edm::TypeWithDict type = iType; 00030 if(type) { 00031 if(type.isPointer()) { 00032 type = type.toType(); 00033 } 00034 returnValue = type.dataMemberByName(iName); 00035 if(!returnValue) { 00036 //check inheriting classes 00037 edm::TypeBases bases(type); 00038 for(auto const& base : bases) { 00039 returnValue = findDataMember(edm::BaseWithDict(base).toType(), iName, oError); 00040 //only stop if we found it or some other error happened 00041 if(returnValue || parser::kNameDoesNotExist != oError) { 00042 break; 00043 } 00044 } 00045 } 00046 if(returnValue && !returnValue.isPublic()) { 00047 returnValue = edm::MemberWithDict(); 00048 oError = parser::kIsNotPublic; 00049 } 00050 } 00051 if(returnValue) { 00052 oError = parser::kNoError; 00053 } 00054 return returnValue; 00055 } 00056 }