Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CDL2STL.h

Go to the documentation of this file.
00001 
00022 #ifndef CDL2STL_H
00023 #define CDL2STL_H
00024 
00025 #include <vector>
00026 #include <list>
00027 #include "Candidate/CandHandle.h"
00028 
00029 
00032 namespace DataUtil {
00033 
00057 template<class OutputIterator, class CandDaughterType>
00058 OutputIterator CDL2STL(const CandHandle& handle, OutputIterator result)
00059 {
00060 
00061     TIter next = handle.GetDaughterIterator();
00062     TObject* obj;
00063     while ((obj=next())) {
00064         *result = dynamic_cast<CandDaughterType*>(obj);
00065         ++result;
00066     }
00067     return result;
00068 }
00069 
00095 template<class OutputIterator>
00096 OutputIterator CDL2STL(const CandHandle& handle, OutputIterator result)
00097 {
00098     return CDL2STL<OutputIterator,const CandHandle>(handle,result);
00099 }
00100 
00101 
00113 template<class CandDaughterType>
00114 std::vector<const CandDaughterType*> CDL2STLvector(const CandHandle& handle)
00115 {
00116     typedef std::vector<const CandDaughterType*> dvec_t;
00117     dvec_t dv;
00118     typedef std::back_insert_iterator<dvec_t> dv_inserter;
00119 
00120     dv_inserter dvi(dv);
00121     DataUtil::CDL2STL<dv_inserter,const CandDaughterType>(handle,dvi);
00122     return dv;
00123 }
00124 #if 1
00125 
00126 template<class CandDaughterType>
00127 std::vector<CandDaughterType*> CDL2STLvector(CandHandle& handle)
00128 {
00129     typedef std::vector<CandDaughterType*> dvec_t;
00130     dvec_t dv;
00131     typedef std::back_insert_iterator<dvec_t> dv_inserter;
00132 
00133     dv_inserter dvi(dv);
00134     DataUtil::CDL2STL<dv_inserter, CandDaughterType>(handle,dvi);
00135     return dv;
00136 }
00137 #endif
00138 
00147 template<class CandDaughterType>
00148 std::list<const CandDaughterType*> CDL2STLlist(const CandHandle& handle)
00149 {
00150     typedef std::list<const CandDaughterType*> dvec_t;
00151     dvec_t dv;
00152     typedef std::back_insert_iterator<dvec_t> dv_inserter;
00153     dv_inserter dvi(dv);
00154     DataUtil::CDL2STL<dv_inserter,const CandDaughterType>(handle,dvi);
00155     return dv;
00156 }
00157 #if 1
00158 
00159 template<class CandDaughterType>
00160 std::list<CandDaughterType*> CDL2STLlist(CandHandle& handle)
00161 {
00162     typedef std::list<CandDaughterType*> dvec_t;
00163     dvec_t dv;
00164     typedef std::back_insert_iterator<dvec_t> dv_inserter;
00165     dv_inserter dvi(dv);
00166     DataUtil::CDL2STL<dv_inserter, CandDaughterType>(handle,dvi);
00167     return dv;
00168 }
00169 #endif
00170 
00171          
00172     
00173 
00174 } // namespace DataUtil
00175 
00176 #endif  // CDL2STL_H

Generated on Mon Feb 15 11:06:30 2010 for loon by  doxygen 1.3.9.1