DDS-PSM-C++
1.0
ISO C++ API for OpenSplice DDS
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
src
hpp
dds
core
refmacros.hpp
Go to the documentation of this file.
1
#ifndef OMG_DDS_CORE_REFMACROS_HPP_
2
#define OMG_DDS_CORE_REFMACROS_HPP_
3
4
/* Copyright 2010, Object Management Group, Inc.
5
* Copyright 2010, PrismTech, Corp.
6
* Copyright 2010, Real-Time Innovations, Inc.
7
* All rights reserved.
8
*
9
* Licensed under the Apache License, Version 2.0 (the "License");
10
* you may not use this file except in compliance with the License.
11
* You may obtain a copy of the License at
12
*
13
* http://www.apache.org/licenses/LICENSE-2.0
14
*
15
* Unless required by applicable law or agreed to in writing, software
16
* distributed under the License is distributed on an "AS IS" BASIS,
17
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
* See the License for the specific language governing permissions and
19
* limitations under the License.
20
*/
21
22
#include <
dds/core/macros.hpp
>
23
#include <
dds/core/ref_traits.hpp
>
24
26
// Macros
28
29
#define DECLARE_TYPE_TRAITS(TYPE) \
30
typedef TYPE TYPE##_T;\
31
typedef typename ::dds::core::smart_ptr_traits<TYPE>::ref_type TYPE##_REF_T;\
32
typedef typename ::dds::core::smart_ptr_traits<TYPE>::weak_ref_type TYPE##_WEAK_REF_T;
33
34
35
/*
36
* This macro defines all the methods that Reference Types have to implement
37
*/
38
/*
39
*
40
*
41
*/
43
// Defines all the types, methods and attributes required for a Reference type
44
// without default ctor.
45
//
46
/*
47
#define OMG_DDS_REF_TYPE_BASE(TYPE, BASE, DELEGATE) \
48
public: \
49
typedef BASE< DELEGATE > BASE_T;\
50
protected:\
51
explicit TYPE(DELEGATE_T* p)\
52
: BASE< DELEGATE_T >(p) \
53
{ }\
54
public:\
55
explicit TYPE(const DELEGATE_REF_T& ref) \
56
: BASE<DELEGATE_T>(ref)\
57
{ }\
58
\
59
template <typename H__> \
60
TYPE(const H__& h) \
61
: BASE< DELEGATE_T >(h) \
62
{ \
63
OMG_DDS_STATIC_ASSERT((::dds::core::is_base_of<typename TYPE::DELEGATE_T, typename H__::DELEGATE_T>::value)); \
64
this->::dds::core::Reference<DELEGATE>::impl_ = h.delegate(); \
65
}
66
*/
67
68
#define OMG_DDS_REF_TYPE_BASE(TYPE, BASE, DELEGATE) \
69
public: \
70
typedef BASE< DELEGATE > BASE_T;\
71
protected:\
72
explicit TYPE(DELEGATE_T* p)\
73
: BASE< DELEGATE_T >(p) \
74
{ }\
75
public:\
76
template <typename H__> \
77
TYPE(const H__& h) \
78
: BASE< DELEGATE_T >(h) \
79
{ \
80
OMG_DDS_STATIC_ASSERT((::dds::core::is_base_of<typename TYPE::DELEGATE_T, typename H__::DELEGATE_T>::value)); \
81
this->::dds::core::Reference<DELEGATE>::impl_ = h.delegate(); \
82
}
83
84
#define OMG_DDS_REF_TYPE_BASE_T(TYPE, BASE, T_PARAM, DELEGATE) \
85
public: \
86
typedef BASE< T_PARAM, DELEGATE > BASE_T; \
87
protected: \
88
explicit TYPE(DELEGATE_T* p) \
89
: BASE< T_PARAM, DELEGATE >(p) \
90
{ } \
91
public: \
92
template <typename H__> \
93
TYPE(const H__& h) \
94
: BASE< T_PARAM, DELEGATE >(h) \
95
{ \
96
OMG_DDS_STATIC_ASSERT((::dds::core::is_base_of<typename TYPE::DELEGATE_T, typename H__::DELEGATE_T>::value)); \
97
this->::dds::core::Reference< DELEGATE< T_PARAM > >::impl_ = h.delegate(); \
98
}
99
100
101
#define OMG_DDS_REF_TYPE_DELEGATE(TYPE, BASE, DELEGATE) \
102
public: \
103
typedef DELEGATE DELEGATE_T; \
104
typedef typename ::dds::core::smart_ptr_traits< DELEGATE >::ref_type DELEGATE_REF_T; \
105
typedef typename ::dds::core::smart_ptr_traits< DELEGATE >::weak_ref_type DELEGATE_WEAK_REF_T; \
106
\
107
private:\
108
const typename ::dds::core::Reference< DELEGATE >::DELEGATE_REF_T& impl() const \
109
{ return ::dds::core::Reference< DELEGATE >::impl_; }\
110
typename ::dds::core::Reference< DELEGATE >::DELEGATE_REF_T& impl() \
111
{ return ::dds::core::Reference< DELEGATE >::impl_; }\
112
\
113
public:\
114
template <typename T__> \
115
TYPE& \
116
operator=(const T__& rhs) {\
117
OMG_DDS_STATIC_ASSERT((::dds::core::is_base_of<typename TYPE::DELEGATE_T, typename T__::DELEGATE_T>::value));\
118
if (this != (TYPE*)&rhs) \
119
*this = TYPE(rhs); \
120
return *this; \
121
}
122
123
124
#define OMG_DDS_REF_TYPE_DELEGATE_T(TYPE, BASE, T_PARAM, DELEGATE) \
125
public: \
126
typedef DELEGATE< T_PARAM > DELEGATE_T; \
127
typedef typename ::dds::core::smart_ptr_traits< DELEGATE< T_PARAM > >::ref_type \
128
DELEGATE_REF_T; \
129
typedef typename ::dds::core::smart_ptr_traits< DELEGATE< T_PARAM > >::weak_ref_type \
130
DELEGATE_WEAK_REF_T; \
131
\
132
private:\
133
const typename ::dds::core::Reference< DELEGATE< T_PARAM > >::DELEGATE_REF_T& impl() const \
134
{ return ::dds::core::Reference< DELEGATE< T_PARAM > >::impl_; }\
135
typename ::dds::core::Reference< DELEGATE< T_PARAM > >::DELEGATE_REF_T& impl() \
136
{ return ::dds::core::Reference< DELEGATE< T_PARAM > >::impl_; }\
137
\
138
public:\
139
template <typename T__> \
140
TYPE& \
141
operator=(const T__& rhs) {\
142
OMG_DDS_STATIC_ASSERT((::dds::core::is_base_of<typename TYPE::DELEGATE_T, typename T__::DELEGATE_T>::value));\
143
if (this != (TYPE*)&rhs) \
144
*this = TYPE(rhs); \
145
return *this; \
146
}
147
148
149
#define OMG_DDS_REF_TYPE_NODC(TYPE, BASE, DELEGATE) \
150
OMG_DDS_REF_TYPE_DELEGATE(TYPE, BASE, DELEGATE) \
151
OMG_DDS_REF_TYPE_BASE(TYPE, BASE, DELEGATE) \
152
public:
153
154
155
#define OMG_DDS_REF_TYPE_NODC_T(TYPE, BASE, T_PARAM, DELEGATE) \
156
OMG_DDS_REF_TYPE_DELEGATE_T(TYPE, BASE, T_PARAM, DELEGATE) \
157
OMG_DDS_REF_TYPE_BASE_T(TYPE, BASE, T_PARAM, DELEGATE) \
158
public:
159
160
#define DDS_PTR_CTOR_REF_TYPE(TYPE, BASE, DELEGATE) \
161
public: \
162
typedef BASE< DELEGATE > BASE_T;\
163
typedef DELEGATE DELEGATE_T; \
164
typedef typename ::dds::core::smart_ptr_traits< DELEGATE >::ref_type DELEGATE_REF_T; \
165
typedef typename ::dds::core::smart_ptr_traits< DELEGATE >::weak_ref_type DELEGATE_WEAK_REF_T; \
166
\
167
private:\
168
typename ::dds::core::Reference< DELEGATE >::DELEGATE_REF_T& impl() \
169
{ return ::dds::core::Reference< DELEGATE >::impl_; }\
170
public:\
171
explicit TYPE(DELEGATE_T* p)\
172
: BASE< DELEGATE_T >(p) \
173
{ }\
174
template <typename PTR>\
175
explicit TYPE(PTR* ptr) {\
176
OMG_DDS_STATIC_ASSERT((::dds::core::is_base_of<typename TYPE::DELEGATE_T, PTR>::value)); \
177
this->::dds::core::Reference< DELEGATE >::impl_.reset(ptr);\
178
}\
179
public:\
180
explicit TYPE(const DELEGATE_REF_T& ref) \
181
: BASE<DELEGATE_T>(ref)\
182
{ }\
183
\
184
template <typename H__> \
185
explicit TYPE(const H__& h) \
186
: BASE< DELEGATE_T >(h) \
187
{ \
188
OMG_DDS_STATIC_ASSERT((::dds::core::is_base_of<typename TYPE::DELEGATE_T, typename H__::DELEGATE_T>::value)); \
189
this->::dds::core::Reference<DELEGATE>::impl_ = h.delegate();\
190
} \
191
public:\
192
template <typename T__> \
193
TYPE& \
194
operator=(const T__& rhs) {\
195
OMG_DDS_STATIC_ASSERT((::dds::core::is_base_of<typename TYPE::DELEGATE_T, typename T__::DELEGATE_T>::value));\
196
if (this != (TYPE*)&rhs) \
197
*this = TYPE(rhs); \
198
return *this; \
199
} \
200
public:
201
202
204
// Declares a reference type equipped with a default ctor.
205
//
206
#define OMG_DDS_REF_TYPE(TYPE, BASE, DELEGATE) \
207
OMG_DDS_REF_TYPE_NODC(TYPE, BASE, DELEGATE) \
208
private: \
209
TYPE(); \
210
public: \
211
TYPE(const dds::core::null_type&) : BASE< DELEGATE >(static_cast<DELEGATE*>(NULL)) { }
212
213
#define OMG_DDS_REF_TYPE_T(TYPE, BASE, T_PARAM, DELEGATE) \
214
OMG_DDS_REF_TYPE_NODC_T(TYPE, BASE, T_PARAM, DELEGATE) \
215
private: \
216
TYPE(); \
217
public: \
218
TYPE(const dds::core::null_type&) : BASE<T_PARAM, DELEGATE>(static_cast<DELEGATE<T_PARAM>* >(NULL)) { }
219
220
#define OMG_DDS_BASIC_REF_TYPE(TYPE, BASE, DELEGATE) \
221
private: \
222
TYPE(); \
223
public: \
224
TYPE(const dds::core::null_type&) : BASE< DELEGATE >(static_cast<DELEGATE*>(NULL)) { }
225
226
#endif
/* OMG_DDS_CORE_REFMACROS_HPP_ */
Generated on Sat Nov 3 2012 00:02:18 for DDS-PSM-C++ by
1.8.2