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