IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
RAII.h
Go to the documentation of this file.
1/**
2 * \file IMP/RAII.h
3 * \brief Temporarily change something; undo the change when object destroyed.
4 *
5 * Copyright 2007-2026 IMP Inventors. All rights reserved.
6 *
7 */
8
9#ifndef IMPKERNEL_RAI_I_H
10#define IMPKERNEL_RAI_I_H
11
12#include <IMP/kernel_config.h>
13#include "NonCopyable.h"
14#include "utility_macros.h"
15
16IMPKERNEL_BEGIN_NAMESPACE
17
18//! Temporarily change something; undo the change when this object is destroyed
19/** An RAII class (Resource Acquisition Is Initialization) provides a way of
20 temporarily changing something and undoing the change when the RAII object
21 is destroyed. Examples include reference counting and changing the log level
22 where you want to do something (increase the amount of logging), but ensure
23 that when your function exits, things are put back to how they were before.
24
25 In Python, all RAII objects also support the context manager protocol
26 (the 'with' statement), and its use is strongly encouraged.
27 */
28class RAII : public NonCopyable {
29 protected:
30 RAII() {}
31};
32
33IMPKERNEL_END_NAMESPACE
34
35#endif /* IMPKERNEL_RAI_I_H */
Base class for all objects that cannot be copied.
Various general useful macros for IMP.