Coverage Report

Created: 2025-07-03 06:58

/src/Fast-DDS/src/cpp/fastdds/topic/TopicProxyFactory.cpp
Line
Count
Source (jump to first uncovered line)
1
// Copyright 2022 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
/*
16
 * TopicProxyFactory.cpp
17
 */
18
19
#include <fastdds/topic/TopicProxyFactory.hpp>
20
21
#include <algorithm>
22
23
#include <fastdds/topic/TopicProxy.hpp>
24
25
namespace eprosima {
26
namespace fastdds {
27
namespace dds {
28
29
TopicProxy* TopicProxyFactory::create_topic()
30
0
{
31
0
    TopicProxy* ret_val = new TopicProxy(topic_name_, type_name_, status_mask_, &topic_impl_);
32
0
    proxies_.emplace_back(ret_val);
33
0
    return ret_val;
34
0
}
35
36
ReturnCode_t TopicProxyFactory::delete_topic(
37
        TopicProxy* proxy)
38
0
{
39
0
    auto it = std::find_if(proxies_.begin(), proxies_.end(), [proxy](const std::unique_ptr<TopicProxy>& item)
40
0
                    {
41
0
                        return item.get() == proxy;
42
0
                    });
43
0
    if (it != proxies_.end() && !proxy->is_referenced())
44
0
    {
45
0
        proxies_.erase(it);
46
0
        return RETCODE_OK;
47
0
    }
48
49
0
    return RETCODE_PRECONDITION_NOT_MET;
50
0
}
51
52
TopicProxy* TopicProxyFactory::get_topic()
53
0
{
54
0
    return proxies_.empty() ? nullptr : proxies_.front().get();
55
0
}
56
57
bool TopicProxyFactory::can_be_deleted()
58
0
{
59
0
    return proxies_.empty();
60
0
}
61
62
void TopicProxyFactory::enable_topic()
63
0
{
64
0
    for (auto& item : proxies_)
65
0
    {
66
0
        item->get_topic()->enable();
67
0
    }
68
0
}
69
70
}  // namespace dds
71
}  // namespace fastdds
72
}  // namespace eprosima