MongoDB  2.7.0
trace.h
1 
29 #pragma once
30 
31 #include "mongo/pch.h"
32 
33 #include <boost/unordered_map.hpp>
34 #include "mongo/util/concurrency/rwlock.h"
35 
36 
37 namespace mongo {
38 
39  class Trace :
40  public boost::noncopyable {
41  public:
42 
43 #ifdef LATER
44 
49  static void setTraces(const string &names);
50 #endif
51 
52  static void setTrace(const string &name, unsigned level);
53 
60  static unsigned getTrace(const string &name);
61 
62  private:
63  Trace();
64  ~Trace();
65 
66  struct Hash :
67  unary_function<string, size_t> {
68  size_t operator()(const string &rS) const;
69  };
70 
71  typedef boost::unordered_map<string, unsigned, Trace::Hash> MapType;
72  class NameMap {
73  public:
74  NameMap();
75 
76  MapType traces;
77  };
78 
79  static NameMap *pMap; /* used by Trace(), so precedes it */
80  static SimpleRWLock lock; /* used by Trace(), so precedes it */
81  static Trace trace;
82  };
83 
84 }
85 
86 /* ======================= PRIVATE IMPLEMENTATIONS ========================== */
87 
88 namespace mongo {
89 
90  inline size_t Trace::Hash::operator()(const string &rS) const {
91  size_t seed = 0xf0afbeef;
92  boost::hash_combine(seed, rS);
93  return seed;
94  }
95 
96 }
separated out as later the implementation of this may be different than RWLock, depending on OS...
Definition: simplerwlock.h:39
static unsigned getTrace(const string &name)
Test to see if the given trace is on or off.
Definition: trace.cpp:85
Definition: trace.h:39