zbsHash.h

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 #ifndef ZBSHASH_H
00008 #define ZBSHASH_H
00009 
00010 // boost include
00011 #include <boost/multi_index_container.hpp>
00012 #include <boost/multi_index/hashed_index.hpp>
00013 #include <boost/multi_index/member.hpp>
00014 #include <boost/multi_index/ordered_index.hpp>
00015 #include <boost/tokenizer.hpp>
00016 
00017 using boost::multi_index_container;
00018 using namespace boost::multi_index;
00019 
00020 
00021 struct bsreadContainer
00022 {
00023 long          by_bsID;
00024 std::string by_bsName;
00025 
00026         bsreadContainer(long _id, std::string _name):by_bsID(_id),by_bsName(_name){};
00027         
00028         friend std::ostream& operator<<(std::ostream& os, const bsreadContainer& m)
00029         {
00030                 //os<<m.by_bsID << " " << m.by_bsName << std::endl;
00031                 os << m.by_bsName << std::endl;
00032                 return os;
00033         }
00034 };
00035 
00036 struct by_bsID{};
00037 struct by_bsName{};
00038 
00039 typedef multi_index_container<
00040         bsreadContainer,
00041                 indexed_by<
00042                         ordered_unique<
00043                           tag<by_bsName>, BOOST_MULTI_INDEX_MEMBER(bsreadContainer, std::string , by_bsName)>,
00044                         ordered_non_unique<
00045                           tag<by_bsID>,   BOOST_MULTI_INDEX_MEMBER(bsreadContainer, long, by_bsID )> >
00046  > bsreadContainer_set;
00047 
00048 
00049 template<typename Tag,typename MultiIndexContainer>
00050 void print_out_by(
00051  const MultiIndexContainer& s,
00052  Tag* =0 
00053 )
00054 {
00055         
00056 // obtain a reference to the index tagged by Tag 
00057 
00058   const typename boost::multi_index::index<MultiIndexContainer,Tag>::type& i=
00059     get<Tag>(s);
00060 
00061   typedef typename MultiIndexContainer::value_type value_type;
00062 
00063 // dump the elements of the index to cout 
00064   std::cout << "--------------" << std::endl;
00065   std::cout << " ENUMERATED LIST " << std::endl;
00066   std::cout << "--------------" << std::endl;
00067   std::copy(i.begin(),i.end(),std::ostream_iterator<value_type>(std::cout));
00068   std::cout << "--------------------" << std::endl;
00069 }
00070 
00071 typedef bsreadContainer_set::index<by_bsID>::type   bsreadContainer_set_by_id;
00072 typedef bsreadContainer_set::index<by_bsName>::type bsreadContainer_set_by_name;
00073 
00074 
00075 #endif
00076 
00077 

Generated on 28 May 2018 for CAFE by  doxygen 1.6.1