IMP
2.0.0
The Integrative Modeling Platform
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
raii_macros.h
Go to the documentation of this file.
1
/**
2
* \file IMP/base/raii_macros.h
3
* \brief Various general useful macros for IMP.
4
*
5
* Copyright 2007-2013 IMP Inventors. All rights reserved.
6
*
7
*/
8
9
#ifndef IMPBASE_RAII_MACROS_H
10
#define IMPBASE_RAII_MACROS_H
11
#include <IMP/base/base_config.h>
12
#include "
showable_macros.h
"
13
#include "
RAII.h
"
14
15
//! Declare a RAII-style class
16
/** Since such classes are typically quite small and simple, all
17
the implementation is inline. The macro declares
18
- default constructor
19
- RAII::set()
20
- RAII::reset()
21
- destructor
22
The Set and Reset arguments are the code to run in the respective
23
functions. "args" are the argument string (in parens) for the
24
constructor and set.
25
*/
26
#define IMP_RAII(Name, args, Initialize, Set, Reset, Show) \
27
IMP_HELPER_MACRO_PUSH_WARNINGS \
28
Name() {Initialize;} \
29
explicit Name args {Initialize; Set;} \
30
void set args {reset(); \
31
Set;} \
32
void reset() {Reset;} \
33
~Name () {reset();} \
34
IMP_HELPER_MACRO_POP_WARNINGS \
35
IMP_SHOWABLE_INLINE(Name, out << #Name << '('; Show; out << ')')
36
37
38
39
40
#endif
/* IMPBASE_RAII_MACROS_H */