IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
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-2022 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
17IMPKERNEL_BEGIN_NAMESPACE
18class Object;
19
20//! A class to change and restore check state
21/**
22 To use, create an instance of this class with the check level you
23 want. When it goes out of scope, it will restore the old level.
24
25 \note This will not keep objects alive; make sure there is also some
26 other ref-counted pointer to them.
27
28 \ingroup checking
29 */
30class IMPKERNELEXPORT SetCheckState : public RAII {
31 CheckLevel level_;
32 Object *obj_;
33 void do_set(Object *o, CheckLevel l);
34 void do_reset();
35 void do_show(std::ostream &out) const;
36
37 public:
38 IMP_RAII(SetCheckState, (Object *o, CheckLevel l), {
39 level_ = DEFAULT_CHECK;
40 obj_ = nullptr;
41 },
42 { do_set(o, l); }, { if (level_ != DEFAULT_CHECK) do_reset(); },
43 do_show(out););
44
45 //! Construct it with the desired level and target
47 obj_ = nullptr;
48 level_ = DEFAULT_CHECK;
49 if (l != DEFAULT_CHECK) set(l);
50 }
51 void set(CheckLevel l);
52};
53
55
56IMPKERNEL_END_NAMESPACE
57
58#endif /* IMPKERNEL_SET_CHECK_STATE_H */
Common base class for heavy weight IMP objects.
Definition Object.h:111
A class to change and restore check state.
SetCheckState(CheckLevel l)
Construct it with the desired level and target.
void set(Object *o, CheckLevel l)
Assign new properties to the class.
Basic enumeration types used by IMP.
CheckLevel
Specify the level of runtime checks performed.
Definition enums.h:51
@ DEFAULT_CHECK
Definition enums.h:53
IMP::Vector< SetCheckState > SetCheckStates
Macros to aid in writing RAII-style classes.
#define IMP_RAII(Name, args, Initialize, Set, Reset, Show)
Declares RAII-style methods in a class.
Definition raii_macros.h:34
Macros to help in implementing Value objects.
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.