Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Changed return types of monitoring api to booleans #1859

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions ecal/core/include/ecal/ecal_monitoring.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,47 +37,47 @@ namespace eCAL
*
* @param filter_ Topic filter as regular expression.
*
* @return Zero if succeeded.
* @return True if succeeded.
**/
ECAL_API int SetExclFilter(const std::string& filter_);
ECAL_API bool SetExclFilter(const std::string& filter_);

/**
* @brief Set topics filter whitelist regular expression.
*
* @param filter_ Topic filter as regular expression.
*
* @return Zero if succeeded.
* @return True if succeeded.
**/
ECAL_API int SetInclFilter(const std::string& filter_);
ECAL_API bool SetInclFilter(const std::string& filter_);

/**
* @brief Switch topics filter using regular expression on/off.
*
* @param state_ Filter on / off state.
*
* @return Zero if succeeded.
* @return True if succeeded.
**/
ECAL_API int SetFilterState(bool state_);
ECAL_API bool SetFilterState(bool state_);

/**
* @brief Get monitoring subset as serialized protobuf string.
*
* @param [out] mon_ Target string to store the monitoring information.
* @param entities_ Entities to get.
*
* @return Monitoring buffer length or zero if failed.
* @return True if succeeded.
**/
ECAL_API int GetMonitoring(std::string& mon_, unsigned int entities_ = Entity::All);
ECAL_API bool GetMonitoring(std::string& mon_, unsigned int entities_ = Entity::All);

/**
* @brief Get monitoring as a struct.
*
* @param [out] mon_ Target struct to store the monitoring information.
* @param entities_ Entities definition.
*
* @return Number of struct elements.
* @return True if succeeded.
**/
ECAL_API int GetMonitoring(SMonitoring& mon_, unsigned int entities_ = Entity::All);
ECAL_API bool GetMonitoring(SMonitoring& mon_, unsigned int entities_ = Entity::All);
}
/** @example monitoring_rec.cpp
* This is an example how the eCAL Monitoring API may be utilized to print monitoring information.
Expand Down
48 changes: 32 additions & 16 deletions ecal/core/src/monitoring/ecal_monitoring_def.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,39 +79,55 @@ namespace eCAL
////////////////////////////////////////////////////////
// static library interface
////////////////////////////////////////////////////////
int SetExclFilter(const std::string& filter_)
bool SetExclFilter(const std::string& filter_)
{
if (g_monitoring() != nullptr) g_monitoring()->SetExclFilter(filter_);
return(0);
if (g_monitoring() != nullptr)
{
g_monitoring()->SetExclFilter(filter_);
return true;
}
return false;
}

int SetInclFilter(const std::string& filter_)
bool SetInclFilter(const std::string& filter_)
{
if (g_monitoring() != nullptr) g_monitoring()->SetInclFilter(filter_);
return(0);
if (g_monitoring() != nullptr)
{
g_monitoring()->SetInclFilter(filter_);
return true;
}
return false;
}

int SetFilterState(const bool state_)
bool SetFilterState(const bool state_)
{
if (g_monitoring() != nullptr) g_monitoring()->SetFilterState(state_);
return(0);
if (g_monitoring() != nullptr)
{
g_monitoring()->SetFilterState(state_);
return true;
}
return false;
}

int GetMonitoring(std::string& mon_, unsigned int entities_)
bool GetMonitoring(std::string& mon_, unsigned int entities_)
{
mon_.clear();
if (g_monitoring() != nullptr) g_monitoring()->GetMonitoring(mon_, entities_);
return((int)mon_.size());
if (g_monitoring() != nullptr)
{
mon_.clear();
g_monitoring()->GetMonitoring(mon_, entities_);
return true;
}
return false;
}

int GetMonitoring(SMonitoring& mon_, unsigned int entities_)
bool GetMonitoring(SMonitoring& mon_, unsigned int entities_)
{
if (g_monitoring() != nullptr)
{
g_monitoring()->GetMonitoring(mon_, entities_);
return(static_cast<int>(mon_.processes.size() + mon_.publisher.size() + mon_.subscriber.size() + mon_.server.size() + mon_.clients.size()));
return true;
}
return(0);
return false;
}
}
}
13 changes: 3 additions & 10 deletions lang/python/core/src/ecal_wrap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ PyObject* mon_setexclfilter(PyObject* /*self*/, PyObject* args)
if (!PyArg_ParseTuple(args, "s", &filter))
return nullptr;

return(Py_BuildValue("i", eCAL::Monitoring::SetExclFilter(filter)));
return(Py_BuildValue("i", static_cast<int>(!eCAL::Monitoring::SetExclFilter(filter))));
}

/****************************************/
Expand All @@ -964,7 +964,7 @@ PyObject* mon_setinclfilter(PyObject* /*self*/, PyObject* args)
if (!PyArg_ParseTuple(args, "s", &filter))
return nullptr;

return(Py_BuildValue("i", eCAL::Monitoring::SetInclFilter(filter)));
return(Py_BuildValue("i", static_cast<int>(!eCAL::Monitoring::SetInclFilter(filter))));
}

/****************************************/
Expand All @@ -977,14 +977,7 @@ PyObject* mon_setfilterstate(PyObject* /*self*/, PyObject* args)
if (!PyArg_ParseTuple(args, "i", &state))
return nullptr;

if (state != 0)
{
return(Py_BuildValue("i", eCAL::Monitoring::SetFilterState(true)));
}
else
{
return(Py_BuildValue("i", eCAL::Monitoring::SetFilterState(false)));
}
return(Py_BuildValue("i", static_cast<int>(!eCAL::Monitoring::SetFilterState(state != 0))));
}

/****************************************/
Expand Down
Loading