00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef VCSN_MISC_UNIQUE_HH
00018 # define VCSN_MISC_UNIQUE_HH
00019
00025 # include <list>
00026 # include <algorithm>
00027 # include <typeinfo>
00028 # include <map>
00029
00030 namespace vcsn
00031 {
00032 namespace misc
00033 {
00035 namespace unique
00036 {
00038 template <class T>
00039 struct UniqueListBase
00040 {
00041 virtual ~UniqueListBase ();
00042 };
00043
00044 typedef UniqueListBase<int> uniquelist_base;
00045
00053 template <typename T>
00054 struct uniquelist : public std::list<T>, public uniquelist_base
00055 {
00056 ~uniquelist ();
00057 };
00058
00071 template <class T>
00072 struct UniqueMap
00073 {
00076 template <class U>
00077 struct TiSlot
00078 {
00079 TiSlot (const std::type_info& );
00080 const std::type_info &id;
00081 bool operator== (const TiSlot& other) const;
00082 bool operator< (const TiSlot& other) const;
00083 };
00084
00085 typedef TiSlot<int> ti_slot;
00086
00088 typedef std::map<ti_slot, uniquelist_base*> map_t;
00089
00091 static map_t& instance ();
00092 protected:
00093 map_t map_;
00097 UniqueMap ();
00104 ~UniqueMap ();
00105 };
00106
00107 typedef UniqueMap<int> unique_map;
00108
00109 struct unifiable
00110 {
00111 inline unifiable ();
00112 inline unifiable (const unifiable&);
00113 private:
00114 template <typename T>
00115 friend const T& get (const T&);
00116 bool unique_;
00117 };
00118
00127 template <typename T>
00128 const T& get (const T&);
00129
00131 template <typename T>
00132 const T* get (const T*);
00133
00135 }
00136
00137 }
00138 }
00139
00140 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00141 # include <vaucanson/misc/unique.hxx>
00142 # endif // INTERFACE_ONLY
00143
00144 #endif // ! VCSN_MISC_UNIQUE_HH