This is Unofficial EPICS BASE Doxygen Site
reftrack.h
Go to the documentation of this file.
1 /*
2  * Copyright information and license terms for this software can be
3  * found in the file LICENSE that is included with the distribution
4  */
5 #ifndef REFTRACK_H
6 #define REFTRACK_H
7 
40 #ifdef __cplusplus
41 
42 #include <map>
43 #include <string>
44 #include <ostream>
45 
46 #include <stdlib.h>
47 
48 #include <epicsVersion.h>
49 #include <epicsAtomic.h>
50 
51 #define REFTRACE_INCREMENT(counter) ::epics::atomic::increment(counter)
52 #define REFTRACE_DECREMENT(counter) ::epics::atomic::decrement(counter)
53 
54 #include <shareLib.h>
55 
56 namespace epics {
57 
60 void registerRefCounter(const char *name, const size_t* counter);
61 
64 void unregisterRefCounter(const char *name, const size_t* counter);
65 
68 size_t readRefCounter(const char *name);
69 
71 class epicsShareClass RefSnapshot
72 {
73 public:
75  struct Count {
76  size_t current;
77  long delta;
78  Count() :current(0u), delta(0) {}
79  explicit Count(size_t c, long d) :current(c), delta(d) {}
80  bool operator==(const Count& o) const
81  { return current==o.current && delta==o.delta; }
82  };
83 
84 private:
85  typedef std::map<std::string, Count> cnt_map_t;
86  cnt_map_t counts;
87 public:
88  typedef cnt_map_t::const_iterator iterator;
89  typedef cnt_map_t::const_iterator const_iterator;
90 
95  void update();
96 
97  const Count& operator[](const std::string& name) const;
98 
99  iterator begin() const { return counts.begin(); }
100  iterator end() const { return counts.end(); }
101  size_t size() const { return counts.size(); }
102 
103  inline void swap(RefSnapshot& o)
104  {
105  counts.swap(o.counts);
106  }
107 
113  RefSnapshot operator-(const RefSnapshot& rhs) const;
114 };
115 
118 std::ostream& operator<<(std::ostream& strm, const RefSnapshot& snap);
119 
122 class epicsShareClass RefMonitor
123 {
124  struct Impl;
125  Impl *impl;
126 public:
127  RefMonitor();
128  virtual ~RefMonitor();
129 
130  void start(double period=10.0);
131  void stop();
132  bool running() const;
133 
135  void current();
136 protected:
139  virtual void show(const RefSnapshot& snap, bool complete=false);
140 };
141 
142 } // namespace epics
143 
144 extern "C" {
145 #endif /* __cplusplus */
146 
151 
152 #ifdef __cplusplus
153 }
154 #endif /* __cplusplus */
155 
156 #endif // REFTRACK_H
size_t readRefCounter(const char *name)
Definition: reftrack.cpp:75
char * epicsRefSnapshotCurrent()
Definition: reftrack.cpp:267
#define epicsShareFunc
Definition: shareLib.h:209
TODO only here because of the Lockable.
Definition: ntaggregate.cpp:16
Mark external symbols and entry points for shared libraries.
epicsTime begin
Definition: caConnTest.cpp:22
void unregisterRefCounter(const char *name, const size_t *counter)
Definition: reftrack.cpp:66
std::ostream & operator<<(std::ostream &strm, const RefSnapshot &snap)
Definition: reftrack.cpp:145
#define epicsShareClass
Definition: shareLib.h:206
void registerRefCounter(const char *name, const size_t *counter)
Definition: reftrack.cpp:59
void swap(shared_ptr< T > &a, shared_ptr< T > &b) BOOST_NOEXCEPT
Definition: shared_ptr.hpp:783
bool operator==(const epics::pvData::shared_vector< A > &a, const epics::pvData::shared_vector< B > &b)
Definition: sharedVector.h:967