Coverage Report

Created: 2022-08-24 06:19

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