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
detail
ref_traits.hpp
Go to the documentation of this file.
1
#ifndef OMG_DDS_CORE_DETAIL_REF_TRAITS_H_
2
#define OMG_DDS_CORE_DETAIL_REF_TRAITS_H_
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
23
/*
24
* This file is non-normative. The implementation is
25
* provided only as an example.
26
*/
27
#include <boost/shared_ptr.hpp>
28
#include <boost/weak_ptr.hpp>
29
#include <boost/static_assert.hpp>
30
#include <boost/type_traits.hpp>
31
32
#include <
dds/core/types.hpp
>
33
#include <
dds/core/Exception.hpp
>
34
35
template
<
typename
T1,
typename
T2>
36
struct
dds::core::is_base_of
:
public
boost::is_base_of<T1, T2> { };
37
38
template
<
typename
T1,
typename
T2>
39
struct
dds::core::is_same
:
public
boost::is_same<T1, T1> { };
40
41
template
<
typename
T>
42
struct
dds::core::smart_ptr_traits
{
43
typedef
boost::shared_ptr<T>
ref_type
;
44
typedef
boost::weak_ptr<T>
weak_ref_type
;
45
};
46
47
48
template
<
typename
TO,
typename
FROM>
49
TO
dds::core::polymorphic_cast
(FROM& from) {
50
typename
TO::DELEGATE_REF_T dr =
51
boost::dynamic_pointer_cast<
typename
TO::DELEGATE_T>(from.delegate());
52
TO to(dr);
53
54
if
(to ==
dds::core::null
)
55
throw
dds::core::InvalidDowncastError
(
"Attempted invalid downcast."
);
56
return
to;
57
}
58
#endif
/* OMG_DDS_CORE_DETAIL_REF_TRAITS_H_ */
59
Generated on Sat Nov 3 2012 00:02:18 for DDS-PSM-C++ by
1.8.2