IMP logo
IMP Reference Guide  2.20.0
The Integrative Modeling Platform
RAII.h
Go to the documentation of this file.
1 /**
2  * \file IMP/RAII.h \brief Basic types used by IMP.
3  * \brief Temporarily change something; undo the change when object destroyed
4  *
5  * Copyright 2007-2022 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 
16 IMPKERNEL_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  */
28 class RAII : public NonCopyable {
29  protected:
30  RAII() {}
31 };
32 
33 IMPKERNEL_END_NAMESPACE
34 
35 #endif /* IMPKERNEL_RAI_I_H */
Base class for all objects that cannot be copied.
Temporarily change something; undo the change when this object is destroyed.
Definition: RAII.h:28
Base class for all objects that cannot be copied.
Definition: NonCopyable.h:22
Various general useful macros for IMP.