uniq_memory.hh
Go to the documentation of this file.
00001 /* -*- C++ -*-
00002  * $Id: uniq_memory.hh 961 2005-03-11 14:05:33Z fpy $
00003  */
00004 #ifndef UTILMM_SMART_UNIQ_MEMORY_HEADER
00005 # define UTILMM_SMART_UNIQ_MEMORY_HEADER
00006 
00007 #include "utilmm/hash/hash_map.hh"
00008 
00009 namespace utilmm {
00010   namespace smart {
00011     namespace ref_count {
00012 
00028       template<typename Ty, class Hash>
00029       struct hash_ptr
00030         :public std::unary_function<Ty const *, size_t> {
00041         size_t operator()(Ty const *arg) const;
00042       }; // struct utilmm::smart::ref_count::hash_ptr<>
00043 
00044 
00059       template<typename Ty, class Equal>
00060       struct eq_ptr
00061         :public std::binary_function<Ty const *, Ty const *, bool> {
00074         bool operator()(Ty const *a, Ty const *b) const;
00075       }; // struct utilmm::smart::ref_count::eq_ptr<>
00076 
00096       template<typename Ty, class Hash, class Equal>
00097       class uniq_memory {
00098       public:
00100         typedef Ty const base_type;
00101         
00102       private:
00103         typedef hash_map< base_type *, size_t, hash_ptr<Ty, Hash>,
00104                           eq_ptr<Ty, Equal> > mem_type;
00105 
00106         mem_type the_mem;
00107         
00108       public:
00110         typedef typename mem_type::iterator mem_cell;
00111 
00118         mem_cell null_cell() {
00119           return the_mem.end();
00120         }
00121 
00134         mem_cell create(base_type *ptr);
00135 
00143         void destroy(mem_cell c);
00144       }; // class utilmm::smart::ref_count::uniq_memory<>
00145 
00146     } // namespace utilmm::smart::ref_count
00147   } // namespace utilmm::smart
00148 } // namespace utilmm
00149 
00150 # define IN_UTILMM_SMART_UNIQ_MEMORY_HEADER
00151 #include "utilmm/smart/bits/uniq_memory.tcc"
00152 # undef IN_UTILMM_SMART_UNIQ_MEMORY_HEADER
00153 #endif // UTILMM_SMART_UNIQ_MEMORY_HEADER
00154 


utilmm
Author(s): Sylvain Joyeux/sylvain.joyeux@m4x.org
autogenerated on Thu Jan 2 2014 11:38:31