home
about
news
download
doc
source
systems
tests
bugs
contact
IMP Reference Guide
2.20.0
The Integrative Modeling Platform
IMP Manual
Reference Guide
Tutorial Index
Modules
Classes
Examples
include
IMP
version 2.20.0
ref_counted_macros.h
Go to the documentation of this file.
1
/**
2
* \file IMP/ref_counted_macros.h
3
* \brief Macros to help with reference counting.
4
*
5
* Copyright 2007-2022 IMP Inventors. All rights reserved.
6
*
7
*/
8
9
#ifndef IMPKERNEL_REF_COUNTED_MACROS_H
10
#define IMPKERNEL_REF_COUNTED_MACROS_H
11
#include <IMP/kernel_config.h>
12
#include "
utility_macros.h
"
13
14
#if defined(IMP_DOXYGEN)
15
//! Set up destructor for a ref counted object
16
/** This macro defines a virtual destructor for a ref counted object.
17
Ideally, the destructor would be defined private, so that the object
18
cannot be declared on the stack and so must be ref counted, but in
19
practice this breaks usage of the object with SWIG, some older compilers,
20
C++11 smart pointers (e.g. std::unique_ptr, std::shared_ptr), and
21
serialization, so a public destructor is used.
22
23
\see IMP_REF_COUNTED_NONTRIVIAL_DESTRUCTOR()
24
*/
25
#define IMP_REF_COUNTED_DESTRUCTOR(Name)
26
27
/** Like IMP_REF_COUNTED_DESTRUCTOR(), but the destructor is only
28
declared, not defined.
29
*/
30
#define IMP_REF_COUNTED_NONTRIVIAL_DESTRUCTOR(Name)
31
32
/** Like IMP_REF_COUNTED_DESTRUCTOR(), but the destructor is declared
33
inline.
34
*/
35
#define IMP_REF_COUNTED_INLINE_DESTRUCTOR(Name, destructor)
36
37
#else
38
#define IMP_REF_COUNTED_DESTRUCTOR(Name) \
39
public: \
40
virtual ~Name() {} \
41
IMP_REQUIRE_SEMICOLON_CLASS(destructor)
42
43
#define IMP_REF_COUNTED_INLINE_DESTRUCTOR(Name, dest) \
44
public: \
45
virtual ~Name() { dest } \
46
IMP_REQUIRE_SEMICOLON_CLASS(destructor)
47
48
#define IMP_REF_COUNTED_NONTRIVIAL_DESTRUCTOR(Name) \
49
public: \
50
virtual ~Name(); \
51
IMP_REQUIRE_SEMICOLON_CLASS(destructor)
52
#endif
53
54
#endif
/* IMPKERNEL_REF_COUNTED_MACROS_H */
utility_macros.h
Various general useful macros for IMP.