IMP  2.0.0
The Integrative Modeling Platform
WarningContext.h
Go to the documentation of this file.
1 /**
2  * \file IMP/base/WarningContext.h
3  * \brief Logging and error reporting support.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPBASE_CREATE_WARNING_CONTEXT_H
10 #define IMPBASE_CREATE_WARNING_CONTEXT_H
11 
12 #include <IMP/base/base_config.h>
13 #include "showable_macros.h"
14 #include <IMP/base/set.h>
15 
16 IMPBASE_BEGIN_NAMESPACE
17 #if IMP_HAS_CHECKS
18 /** Warnings with the same key within the context are only output once.*/
19 struct IMPBASEEXPORT WarningContext {
20  mutable base::set<std::string> data_;
21 public:
22  void add_warning(std::string key, std::string warning) const;
23  void clear_warnings() const;
24  void dump_warnings() const;
25  ~WarningContext();
26  IMP_SHOWABLE_INLINE(WarningContext, out << data_.size() << " warnings");
27 };
28 #else
29 struct IMPBASEEXPORT WarningContext {
30 public:
32  void add_warning(std::string, std::string ) const {}
33  void clear_warnings() const {}
34  void dump_warnings() const {}
35  void show(std::ostream &) const {}
36 };
37 #endif
38 
39 
40 IMPBASE_END_NAMESPACE
41 
42 
43 #endif /* IMPBASE_CREATE_WARNING_CONTEXT_H */