00001 #ifndef DCHAIN_SELECTIVEINSERTER_H 00002 #define DCHAIN_SELECTIVEINSERTER_H 00003 // -*- C++ -*- 00004 // 00005 // Package: <DChain> 00006 // Module: SelectiveInserter 00007 // 00016 // 00017 // Author: Chris D Jones 00018 // Created: Thu Jan 5 15:40:59 EST 2006 00019 // $Id: SelectiveInserter.h,v 1.1.1.1 2009/03/03 06:06:56 maqm Exp $ 00020 // 00021 // Revision history 00022 // 00023 // $Log: SelectiveInserter.h,v $ 00024 // Revision 1.1.1.1 2009/03/03 06:06:56 maqm 00025 // first import of DecayChain 00026 // 00027 // Revision 1.1 2006/01/11 20:28:18 cdj 00028 // massive class renaming, addition of [] for selection and unit tests 00029 // 00030 00031 // system include files 00032 #include <iterator> 00033 00034 // user include files 00035 00036 // forward declarations 00037 namespace dchain { 00038 template<class TList, class TSelect> 00039 struct SelectiveInserter { 00040 typedef std::output_iterator_tag iterator_category; 00041 typedef void value_type; 00042 typedef void difference_type; 00043 00044 SelectiveInserter(TList& iList, 00045 const TSelect& iSelect): 00046 m_list(&iList), 00047 m_select(iSelect) {} 00048 SelectiveInserter<TList,TSelect>& operator*() { 00049 return *this; } 00050 00051 SelectiveInserter<TList,TSelect>& operator++() { 00052 return *this; 00053 } 00054 00055 SelectiveInserter<TList,TSelect>& operator+(int) { 00056 return *this; 00057 } 00058 00060 template<class THolder> 00061 bool operator=(THolder iHolder){ 00062 return m_list->attempt_insert(iHolder, m_select); 00063 } 00064 private: 00065 TList* m_list; 00066 TSelect m_select; 00067 }; 00068 } 00069 #endif /* DCHAIN_SELECTIVEINSERTER_H */