IMP logo
IMP Reference Guide  2.8.0
The Integrative Modeling Platform
SetCheckState.h
Go to the documentation of this file.
1 /**
2  * \file IMP/SetCheckState.h
3  * \brief Checking and error reporting support.
4  *
5  * Copyright 2007-2017 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPKERNEL_SET_CHECK_STATE_H
10 #define IMPKERNEL_SET_CHECK_STATE_H
11 
12 #include <IMP/kernel_config.h>
13 #include "enums.h"
14 #include "raii_macros.h"
15 #include "value_macros.h"
16 #include <IMP/nullptr.h>
17 
18 IMPKERNEL_BEGIN_NAMESPACE
19 class Object;
20 
21 //! A class to change and restore check state
22 /**
23  To use, create an instance of this class with the check level you
24  want. When it goes out of scope, it will restore the old level.
25 
26  \note This will not keep objects alive, make sure there is also some
27  other ref-counted pointer to them.
28 
29  \ingroup checking
30  */
31 class IMPKERNELEXPORT SetCheckState : public RAII {
32  CheckLevel level_;
33  Object *obj_;
34  void do_set(Object *o, CheckLevel l);
35  void do_reset();
36  void do_show(std::ostream &out) const;
37 
38  public:
40  level_ = DEFAULT_CHECK;
41  obj_ = nullptr;
42  },
43  { do_set(o, l); }, { do_reset(); }, do_show(out););
44 
45  //! Construct it with the desired level and target
47  obj_ = nullptr;
48  level_ = DEFAULT_CHECK;
49  set(l);
50  }
51  void set(CheckLevel l);
52 };
53 
55 
56 IMPKERNEL_END_NAMESPACE
57 
58 #endif /* IMPKERNEL_SET_CHECK_STATE_H */
Temporarily change something; undo the change when this object is destroyed.
Definition: RAII.h:26
#define IMP_RAII(Name, args, Initialize, Set, Reset, Show)
Declares RAII-style methods in a class.
Definition: raii_macros.h:34
SetCheckState(CheckLevel l)
Construct it with the desired level and target.
Definition: SetCheckState.h:46
A more IMP-like version of the std::vector.
Definition: Vector.h:39
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
Definition: value_macros.h:23
Provide a nullptr keyword analog.
Common base class for heavy weight IMP objects.
Definition: Object.h:106
A class to change and restore check state.
Definition: SetCheckState.h:31
Basic types used by IMP.
CheckLevel
Specify the level of runtime checks performed.
Definition: enums.h:53
Various general useful macros for IMP.
Various general useful macros for IMP.