Deprecator.h
Go to the documentation of this file.
1 #ifndef _utl_deprecator_h_
2 #define _utl_deprecator_h_
3 
4 #include <string>
5 #include <map>
6 #include <utl/AugerException.h>
7 #include <utl/Singleton.h>
8 
9 
10 namespace utl {
11 
54  class Deprecator : public Singleton<Deprecator> {
55  public:
57 
62  Deprecator() { }
63 
65 
70  void Deprecated(const std::string& theInterface,
71  const std::string& theVersion,
72  const std::string& theNewUsageHint);
73 
75  bool IsEmpty() const { return fData.empty(); }
76 
78  std::size_t GetSize() const { return fData.size(); }
79 
81  std::string GetReport() const;
82 
83  private:
86  public:
87  DeprecationInfo(const std::string& theHint,
88  const std::string& theVersion)
89  : fHint(theHint), fVersion(theVersion), fCount(1) { }
90 
91  void IncrementUsage() { ++fCount; }
92 
93  const std::string& GetHint() const { return fHint; }
94 
95  const std::string& GetVersion() const { return fVersion; }
96 
97  std::size_t GetCount() const { return fCount; }
98  private:
100  std::string fHint;
102  std::string fVersion;
104  std::size_t fCount;
105  };
106 
107  typedef std::map<std::string, DeprecationInfo> DataMap;
109  };
110 
111 }
112 
113 
114 #endif
std::string GetReport() const
Get the final report on interface usage problems.
Definition: Deprecator.cc:37
Deprecator()
Constructor.
Definition: Deprecator.h:62
std::map< std::string, DeprecationInfo > DataMap
Definition: Deprecator.h:107
const std::string & GetHint() const
Definition: Deprecator.h:93
std::size_t fCount
Count of uses of deprecated interface.
Definition: Deprecator.h:104
std::size_t GetCount() const
Definition: Deprecator.h:97
const std::string & GetVersion() const
Definition: Deprecator.h:95
std::string fVersion
Version since when this interface is deprecated.
Definition: Deprecator.h:102
Class to collect and provide information about deprecated class interfaces.
Definition: Deprecator.h:54
void Deprecated(const std::string &theInterface, const std::string &theVersion, const std::string &theNewUsageHint)
Log the usage of a deprecated interface and emit a warning.
Definition: Deprecator.cc:21
bool IsEmpty() const
Check if empty, i.e., no deprecated usage registered.
Definition: Deprecator.h:75
Information about the deprecated interface.
Definition: Deprecator.h:85
DeprecationInfo(const std::string &theHint, const std::string &theVersion)
Definition: Deprecator.h:87
std::size_t GetSize() const
Size, i.e., number of different deprecated interfaces uses.
Definition: Deprecator.h:78
std::string fHint
Hint what to do to avoid deprecated interface.
Definition: Deprecator.h:100
Curiously Recurring Template Pattern (CRTP) for Meyers singleton.
Definition: Singleton.h:36

, generated on Tue Sep 26 2023.