IMP
2.0.1
The Integrative Modeling Platform
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
swap_macros.h
Go to the documentation of this file.
1
/**
2
* \file IMP/base/swap_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_SWAP_MACROS_H
10
#define IMPBASE_SWAP_MACROS_H
11
#include <IMP/base/base_config.h>
12
13
#if !defined(SWIG)
14
/** \name Swap helpers
15
16
Use the swap_with member function to swap two objects. The two
17
objects mustbe of the same type (Name) and define
18
the method \c swap_with(). The number suffix is the number of template
19
arguments, all of which must be of class type.
20
@{
21
*/
22
#define IMP_SWAP(Name) \
23
inline void swap(Name &a, Name &b) {a.swap_with(b);} \
24
IMP_REQUIRE_SEMICOLON_NAMESPACE
25
26
27
#define IMP_SWAP_1(Name) \
28
template <class A> \
29
inline void swap(Name<A> &a, Name<A> &b) {a.swap_with(b);} \
30
IMP_REQUIRE_SEMICOLON_NAMESPACE
31
32
33
34
#define IMP_SWAP_2(Name) \
35
template <class A, class B> \
36
inline void swap(Name<A,B> &a, Name<A,B> &b) { \
37
a.swap_with(b); \
38
} \
39
IMP_REQUIRE_SEMICOLON_NAMESPACE
40
41
42
#define IMP_SWAP_3(Name) \
43
template <class A, class B, class C> \
44
inline void swap(Name<A,B,C> &a, Name<A,B,C> &b) { \
45
a.swap_with(b); \
46
} \
47
IMP_REQUIRE_SEMICOLON_NAMESPACE
48
49
/** @} */
50
#else
51
#define IMP_SWAP(Name)
52
53
#define IMP_SWAP_1(Name)
54
55
#define IMP_SWAP_2(Name)
56
57
#define IMP_SWAP_3(Name)
58
#endif
59
60
61
//! Swap two member variables assuming the other object is called o
62
/** Swap the member \c var_name of the two objects (this and o).
63
*/
64
#define IMP_SWAP_MEMBER(var_name) \
65
swap(var_name, o.var_name)
66
67
68
#endif
/* IMPBASE_SWAP_MACROS_H */