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