00001 #ifndef DCHAIN_FILLLISTWITHSELECTION_H 00002 #define DCHAIN_FILLLISTWITHSELECTION_H 00003 // -*- C++ -*- 00004 // 00005 // Package: <DChain> 00006 // Module: FillListWithSelection 00007 // 00016 // 00017 // Author: Chris D Jones 00018 // Created: Sat Dec 24 13:10:55 EST 2005 00019 // $Id: FillListWithSelection.h,v 1.1.1.1.2.1 2014/04/18 00:56:43 maqm Exp $ 00020 // 00021 // Revision history 00022 // 00023 // $Log: FillListWithSelection.h,v $ 00024 // Revision 1.1.1.1.2.1 2014/04/18 00:56:43 maqm 00025 // remove mutable for TList ref. 00026 // 00027 // Revision 1.1.1.1 2009/03/03 06:06:56 maqm 00028 // first import of DecayChain 00029 // 00030 // Revision 1.1 2006/01/11 20:28:27 cdj 00031 // massive class renaming, addition of [] for selection and unit tests 00032 // 00033 00034 // system include files 00035 00036 // user include files 00037 00038 // forward declarations 00039 00040 namespace dchain { 00041 template< class CandidateClass> 00042 class CombinatoricList; 00043 00044 template<class TIList, class TSelector,class TOList> 00045 void fill_using_selector(const TIList& iList, 00046 const TSelector& iSelector, 00047 TOList& oList) { 00048 oList.fill(iList, iSelector); 00049 } 00050 00051 template<class TList, class TSelector> 00052 class FillListWithSelection 00053 { 00054 // ---------- friend classes and functions --------------- 00055 00056 public: 00057 // ---------- constants, enums and typedefs -------------- 00058 00059 // ---------- Constructors and destructor ---------------- 00060 FillListWithSelection(TList& ioList, const TSelector& iSel): 00061 m_list(ioList), m_selector(iSel) {} 00062 //virtual ~FillListWithSelection(); 00063 00064 // ---------- member functions --------------------------- 00065 const TList& operator=(const TList& iList) const { 00066 m_list.erase(); 00067 fill_using_selector(iList, m_selector, m_list); 00068 return m_list; 00069 } 00070 00071 template <class TAList> 00072 const TList& operator=(const TAList& iList) const { 00073 m_list.erase(); 00074 fill_using_selector(iList, m_selector, m_list); 00075 return m_list; 00076 } 00077 00078 template< class TCandidate> 00079 const TList& operator=( const CombinatoricList< TCandidate >& aOtherList ) { 00080 m_list.erase(); 00081 fill_using_selector(aOtherList, m_selector, m_list); 00082 return m_list; 00083 } 00084 00085 // ---------- const member functions --------------------- 00086 00087 // ---------- static member functions -------------------- 00088 00089 protected: 00090 // ---------- protected member functions ----------------- 00091 00092 // ---------- protected const member functions ----------- 00093 00094 private: 00095 // ---------- Constructors and destructor ---------------- 00096 //FillListWithSelection( const FillListWithSelection& ); // stop default 00097 00098 // ---------- assignment operator(s) --------------------- 00099 //const FillListWithSelection& operator=( const FillListWithSelection& ); // stop default 00100 00101 // ---------- private member functions ------------------- 00102 00103 // ---------- private const member functions ------------- 00104 00105 // ---------- data members ------------------------------- 00106 TList& m_list; 00107 const TSelector& m_selector; 00108 00109 // ---------- static data members ------------------------ 00110 00111 }; 00112 00113 // inline function definitions 00114 00115 // Uncomment the following lines, if your class is templated 00116 // and has an implementation file (in the Template directory) 00117 //#if defined(INCLUDE_TEMPLATE_DEFINITIONS) 00118 //# include "DChain/Template/FillListWithSelection.cc" 00119 //#endif 00120 } 00121 #endif /* DCHAIN_FILLLISTWITHSELECTION_H */