Coverage Report

Created: 2025-07-03 06:58

/src/Fast-DDS/src/cpp/rtps/reader/StatefulPersistentReader.cpp
Line
Count
Source (jump to first uncovered line)
1
// Copyright 2018 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
 * @file StatefulPersistentReader.cpp
17
 *
18
 */
19
20
#include <rtps/reader/StatefulPersistentReader.hpp>
21
22
#include <fastdds/rtps/history/ReaderHistory.hpp>
23
24
#include <rtps/persistence/PersistenceService.h>
25
#include <rtps/reader/ReaderHistoryState.hpp>
26
27
namespace eprosima {
28
namespace fastdds {
29
namespace rtps {
30
31
StatefulPersistentReader::StatefulPersistentReader(
32
        RTPSParticipantImpl* impl,
33
        const GUID_t& guid,
34
        const ReaderAttributes& att,
35
        ReaderHistory* hist,
36
        ReaderListener* listen,
37
        IPersistenceService* persistence)
38
0
    : StatefulReader(impl, guid, att, hist, listen)
39
0
    , persistence_(persistence)
40
0
    , persistence_guid_()
41
0
{
42
0
    init(guid, att);
43
0
}
44
45
StatefulPersistentReader::StatefulPersistentReader(
46
        RTPSParticipantImpl* impl,
47
        const GUID_t& guid,
48
        const ReaderAttributes& att,
49
        const std::shared_ptr<IPayloadPool>& payload_pool,
50
        ReaderHistory* hist,
51
        ReaderListener* listen,
52
        IPersistenceService* persistence)
53
0
    : StatefulReader(impl, guid, att, payload_pool, hist, listen)
54
0
    , persistence_(persistence)
55
0
    , persistence_guid_()
56
0
{
57
0
    init(guid, att);
58
0
}
59
60
StatefulPersistentReader::StatefulPersistentReader(
61
        RTPSParticipantImpl* impl,
62
        const GUID_t& guid,
63
        const ReaderAttributes& att,
64
        const std::shared_ptr<IPayloadPool>& payload_pool,
65
        const std::shared_ptr<IChangePool>& change_pool,
66
        ReaderHistory* hist,
67
        ReaderListener* listen,
68
        IPersistenceService* persistence)
69
0
    : StatefulReader(impl, guid, att, payload_pool, change_pool, hist, listen)
70
0
    , persistence_(persistence)
71
0
    , persistence_guid_()
72
0
{
73
0
    init(guid, att);
74
0
}
75
76
void StatefulPersistentReader::init(
77
        const GUID_t& guid,
78
        const ReaderAttributes& att)
79
0
{
80
    // When persistence GUID is unknown, create from rtps GUID
81
0
    GUID_t p_guid = att.endpoint.persistence_guid == c_Guid_Unknown ? guid : att.endpoint.persistence_guid;
82
0
    std::ostringstream ss;
83
0
    ss << p_guid;
84
0
    persistence_guid_ = ss.str();
85
0
    persistence_->load_reader_from_storage(persistence_guid_, history_state_->history_record);
86
0
}
87
88
StatefulPersistentReader::~StatefulPersistentReader()
89
0
{
90
0
    delete persistence_;
91
0
}
92
93
void StatefulPersistentReader::persist_last_notified_nts(
94
        const GUID_t& writer_guid,
95
        const SequenceNumber_t& seq)
96
0
{
97
0
    history_state_->history_record[writer_guid] = seq;
98
0
    persistence_->update_writer_seq_on_storage(persistence_guid_, writer_guid, seq);
99
0
}
100
101
bool StatefulPersistentReader::may_remove_history_record(
102
        bool /* removed_by_lease */)
103
0
{
104
0
    return false;
105
0
}
106
107
} /* namespace rtps */
108
} /* namespace fastdds */
109
} /* namespace eprosima */