Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define CONTROL_CLIENT_CHANNEL_HPP_INCLUDED

#include <atomic>
#include <string_view>
#include <score/lcm/internal/process_group_state_id.hpp>
#include <score/lcm/internal/osal/osalipccomms.hpp>
#include <condition_variable>
Expand Down Expand Up @@ -247,7 +248,7 @@ class ControlClientChannel final {
/// @brief A utility function that converts codes to strings for logging purposes
/// @param code The code to convert
/// @return A string representing the code
const char* toString(ControlClientCode code);
std::string_view toString(ControlClientCode code);

private:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ ControlClientChannelP ControlClientChannel::initializeControlClientChannel(int f

if (MAP_FAILED == channelMemory)
{
LM_LOG_ERROR() << "mmap failed in initializeControlClientChannel:" << std::strerror(errno);
LM_LOG_ERROR() << "mmap failed in initializeControlClientChannel:" << std::string_view{std::strerror(errno)};
return nullptr;
}

Expand Down Expand Up @@ -239,7 +239,7 @@ void ControlClientChannel::releaseParentMapping()
ipc_parent_.reset();
}

const char* ControlClientChannel::toString(ControlClientCode code)
std::string_view ControlClientChannel::toString(ControlClientCode code)
{
for (const auto& mapping : stateArray)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ bool FlatCfgFactory::createProcessStates(std::vector<ifexm::ProcessState>& f_pro
{
isSuccess = false;
logger_r.LogError() << kLogPrefix
<< "Could not create Process States due to exception:" << f_exception_r.what();
<< "Could not create Process States due to exception:" << std::string_view{f_exception_r.what()};
}
}
else
Expand Down Expand Up @@ -272,7 +272,7 @@ bool FlatCfgFactory::createMonitorIfIpcs(std::vector<ifappl::CheckpointIpcServer
{
isSuccess = false;
logger_r.LogError() << kLogPrefix << "Could not create Monitor interface IPC due to exception:"
<< f_exception_r.what();
<< std::string_view{f_exception_r.what()};
}
}
else
Expand Down Expand Up @@ -332,7 +332,7 @@ bool FlatCfgFactory::createMonitorIf(std::vector<ifappl::MonitorIfDaemon>& f_int
f_interfaces_r.clear();
logger_r.LogError() << kLogPrefix
<< "Could not create all necessary Monitor interfaces due to exception:"
<< f_exception_r.what();
<< std::string_view{f_exception_r.what()};
}

return isSuccess;
Expand Down Expand Up @@ -375,7 +375,7 @@ bool FlatCfgFactory::createSupervisionCheckpoints(std::vector<ifappl::Checkpoint
{
isSuccess = false;
logger_r.LogError() << kLogPrefix << "Could not create supervision worker objects, due to exception:"
<< f_exception_r.what();
<< std::string_view{f_exception_r.what()};
}
}
else
Expand Down Expand Up @@ -477,7 +477,7 @@ bool FlatCfgFactory::createAliveSupervisions(std::vector<supervision::Alive>& f_
logger_r.LogError() << kLogPrefix
<< "Could not create all necessary alive supervision "
"worker objects, due to exception:"
<< f_exception_r.what();
<< std::string_view{f_exception_r.what()};
}
}

Expand Down Expand Up @@ -541,7 +541,7 @@ bool FlatCfgFactory::createLocalSupervisions(std::vector<supervision::Local>& f_
{
isSuccess = false;
logger_r.LogError() << kLogPrefix << "Could not create local supervision worker objects, due to exception:"
<< f_exception_r.what();
<< std::string_view{f_exception_r.what()};
}
}
else
Expand Down Expand Up @@ -649,7 +649,7 @@ bool FlatCfgFactory::createGlobalSupervisions(std::vector<supervision::Global>&
{
isGlobalSupCfgSuccess = false;
logger_r.LogError() << kLogPrefix << "Could not create all necessary global supervision due to exception:"
<< f_exception_r.what();
<< std::string_view{f_exception_r.what()};
}
}
else
Expand Down Expand Up @@ -702,7 +702,7 @@ bool FlatCfgFactory::createRecoveryNotifications(std::shared_ptr<score::lcm::IRe
logger_r.LogError() << kLogPrefix
<< "Could not create all necessary recovery notifications "
"due to exception:"
<< f_exception_r.what();
<< std::string_view{f_exception_r.what()};
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "score/lcm/saf/factory/MachineConfigFactory.hpp"

#include <limits>
#include <string_view>
#include <fstream>
#include "score/lcm/saf/timers/TimeConversion.hpp"
#include "hmcore_flatcfg_generated.h"
Expand Down Expand Up @@ -191,8 +192,8 @@ void MachineConfigFactory::logConfiguration() noexcept(true)
std::uint32_t wdgCount{1U};
for (const auto& wdgConfig : watchdogConfigs)
{
const char* const wdgMagicCloseBool{wdgConfig.needsMagicClose ? "true" : "false"};
const char* const wdgDeactivatedBool{wdgConfig.canBeDeactivated ? "true" : "false"};
const std::string_view wdgMagicCloseBool{wdgConfig.needsMagicClose ? "true" : "false"};
const std::string_view wdgDeactivatedBool{wdgConfig.canBeDeactivated ? "true" : "false"};
logger_r.LogDebug() << kLogPrefix << "Watchdog" << wdgCount << "- device file:" << wdgConfig.fileName;
logger_r.LogDebug() << kLogPrefix << "Watchdog" << wdgCount << "- max timeout:" << wdgConfig.timeoutMax << "ms";
logger_r.LogDebug() << kLogPrefix << "Watchdog" << wdgCount << "- needs magic close:" << wdgMagicCloseBool;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ bool Checkpoint::getDataLossEvent(void) const noexcept(true)
return isDataLossEvent;
}

const char* Checkpoint::getConfigName(void) const noexcept(true)
std::string_view Checkpoint::getConfigName(void) const noexcept(true)
{
return k_configName.c_str();
return k_configName;
}

const ifexm::ProcessState* Checkpoint::getProcess(void) const noexcept(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#define CHECKPOINT_HPP_INCLUDED

#include <string>
#include <string_view>

#include <cstdint>

Expand Down Expand Up @@ -93,7 +94,7 @@ class Checkpoint : public saf::common::Observable<Checkpoint>

/// @brief Get the configuration name of the corresponding SupervisionCheckpoint
/// @return Name of the corresponding SupervisionCheckpoint (configuration element)
const char* getConfigName(void) const noexcept(true);
std::string_view getConfigName(void) const noexcept(true);

/// @brief Return the process that is reporting this checkpoint
/// @return process state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "score/lcm/saf/supervision/Alive.hpp"

#include <cassert>
#include <string_view>

#include "score/lcm/saf/common/Types.hpp"
#include "score/lcm/saf/ifexm/ProcessState.hpp"
Expand Down Expand Up @@ -546,7 +547,7 @@ bool Alive::isMaxError(void) const noexcept(true)

void Alive::logExpiredFailedStateDetails() const noexcept(true)
{
const char* failedState{""};
std::string_view failedState{""};
if (aliveStatus == Alive::EStatus::failed)
{
// failedSupervisionCycles == 1 if just switched to FAILED and > 1 if were already in FAILED before
Expand All @@ -559,11 +560,10 @@ void Alive::logExpiredFailedStateDetails() const noexcept(true)

const bool minError{isMinError()};
/* RULECHECKER_comment(0, 4, check_conditional_as_sub_expression, "Ternary operation is very simple", true_no_defect) */
const char* indication{((indicationCount != 1U) ? "indications" : "indication")};
const std::uint64_t aliveIndicationMargin{minError ? k_minAliveIndications : k_maxAliveIndications};
const char* expectedComparison{minError ? ">=" : "<="};
const std::string_view expectedComparison{minError ? ">=" : "<="};
logger_r.LogWarn() << "Alive Supervision (" << getConfigName() << ")" << failedState << ", due to"
<< indicationCount << "reported alive" << indication << "(expected" << expectedComparison
<< indicationCount << "reported alive indication(s) (expected" << expectedComparison
<< aliveIndicationMargin << "). Failed supervision cycles:" << failedSupervisionCycles << "/"
<< k_failedSupervisionCyclesTolerance;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ ISupervision::ISupervision(const char* const f_supervisionConfigName_p) : k_cfgN
static_cast<void>(0);
}

const char* ISupervision::getConfigName(void) const
std::string_view ISupervision::getConfigName(void) const noexcept
{
return static_cast<const char*>(k_cfgName.c_str());
return k_cfgName;
}

} // namespace supervision
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <cstdint>

#include <string>
#include <string_view>
#include <vector>
#include "score/lcm/saf/timers/Timers_OsClock.hpp"

Expand Down Expand Up @@ -56,9 +57,8 @@ class ISupervision
virtual void evaluate(const timers::NanoSecondType f_syncTimestamp) = 0;

/// @brief Get the name of the configuration element for the corresponding supervision container
/// @return std::string Constant string containing the name of the
/// corresponding supervision configuration container
const char* getConfigName(void) const;
/// @return std::string_view View over the name of the corresponding supervision configuration container
std::string_view getConfigName(void) const noexcept;

protected:
/// @brief Default Move Constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "score/lcm/saf/supervision/Local.hpp"

#include <cassert>
#include <string_view>

#include "score/lcm/saf/logging/PhmLogger.hpp"
#include "score/lcm/saf/timers/Timers_OsClock.hpp"
Expand Down Expand Up @@ -282,7 +283,7 @@ void Local::switchToOk(ICheckpointSupervision::EType f_type) noexcept
pushResultToObservers();
}

void Local::switchToFailed(ICheckpointSupervision::EType f_type, const char* reason_p) noexcept
void Local::switchToFailed(ICheckpointSupervision::EType f_type, std::string_view reason_p) noexcept
{
supervisionType = f_type;
logger_r.LogWarn() << "Local Supervision (" << getConfigName() << ") switched to FAILED," << reason_p;
Expand All @@ -291,11 +292,11 @@ void Local::switchToFailed(ICheckpointSupervision::EType f_type, const char* rea
}

void Local::switchToExpired(ICheckpointSupervision::EType f_type,
ifexm::ProcessCfg::ProcessExecutionError f_executionError, const char* reason_p) noexcept
ifexm::ProcessCfg::ProcessExecutionError f_executionError, std::string_view reason_p) noexcept
{
supervisionType = f_type;
processExecutionError = f_executionError;
if (nullptr == reason_p)
if (reason_p.empty())
{
if (ICheckpointSupervision::EType::aliveSupervision == f_type)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#endif

#include <map>
#include <string_view>

#include <cstdint>

Expand Down Expand Up @@ -174,7 +175,7 @@ class Local : public ISupervision,
/// @brief Switch to state Failed
/// @param [in] f_type Type of Supervision
/// @param [in] reason_p Reason for switch to Failed
void switchToFailed(const ICheckpointSupervision::EType f_type, const char* reason_p) noexcept;
void switchToFailed(const ICheckpointSupervision::EType f_type, std::string_view reason_p) noexcept;

/// @brief Switch to state Expired
/// @details In case reason_p was given f_type will be ignored.
Expand All @@ -183,7 +184,7 @@ class Local : public ISupervision,
/// @param [in] reason_p [Optional] Other reason for switch to Expired
void switchToExpired(ICheckpointSupervision::EType f_type,
ifexm::ProcessCfg::ProcessExecutionError f_executionError,
const char* reason_p = nullptr) noexcept;
std::string_view reason_p = {}) noexcept;

/// @brief Check if ALL attached Supervisions are in status Deactivated
bool isAllDeactivated() const noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ bool ConfigurationManager::parseMachineConfigurations(const ModeGroup* node, con
ProcessGroup process_group_data;
process_group_data.name_ = getStringViewFromFlatBuffer(node->identifier());
process_group_data.sw_cluster_ = cluster;
LM_LOG_DEBUG() << "FlatBufferParser::getModeGroupPgName:" << getStringFromFlatBuffer(node->identifier())
LM_LOG_DEBUG() << "FlatBufferParser::getModeGroupPgName:" << std::string_view{getStringFromFlatBuffer(node->identifier())}
<< "( IdentifierHash:" << process_group_data.name_.data() << ")";

if (process_group_data.name_ != score::lcm::IdentifierHash(std::string_view(""))) {
Expand Down Expand Up @@ -338,7 +338,7 @@ bool ConfigurationManager::parseModeGroups(const ModeGroup* node, ProcessGroup&
std::string string_name(flatbuffer_string->c_str(), flatbuffer_string->size());
pg_state.name_ = getStringViewFromFlatBuffer(flatbuffer_string);
LM_LOG_DEBUG() << "FlatBufferParser::getModeGroupPgStateName:"
<< mode_declaration_node->identifier()->c_str()
<< std::string_view{flatbuffer_string->c_str(), flatbuffer_string->size()}
<< "( IdentifierHash:" << pg_state.name_.data() << ")";
process_group_data.states_.push_back(pg_state);
// Is this the "Off" state, i.e. does it end with "/Off" ?
Expand Down Expand Up @@ -395,7 +395,7 @@ static void setSchedulingParameters(const Process& node, const ProcessStartupCon
} else if (strcasecmp("SCHED_OTHER", attribute->c_str()) == 0) {
instance.startup_config_.scheduling_policy_ = SCHED_OTHER;
} else {
LM_LOG_WARN() << "scheduling policy" << attribute->c_str() << "is not supported, using default";
LM_LOG_WARN() << "scheduling policy" << std::string_view{attribute->c_str(), attribute->size()} << "is not supported, using default";
}
}
attribute = config.schedulingPriority();
Expand Down Expand Up @@ -617,7 +617,7 @@ void ConfigurationManager::parseExecutionDependency(
dep.process_state_ = getProcessState(state_name);
dep.target_process_id_ = getStringViewFromFlatBuffer(process_dependency_node->targetProcess_identifier());
LM_LOG_DEBUG() << "ParseProcessExecutionDependency: target process path:"
<< getStringFromFlatBuffer(process_dependency_node->targetProcess_identifier())
<< std::string_view{getStringFromFlatBuffer(process_dependency_node->targetProcess_identifier())}
<< "ID:" << dep.target_process_id_;
process_instance.dependencies_.push_back(dep);

Expand Down Expand Up @@ -761,7 +761,7 @@ bool ConfigurationManager::checkOrSetFlatConfigEnvVar(const std::string& name, c
const char* value = getenv(name.c_str());

if (value && strlen(value)) {
LM_LOG_DEBUG() << name.c_str() << "already set. Current value:" << value;
LM_LOG_DEBUG() << name << "already set. Current value:" << std::string_view{value};
result = true;
} else {
if (setenv(name.c_str(), path.c_str(), overwrite_) == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ ControlClientMessage& Graph::getCancelMessage() {
return cancel_message_;
}

const char* Graph::toString(GraphState state) {
std::string_view Graph::toString(GraphState state) {
switch (state) {
case GraphState::kAborting:
return "kAborting";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <memory>
#include <atomic>
#include <mutex>
#include <string_view>
#include <vector>

#include <score/lcm/identifier_hash.hpp>
Expand Down Expand Up @@ -302,7 +303,7 @@ class Graph final {
/// @brief A utility function that converts codes to strings for logging purposes
/// @param state The state to convert
/// @return A string representing the state
static const char* toString(GraphState state);
static std::string_view toString(GraphState state);

/// @brief Sets the state transition request start time
void setRequestStartTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ void ProcessInfoNode::startProcess() {

if (osal::CommsType::kLaunchManager == config_->startup_config_.comms_type_) {
// Don't start launch manager, we're already running
LM_LOG_DEBUG() << "Found myself (" << config_->startup_config_.argv_[0U]
LM_LOG_DEBUG() << "Found myself (" << std::string_view{config_->startup_config_.argv_[0U]}
<< ") in a process group to start, not starting, reporting kRunning";
pid_ = getpid();
static_cast<void>(setState(score::lcm::ProcessState::kRunning)); // Cannot fail by design
Expand Down Expand Up @@ -393,7 +393,7 @@ void ProcessInfoNode::terminateProcess() {

if (setState(score::lcm::ProcessState::kTerminating)) {
if (osal::CommsType::kLaunchManager == config_->startup_config_.comms_type_) {
LM_LOG_DEBUG() << "Found myself (" << config_->startup_config_.argv_[0U]
LM_LOG_DEBUG() << "Found myself (" << std::string_view{config_->startup_config_.argv_[0U]}
<< ") in a process group to terminate, not terminating, reporting kTerminated";
static_cast<void>(setState(score::lcm::ProcessState::kTerminated)); // Cannot fail by design
} else {
Expand Down
Loading
Loading