Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/vfind is written in an unsupported language. File is not indexed.

0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003 
0004 #ifndef tools_vfind
0005 #define tools_vfind
0006 
0007 #include <vector>
0008 #include <string>
0009 
0010 namespace tools {
0011 
0012 template <class T>
0013 inline T* find_named(const std::vector<T*>& a_vec,const std::string& a_name) {
0014   typedef typename std::vector<T*>::const_iterator it_t;
0015   it_t it;
0016   for(it=a_vec.begin();it!=a_vec.end();++it) {
0017     if((*it)->name()==a_name) return *it;
0018   }
0019   return 0;
0020 }
0021 
0022 template <class T>
0023 inline const T* find_obj_named(const std::vector<T>& a_vec,const std::string& a_name) {  //used in hep/pdgs.
0024   typedef typename std::vector<T>::const_iterator it_t;
0025   it_t it;
0026   for(it=a_vec.begin();it!=a_vec.end();++it) {
0027     if((*it).name()==a_name) return &(*it);
0028   }
0029   return 0;
0030 }
0031 template <class T>
0032 inline T* find_obj_named(std::vector<T>& a_vec,const std::string& a_name) {  //used in hep/pdgs.
0033   typedef typename std::vector<T>::iterator it_t;
0034   it_t it;
0035   for(it=a_vec.begin();it!=a_vec.end();++it) {
0036     if((*it).name()==a_name) return &(*it);
0037   }
0038   return 0;
0039 }
0040 
0041 }
0042 
0043 #include "touplow"
0044 
0045 namespace tools {
0046 
0047 template <class T>
0048 inline T* find_named_case_insensitive(const std::vector<T*>& a_vec,const std::string& a_name) {
0049   std::string low_a_name = a_name;
0050   tolowercase(low_a_name);
0051   std::string low_name;
0052   typedef typename std::vector<T*>::const_iterator it_t;
0053   it_t it;
0054   for(it=a_vec.begin();it!=a_vec.end();++it) {
0055     low_name = (*it)->name();
0056     tolowercase(low_name);
0057     if(low_name==low_a_name) return *it;
0058   }
0059   return 0;
0060 }
0061 
0062 }
0063 
0064 #endif