ELmap.h
Go to the documentation of this file.
1 #ifndef messagefacility_Utilities_ELmap_h
2 #define messagefacility_Utilities_ELmap_h
3 
4 // ----------------------------------------------------------------------
5 //
6 // ELmap.h Provides a map class with the semantics of std::map.
7 // Customizers may substitute for this class to provide either
8 // a map with a different allocator, or whatever else.
9 //
10 // We typedef an individual type for each of these maps since
11 // the syntax
12 // typedef map ELmap;
13 // ELlist<ELextededID, Counts, ELextendedID::less> table;
14 // may or may not be valid C++, and if valid probably won't work
15 // everywhere.
16 //
17 // The key types are common enough types (strings and extended id's);
18 // the data types are peculiar to each type of map. We have made the
19 // design choice of grouping all maps in this one file, so that if
20 // a customizer needs to do something else with maps, all the slop is
21 // in one place.
22 //
23 // The drawback is that all the classes that depend on these maps must
24 // include ELmap.h, which pulls in not only the maps and structs they
25 // need but those anybody else needs. Fortunately, only two classes
26 // use maps at all: ELlimitsTable and the ELstatistics destination.
27 // So this drawback is very slight.
28 //
29 // The elements of map semantics which ErrorLogger code rely upon are
30 // listed in ELmap.semantics.
31 //
32 // ----------------------------------------------------------------------
33 
35 
36 #include <map>
37 #include <string>
38 
39 namespace mf {
40 
42  public:
43  int limit;
44  int timespan;
45  int interval;
46 
47  LimitAndTimespan(int lim = -1, int ts = -1, int ivl = -1);
48 
49  }; // LimitAndTimespan
50 
51  class CountAndLimit {
52  public:
53  int n{};
54  int aggregateN{};
55  time_t lastTime;
56  int limit;
57  int timespan;
58  int interval;
59  int skipped;
60 
61  CountAndLimit(int lim = -1, int ts = -1, int ivl = -1);
62  bool add();
63 
64  }; // CountAndLimit
65 
66  class StatsCount {
67  public:
68  int n{};
69  int aggregateN{};
70  bool ignoredFlag{false};
71  std::string context1{};
72  std::string context2{};
73  std::string contextLast{};
74 
75  void add(std::string const& context, bool reactedTo);
76 
77  }; // StatsCount
78 
79  // ----------------------------------------------------------------------
80 
81  using ELmap_limits = std::map<std::string, LimitAndTimespan>;
82  using ELmap_counts = std::map<ELextendedID, CountAndLimit>;
83  using ELmap_stats = std::map<ELextendedID, StatsCount>;
84 
85  // See ELseverityLevel.cc for another map: ELmap_sevTran
86 }
87 
88 #endif /* messagefacility_Utilities_ELmap_h */
89 
90 // Local variables:
91 // mode: c++
92 // End:
time_t lastTime
Definition: ELmap.h:55
LimitAndTimespan(int lim=-1, int ts=-1, int ivl=-1)
Definition: ELmap.cc:11
std::string string
Definition: nybbler.cc:12
std::map< ELextendedID, CountAndLimit > ELmap_counts
Definition: ELmap.h:82
std::map< ELextendedID, StatsCount > ELmap_stats
Definition: ELmap.h:83
std::map< std::string, LimitAndTimespan > ELmap_limits
Definition: ELmap.h:81