Merge pull request #2258 from likema/log-msg-reset-ostream
[ACE_TAO.git] / TAO / orbsvcs / examples / FaultTolerance / RolyPoly / LogStdMap.h
blob936dcaac79a5285e69db59d467702537ffbcba51
1 // file : RolyPoly/LogStdMap.h
2 // author : Boris Kolpackov <boris@dre.vanderbilt.edu>
3 #ifndef LOG_STD_MAP_H
4 #define LOG_STD_MAP_H
6 #include <map>
8 template <typename RI, typename RV>
9 class Log
11 public:
12 typedef RI RecordIdType;
13 typedef RV RecordValueType;
15 private:
16 typedef
17 std::map <RecordIdType, RecordValueType>
18 Map_;
20 public:
21 class Duplicate {};
22 class NotFound {};
24 void
25 insert (RecordIdType const& ri, RecordValueType const& rv)
27 if (!map_.insert (std::make_pair (ri, rv)).second)
29 throw Duplicate ();
33 bool
34 contains (RecordIdType const& ri) const
36 return map_.count (ri) != 0;
40 RecordValueType const&
41 lookup (RecordIdType const& ri) const
43 typename Map_::const_iterator i = map_.find (ri);
45 if (i != map_.end ()) return i->second;
46 else throw NotFound ();
49 private:
50 Map_ map_;
53 #endif // LOG_STD_MAP_H