Fast DDS
Version 3.6.1.0
Fast DDS
Toggle main menu visibility
Loading...
Searching...
No Matches
type_traits.hpp
1
// Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#ifndef FASTDDS_DDS_XTYPES_DYNAMIC_TYPES_DETAIL__TYPE_TRAITS_HPP
16
#define FASTDDS_DDS_XTYPES_DYNAMIC_TYPES_DETAIL__TYPE_TRAITS_HPP
17
18
#include <memory>
19
20
#include <fastdds/fastdds_dll.hpp>
21
22
namespace
eprosima
{
23
namespace
fastdds
{
24
namespace
dds
{
25
26
template
<
typename
T>
27
struct
traits
28
{
29
using
ref_type
= typename ::std::shared_ptr<T>;
30
using
weak_ref_type
= typename ::std::weak_ptr<T>;
31
32
template
<
typename
_Tp,
typename
=
typename
33
std::enable_if<std::is_base_of<T, _Tp>::value>::type>
34
inline
static
std::shared_ptr<_Tp>
narrow
(
35
ref_type
obj)
36
{
37
return
std::dynamic_pointer_cast<_Tp>(obj);
38
}
39
40
FASTDDS_EXPORTED_API
static
std::shared_ptr<T>
make_shared
();
41
42
};
43
44
template
<
typename
T>
45
struct
object_traits
46
{
47
using
ref_type
= typename ::std::shared_ptr<T>;
48
using
weak_ref_type
= typename ::std::weak_ptr<T>;
49
50
template
<
typename
_Tp,
typename
=
typename
51
std::enable_if<std::is_base_of<T, _Tp>::value>::type>
52
inline
static
std::shared_ptr<_Tp>
narrow
(
53
ref_type
obj)
54
{
55
return
std::dynamic_pointer_cast<_Tp>(obj);
56
}
57
58
};
59
60
}
// namespace dds
61
}
// namespace fastdds
62
}
// namespace eprosima
63
64
#endif
// FASTDDS_DDS_XTYPES_DYNAMIC_TYPES_DETAIL__TYPE_TRAITS_HPP
65
eprosima::fastdds::dds
Definition
BuiltinTopicKey.hpp:26
eprosima::fastdds
eprosima
eProsima namespace.
eprosima::fastdds::dds::object_traits
Definition
type_traits.hpp:46
eprosima::fastdds::dds::object_traits::ref_type
typename ::std::shared_ptr< T > ref_type
Definition
type_traits.hpp:47
eprosima::fastdds::dds::object_traits::weak_ref_type
typename ::std::weak_ptr< T > weak_ref_type
Definition
type_traits.hpp:48
eprosima::fastdds::dds::object_traits::narrow
static std::shared_ptr< _Tp > narrow(ref_type obj)
Definition
type_traits.hpp:52
eprosima::fastdds::dds::traits
Definition
type_traits.hpp:28
eprosima::fastdds::dds::traits::ref_type
typename ::std::shared_ptr< T > ref_type
Definition
type_traits.hpp:29
eprosima::fastdds::dds::traits::weak_ref_type
typename ::std::weak_ptr< T > weak_ref_type
Definition
type_traits.hpp:30
eprosima::fastdds::dds::traits::narrow
static std::shared_ptr< _Tp > narrow(ref_type obj)
Definition
type_traits.hpp:34
eprosima::fastdds::dds::traits::make_shared
static FASTDDS_EXPORTED_API std::shared_ptr< T > make_shared()
include
fastdds
dds
xtypes
dynamic_types
detail
type_traits.hpp
Generated on
for