home
about
news
download
doc
source
systems
tests
bugs
contact
IMP Reference Guide
2.8.0
The Integrative Modeling Platform
IMP Manual
Reference Guide
Modules
Classes
Examples
include
IMP
version 2.8.0
showable_macros.h
Go to the documentation of this file.
1
/**
2
* \file IMP/showable_macros.h
3
* \brief Various general useful macros for IMP.
4
*
5
* Copyright 2007-2017 IMP Inventors. All rights reserved.
6
*
7
*/
8
9
#ifndef IMPKERNEL_SHOWABLE_MACROS_H
10
#define IMPKERNEL_SHOWABLE_MACROS_H
11
#include <IMP/kernel_config.h>
12
#include "
Showable.h
"
13
#include "
warning_macros.h
"
14
15
#if defined(IMP_DOXYGEN) || defined(SWIG)
16
/** \name Showable
17
Declare the methods needed by an object that can be printed,
18
both from C++ and Python. Each value-type class should have an
19
IMP_SHOWABLE() call internal to it and an IMP_OUTPUT_OPERATOR()
20
call external to it.
21
22
The suffixes are the number of template arguments that the
23
object has (eg _1 means one template argument). _D means
24
one integer template argument.
25
@{
26
*/
27
28
/** This macro declares the method
29
- void show(std::ostream &out) const
30
It also makes it so that the object can be printed
31
in Python.
32
33
The \c ostream and \c sstream headers must be included.
34
35
\see IMP_SHOWABLE_INLINE().
36
37
Do not use with IMP::Object objects as they have their
38
own show mechanism.
39
*/
40
#define IMP_SHOWABLE(Name) void show(std::ostream &out = std::cout) const
41
42
//! Declare the methods needed by an object that can be printed
43
/** This macro declares the method
44
- \c void \c show(std::ostream &out) const
45
It also makes it so that the object can be printed
46
in Python.
47
48
The \c ostream and \c sstream headers must be included.
49
*/
50
#define IMP_SHOWABLE_INLINE(Name, how_to_show) \
51
void show(std::ostream &out = std::cout) const
52
/** @} */
53
54
#else
55
56
#define IMP_SHOWABLE(Name) \
57
IMP_HELPER_MACRO_PUSH_WARNINGS void show(std::ostream &out = \
58
std::cout) const; \
59
operator IMP::Showable() const { \
60
std::ostringstream oss; \
61
show(oss); \
62
return IMP::Showable(oss.str()); \
63
} \
64
IMP_HELPER_MACRO_POP_WARNINGS IMP_REQUIRE_SEMICOLON_CLASS(showable)
65
66
#define IMP_SHOWABLE_INLINE(Name, how_to_show) \
67
IMP_HELPER_MACRO_PUSH_WARNINGS void show(std::ostream &out = \
68
std::cout) const { \
69
how_to_show; \
70
} \
71
operator IMP::Showable() const { \
72
std::ostringstream oss; \
73
show(oss); \
74
return IMP::Showable(oss.str()); \
75
} \
76
IMP_HELPER_MACRO_POP_WARNINGS IMP_REQUIRE_SEMICOLON_CLASS(showable)
77
78
#endif
79
80
/** @} */
81
82
#endif
/* IMPKERNEL_SHOWABLE_MACROS_H */
Showable.h
IO support.
warning_macros.h
Various general useful macros for IMP.