CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/CommonTools/Utils/src/findDataMember.cc

Go to the documentation of this file.
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.1 2009/02/24 14:10:22 llista Exp $
00012 //
00013 
00014 // system include files
00015 #include "Reflex/Base.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    Reflex::Member findDataMember(const Reflex::Type& iType, const std::string& iName, int& oError) {
00027       using namespace Reflex;
00028       Member returnValue;
00029       oError = parser::kNameDoesNotExist;
00030       Type type = iType;
00031       if(type) {
00032          if(type.IsPointer()) {
00033             type = type.ToType();
00034          }
00035          returnValue = type.DataMemberByName(iName);
00036          if(!returnValue) {
00037             //check inheriting classes
00038             for(Base_Iterator b = type.Base_Begin(); b != type.Base_End(); ++ b) {
00039                returnValue = findDataMember(b->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 = Member();
00048             oError = parser::kIsNotPublic;
00049          }
00050       }
00051       if(returnValue) {
00052          oError = parser::kNoError;
00053       }
00054       return returnValue;
00055    }
00056 }