Skip to content

Commit

Permalink
Monitoring uses SAttributes instead of config object.
Browse files Browse the repository at this point in the history
  • Loading branch information
Peguen committed Aug 19, 2024
1 parent f80ce01 commit c530be3
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 14 deletions.
1 change: 1 addition & 0 deletions ecal/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ endif()
# common
######################################
set(ecal_cmn_src
src/builder/monitoring_attribute_builder.cpp
src/ecal.cpp
src/ecal_def.h
src/ecal_def_ini.h
Expand Down
37 changes: 37 additions & 0 deletions ecal/core/src/builder/monitoring_attribute_builder.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2024 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ========================= eCAL LICENSE =================================
*/

#include "monitoring_attribute_builder.h"

namespace eCAL
{
namespace Monitoring
{
SAttributes BuildMonitoringAttributes(const Monitoring::Configuration& config_)
{
SAttributes attributes;

attributes.timeout = config_.timeout;
attributes.filter_excl = config_.filter_excl;
attributes.filter_incl = config_.filter_incl;

return attributes;
}
}
}
32 changes: 32 additions & 0 deletions ecal/core/src/builder/monitoring_attribute_builder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2024 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ========================= eCAL LICENSE =================================
*/

#pragma once

#include "monitoring/attributes/monitoring_attributes.h"

#include <ecal/config/monitoring.h>

namespace eCAL
{
namespace Monitoring
{
SAttributes BuildMonitoringAttributes(const Monitoring::Configuration& config_);
}
}
4 changes: 3 additions & 1 deletion ecal/core/src/ecal_globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#include "ecal_globals.h"

#include "builder/monitoring_attribute_builder.h"

#include <iostream>
#include <memory>
#include <stdexcept>
Expand Down Expand Up @@ -174,7 +176,7 @@ namespace eCAL
{
if (monitoring_instance == nullptr)
{
monitoring_instance = std::make_unique<CMonitoring>(eCAL::GetConfiguration().monitoring);
monitoring_instance = std::make_unique<CMonitoring>(Monitoring::BuildMonitoringAttributes(eCAL::GetConfiguration().monitoring));
new_initialization = true;
}
}
Expand Down
36 changes: 36 additions & 0 deletions ecal/core/src/monitoring/attributes/monitoring_attributes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2024 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ========================= eCAL LICENSE =================================
*/

#pragma once

#include <string>

namespace eCAL
{
namespace Monitoring
{
struct SAttributes
{
unsigned int timeout;
std::string filter_excl;
std::string filter_incl;
};

}
}
4 changes: 2 additions & 2 deletions ecal/core/src/monitoring/ecal_monitoring_def.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

namespace eCAL
{
CMonitoring::CMonitoring(const Monitoring::Configuration& config_)
CMonitoring::CMonitoring(const Monitoring::SAttributes& attr_)
{
m_monitoring_impl = std::make_unique<CMonitoringImpl>(config_);
m_monitoring_impl = std::make_unique<CMonitoringImpl>(attr_);
}

CMonitoring::~CMonitoring()
Expand Down
5 changes: 3 additions & 2 deletions ecal/core/src/monitoring/ecal_monitoring_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
#pragma once

#include <ecal/types/monitoring.h>
#include <ecal/config/monitoring.h>

#include "attributes/monitoring_attributes.h"

#include <memory>
#include <string>
Expand All @@ -38,7 +39,7 @@ namespace eCAL
class CMonitoring
{
public:
CMonitoring(const Monitoring::Configuration& config_);
CMonitoring(const Monitoring::SAttributes& attr_);
~CMonitoring();

void Start();
Expand Down
12 changes: 6 additions & 6 deletions ecal/core/src/monitoring/ecal_monitoring_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ namespace eCAL
////////////////////////////////////////
// Monitoring Implementation
////////////////////////////////////////
CMonitoringImpl::CMonitoringImpl(const Monitoring::Configuration& config_) :
CMonitoringImpl::CMonitoringImpl(const Monitoring::SAttributes& attr_) :
m_init(false),
m_config (config_)
m_attributes(attr_)
{
}

Expand Down Expand Up @@ -72,12 +72,12 @@ namespace eCAL

void CMonitoringImpl::SetExclFilter(const std::string& filter_)
{
m_config.filter_excl = filter_;
m_attributes.filter_excl = filter_;
}

void CMonitoringImpl::SetInclFilter(const std::string& filter_)
{
m_config.filter_incl = filter_;
m_attributes.filter_incl = filter_;
}

void CMonitoringImpl::SetFilterState(bool state_)
Expand All @@ -87,13 +87,13 @@ namespace eCAL
// create excluding filter list
{
const std::lock_guard<std::mutex> lock(m_topic_filter_excl_mtx);
Tokenize(m_config.filter_excl, m_topic_filter_excl, ",;", true);
Tokenize(m_attributes.filter_excl, m_topic_filter_excl, ",;", true);
}

// create including filter list
{
const std::lock_guard<std::mutex> lock(m_topic_filter_incl_mtx);
Tokenize(m_config.filter_incl, m_topic_filter_incl, ",;", true);
Tokenize(m_attributes.filter_incl, m_topic_filter_incl, ",;", true);
}
}
else
Expand Down
6 changes: 3 additions & 3 deletions ecal/core/src/monitoring/ecal_monitoring_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
#pragma once

#include <ecal/types/monitoring.h>
#include <ecal/config/monitoring.h>

#include "ecal_def.h"
#include "attributes/monitoring_attributes.h"

#include "serialization/ecal_serialize_sample_registration.h"

Expand All @@ -48,7 +48,7 @@ namespace eCAL
class CMonitoringImpl
{
public:
CMonitoringImpl(const Monitoring::Configuration& config_);
CMonitoringImpl(const Monitoring::SAttributes& attr_);
~CMonitoringImpl() = default;

void Create();
Expand Down Expand Up @@ -151,7 +151,7 @@ namespace eCAL

bool m_init;

Monitoring::Configuration m_config;
Monitoring::SAttributes m_attributes;

std::mutex m_topic_filter_excl_mtx;
StrICaseSetT m_topic_filter_excl;
Expand Down

0 comments on commit c530be3

Please sign in to comment.