Skip to content

Commit 2ede94a

Browse files
committed
fix: correct incorrect refactor
1 parent bf3a5d6 commit 2ede94a

2 files changed

Lines changed: 12 additions & 14 deletions

File tree

api/dsr_api.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ using namespace std::literals;
3131
///// PUBLIC METHODS
3232
/////////////////////////////////////////////////
3333

34-
DSRGraph::DSRGraph(GraphSettings settings) :
34+
DSRGraph::DSRGraph(GraphSettings settings) :
3535
agent_id(settings.agent_id),
3636
agent_name(std::move(settings.graph_name)),
3737
copy(false),
@@ -163,7 +163,7 @@ std::optional<DSR::Node> DSRGraph::get_node(uint64_t id)
163163

164164
std::tuple<bool, std::optional<IDL::MvregNode>> DSRGraph::insert_node_(CRDTNode &&node)
165165
{
166-
if (deleted.find(node.id()) == deleted.end())
166+
if (!deleted.contains(node.id()))
167167
{
168168
if (auto it = nodes.find(node.id()); it != nodes.end() and not it->second.empty() and it->second.read_reg() == node)
169169
{
@@ -563,7 +563,6 @@ DSRGraph::insert_or_assign_edge_(CRDTEdge &&attrs, uint64_t from, uint64_t to)
563563
//Update
564564
if (node.fano().contains({to, attrs.type()}))
565565
{
566-
std::vector<IDL::MvregEdgeAttr> atts_deltas;
567566
auto iter = nodes.at(from).read_reg().fano().find({attrs.to(), attrs.type()});
568567
auto end = nodes.at(from).read_reg().fano().end();
569568
if (iter != end) {
@@ -1171,15 +1170,13 @@ void DSRGraph::join_delta_edge(IDL::MvregEdge &&mvreg)
11711170
std::optional<Edge> deleted_edge;
11721171
{
11731172
auto crdt_delta = IDLEdge_to_CRDT(std::move(mvreg));
1173+
deleted_edge = get_edge_(from, to, type);
11741174
std::unique_lock<std::shared_mutex> lock(_mutex);
11751175
//Check if the node where we are joining the edge exist.
11761176
bool cfrom{nodes.contains(from)}, cto{nodes.contains(to)};
11771177
bool dfrom{deleted.contains(from)}, dto{deleted.contains(to)};
11781178
if (cfrom and cto) {
11791179
joined = true;
1180-
if (!crdt_delta.empty()) {
1181-
deleted_edge = crdt_delta.read_reg();
1182-
}
11831180
signal = process_delta_edge(from, to, type, std::move(crdt_delta));
11841181
if (signal) {
11851182
consume_unprocessed_deltas();
@@ -1566,13 +1563,13 @@ void print_sample_info(const eprosima::fastdds::dds::SampleInfo& info) {
15661563

15671564
double now = static_cast<double>(secs_t.count()) * 1000.0 ;
15681565
now += static_cast<double>(duration_cast<std::chrono::nanoseconds>(t_since_epoch).count()) / 1000000.0;
1569-
1566+
15701567
std::ostringstream oss;
15711568
oss << "SampleInfo:" << std::endl;
1572-
oss << " ms diff reception: " << (milliseconds_recv - milliseconds_send) << "ms" << std::endl;
1573-
oss << " ms taken from dds: " << (now - milliseconds_send) << "ms" << std::endl;
1569+
oss << " ms diff reception: " << (milliseconds_recv - milliseconds_send) << "ms" << std::endl;
1570+
oss << " ms taken from dds: " << (now - milliseconds_send) << "ms" << std::endl;
15741571
oss << " Valid Data: " << (info.valid_data ? "true" : "false") << std::endl;
1575-
std::cout << oss.str();
1572+
std::cout << oss.str();
15761573
}
15771574

15781575

@@ -1744,7 +1741,7 @@ void DSRGraph::node_attrs_subscription_thread()
17441741
}
17451742
std::vector<std::future<std::optional<std::string>>> futures;
17461743
for (auto &&s: samples.vec()) {
1747-
if (ignored_attributes.contains(s.attr_name())) {
1744+
if (!ignored_attributes.contains(s.attr_name())) {
17481745
futures.emplace_back(tp.spawn_task_waitable([this, samp{std::move(s)}]() mutable {
17491746
auto f = join_delta_node_attr(std::move(samp));
17501747
return f;
@@ -1839,7 +1836,7 @@ std::pair<bool, bool> DSRGraph::fullgraph_request_thread()
18391836
{
18401837
bool sync = false;
18411838
bool repeated = false;
1842-
auto lambda_request_answer = [&](eprosima::fastdds::dds::DataReader *reader, const DSR::DSRGraph *graph)
1839+
auto lambda_request_answer = [&](eprosima::fastdds::dds::DataReader *reader, DSR::DSRGraph *graph)
18431840
{
18441841
while (true)
18451842
{

api/include/dsr/api/dsr_api.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "dsr/core/rtps/dsrparticipant.h"
2020
#include "dsr/core/rtps/dsrpublisher.h"
2121
#include "dsr/core/rtps/dsrsubscriber.h"
22-
#include "dsr/core/topics/IDLGraph.hpp"
2322
#include "dsr/core/types/crdt_types.h"
2423
#include "dsr/core/types/user_types.h"
2524
#include "dsr/core/types/translator.h"
@@ -31,6 +30,8 @@
3130
#include "dsr/api/dsr_utils.h"
3231
#include "dsr/api/dsr_signal_info.h"
3332
#include "dsr/api/dsr_graph_settings.h"
33+
#include "dsr/core/types/type_checking/dsr_edge_type.h"
34+
#include "dsr/core/types/type_checking/dsr_node_type.h"
3435
#include "dsr/core/types/type_checking/dsr_attr_name.h"
3536
#include "dsr/core/utils.h"
3637
#include "dsr/core/id_generator.h"
@@ -699,9 +700,9 @@ namespace DSR
699700

700701
void del_edge_signal(uint64_t from, uint64_t to, const std::string &edge_tag, DSR::SignalInfo info = {});
701702
void deleted_edge_signal(const DSR::Edge & edge, DSR::SignalInfo info = {});
703+
702704
void del_node_signal(uint64_t id, DSR::SignalInfo info = {}) ;
703705
void deleted_node_signal(const DSR::Node & edge, DSR::SignalInfo info = {});
704-
705706
};
706707
} // namespace CRDT
707708

0 commit comments

Comments
 (0)