Coverage Report

Created: 2026-05-04 06:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/Fast-DDS/src/cpp/rtps/persistence/PersistenceFactory.cpp
Line
Count
Source
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 PersistenceFactory.cpp
17
 *
18
 */
19
20
#include <rtps/persistence/PersistenceService.h>
21
22
#if HAVE_SQLITE3
23
#include <rtps/persistence/SQLite3PersistenceService.h>
24
#endif // if HAVE_SQLITE3
25
26
#include <fastdds/rtps/attributes/PropertyPolicy.hpp>
27
#include <fastdds/rtps/history/WriterHistory.hpp>
28
29
namespace eprosima {
30
namespace fastdds {
31
namespace rtps {
32
33
std::vector<CacheChange_t*>& IPersistenceService::get_changes(
34
        WriterHistory* history)
35
0
{
36
0
    return history->m_changes;
37
0
}
38
39
void IPersistenceService::set_fragments(
40
        WriterHistory* history,
41
        CacheChange_t* change)
42
0
{
43
0
    history->set_fragments(change);
44
0
}
45
46
IPersistenceService* PersistenceFactory::create_persistence_service(
47
        const PropertyPolicy& property_policy)
48
0
{
49
0
    IPersistenceService* ret_val = nullptr;
50
0
    const std::string* plugin_property = PropertyPolicyHelper::find_property(property_policy, "dds.persistence.plugin");
51
52
0
    if (plugin_property != nullptr)
53
0
    {
54
0
#if HAVE_SQLITE3
55
0
        if (plugin_property->compare("builtin.SQLITE3") == 0)
56
0
        {
57
0
            const std::string* filename_property = PropertyPolicyHelper::find_property(property_policy,
58
0
                            "dds.persistence.sqlite3.filename");
59
#ifdef ANDROID
60
            const char* filename = (filename_property == nullptr) ?
61
                    "/data/local/tmp/persistence.db" : filename_property->c_str();
62
#else
63
0
            const char* filename = (filename_property == nullptr) ?
64
0
                    "persistence.db" : filename_property->c_str();
65
0
#endif // if ANDROID
66
0
            bool update_schema = false;
67
0
            const std::string* update_schema_value = PropertyPolicyHelper::find_property(property_policy,
68
0
                            "dds.persistence.update_schema");
69
0
            if (update_schema_value != nullptr &&
70
0
                    ((update_schema_value->compare("TRUE") == 0) ||
71
0
                    (update_schema_value->compare("true") == 0)))
72
0
            {
73
0
                update_schema = true;
74
0
            }
75
0
            ret_val = create_SQLite3_persistence_service(filename, update_schema);
76
0
        }
77
0
#endif // if HAVE_SQLITE3
78
0
    }
79
80
0
    return ret_val;
81
0
}
82
83
} /* namespace rtps */
84
} /* namespace fastdds */
85
} /* namespace eprosima */