Skip to content

Commit

Permalink
cleanup(common/engine_conf): new comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bouda1 committed Jul 18, 2024
1 parent 47183ec commit d7968a1
Show file tree
Hide file tree
Showing 21 changed files with 170 additions and 136 deletions.
7 changes: 2 additions & 5 deletions common/engine_conf/anomalydetection_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "com/centreon/exceptions/msg_fmt.hh"

using msg_fmt = com::centreon::exceptions::msg_fmt;
using com::centreon::exceptions::msg_fmt;

namespace com::centreon::engine::configuration {

Expand Down Expand Up @@ -208,13 +208,10 @@ bool anomalydetection_helper::hook(std::string_view key,
return false;
}

/**
* @brief Check the validity of the Anomalydetection object.
*/
/**
* @brief Check the validity of the Anomalydetection object.
*
* @param [[maybe_unused]]
* @param err An error counter.
*/
void anomalydetection_helper::check_validity(error_cnt& err) const {
const Anomalydetection* o = static_cast<const Anomalydetection*>(obj());
Expand Down
2 changes: 2 additions & 0 deletions common/engine_conf/command_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ command_helper::command_helper(Command* obj)

/**
* @brief Check the validity of the Command object.
*
* @param err An error counter.
*/
void command_helper::check_validity(error_cnt& err) const {
const Command* o = static_cast<const Command*>(obj());
Expand Down
2 changes: 1 addition & 1 deletion common/engine_conf/contact_helper.hh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ class contact_helper : public message_helper {
bool insert_customvariable(std::string_view key,
std::string_view value) override;
};
} // namespace configuration
} // namespace com::centreon::engine::configuration

#endif /* !CCE_CONFIGURATION_CONTACT */
2 changes: 1 addition & 1 deletion common/engine_conf/host_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#error host_helper should not be compiled in this context.
#endif

using msg_fmt = com::centreon::exceptions::msg_fmt;
using com::centreon::exceptions::msg_fmt;

namespace com::centreon::engine::configuration {

Expand Down
2 changes: 1 addition & 1 deletion common/engine_conf/hostdependency_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "com/centreon/exceptions/msg_fmt.hh"

using msg_fmt = com::centreon::exceptions::msg_fmt;
using com::centreon::exceptions::msg_fmt;

namespace com::centreon::engine::configuration {

Expand Down
2 changes: 2 additions & 0 deletions common/engine_conf/hostescalation_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ bool hostescalation_helper::hook(std::string_view key,

/**
* @brief Check the validity of the Hostescalation object.
*
* @param err An error counter.
*/
void hostescalation_helper::check_validity(error_cnt& err) const {
const Hostescalation* o = static_cast<const Hostescalation*>(obj());
Expand Down
6 changes: 5 additions & 1 deletion common/engine_conf/hostgroup_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,17 @@ bool hostgroup_helper::hook(std::string_view key,

/**
* @brief Check the validity of the Hostgroup object.
*
* @param err An error counter.
*/
void hostgroup_helper::check_validity(error_cnt& err) const {
const Hostgroup* o = static_cast<const Hostgroup*>(obj());

if (o->obj().register_()) {
if (o->hostgroup_name().empty())
if (o->hostgroup_name().empty()) {
err.config_errors++;
throw msg_fmt("Host group has no name (property 'hostgroup_name')");
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion common/engine_conf/parser.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <fstream>
#include "common/engine_conf/file_info.hh"
#include "state_helper.hh"
//#include "host.hh"
// #include "host.hh"

namespace com::centreon::engine::configuration {

Expand Down
18 changes: 13 additions & 5 deletions common/engine_conf/service_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "com/centreon/exceptions/msg_fmt.hh"

using msg_fmt = com::centreon::exceptions::msg_fmt;
using com::centreon::exceptions::msg_fmt;

namespace com::centreon::engine::configuration {

Expand Down Expand Up @@ -210,19 +210,27 @@ bool service_helper::hook(std::string_view key, const std::string_view& value) {

/**
* @brief Check the validity of the Service object.
*
* @param err An error counter.
*/
void service_helper::check_validity(error_cnt& err) const {
const Service* o = static_cast<const Service*>(obj());

if (o->obj().register_()) {
if (o->service_description().empty())
if (o->service_description().empty()) {
err.config_errors++;
throw msg_fmt("Services must have a non-empty description");
if (o->check_command().empty())
}
if (o->check_command().empty()) {
err.config_errors++;
throw msg_fmt("Service '{}' has an empty check command",
o->service_description());
if (o->host_name().empty())
}
if (o->host_name().empty()) {
err.config_errors++;
throw msg_fmt("Service '{}' must contain one host name",
o->service_description());
}
}
}

Expand Down Expand Up @@ -292,4 +300,4 @@ bool service_helper::insert_customvariable(std::string_view key,
new_cv->set_value(value.data(), value.size());
return true;
}
} // namespace configuration
} // namespace com::centreon::engine::configuration
2 changes: 1 addition & 1 deletion common/engine_conf/service_helper.hh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/**
* Copyright 2022-2024 Centreon (https://www.centreon.com/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
22 changes: 15 additions & 7 deletions common/engine_conf/servicedependency_helper.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/**
* Copyright 2022-2024 Centreon (https://www.centreon.com/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -20,7 +20,7 @@

#include "com/centreon/exceptions/msg_fmt.hh"

using msg_fmt = com::centreon::exceptions::msg_fmt;
using com::centreon::exceptions::msg_fmt;

namespace com::centreon::engine::configuration {

Expand Down Expand Up @@ -139,38 +139,46 @@ bool servicedependency_helper::hook(std::string_view key,

/**
* @brief Check the validity of the Servicedependency object.
*
* @param err An error counter.
*/
void servicedependency_helper::check_validity(error_cnt& err) const {
const Servicedependency* o = static_cast<const Servicedependency*>(obj());

/* Check base service(s). */
if (o->servicegroups().data().empty()) {
if (o->service_description().data().empty())
if (o->service_description().data().empty()) {
err.config_errors++;
throw msg_fmt(
"Service dependency is not attached to any service or service group "
"(properties 'service_description' or 'servicegroup_name', "
"respectively)");
else if (o->hosts().data().empty() && o->hostgroups().data().empty())
} else if (o->hosts().data().empty() && o->hostgroups().data().empty()) {
err.config_errors++;
throw msg_fmt(
"Service dependency is not attached to any host or host group "
"(properties 'host_name' or 'hostgroup_name', respectively)");
}
}

/* Check dependent service(s). */
if (o->dependent_servicegroups().data().empty()) {
if (o->dependent_service_description().data().empty())
if (o->dependent_service_description().data().empty()) {
err.config_errors++;
throw msg_fmt(
"Service dependency is not attached to "
"any dependent service or dependent service group "
"(properties 'dependent_service_description' or "
"'dependent_servicegroup_name', respectively)");
else if (o->dependent_hosts().data().empty() &&
o->dependent_hostgroups().data().empty())
} else if (o->dependent_hosts().data().empty() &&
o->dependent_hostgroups().data().empty()) {
err.config_errors++;
throw msg_fmt(
"Service dependency is not attached to "
"any dependent host or dependent host group (properties "
"'dependent_host_name' or 'dependent_hostgroup_name', "
"respectively)");
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion common/engine_conf/servicedependency_helper.hh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/**
* Copyright 2022-2024 Centreon (https://www.centreon.com/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
6 changes: 4 additions & 2 deletions common/engine_conf/serviceescalation_helper.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/**
* Copyright 2022-2024 Centreon (https://www.centreon.com/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -20,7 +20,7 @@

#include "com/centreon/exceptions/msg_fmt.hh"

using msg_fmt = com::centreon::exceptions::msg_fmt;
using com::centreon::exceptions::msg_fmt;

namespace com::centreon::engine::configuration {

Expand Down Expand Up @@ -110,6 +110,8 @@ bool serviceescalation_helper::hook(std::string_view key,

/**
* @brief Check the validity of the Serviceescalation object.
*
* @param err An error counter.
*/
void serviceescalation_helper::check_validity(error_cnt& err) const {
const Serviceescalation* o = static_cast<const Serviceescalation*>(obj());
Expand Down
11 changes: 8 additions & 3 deletions common/engine_conf/servicegroup_helper.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/**
* Copyright 2022-2024 Centreon (https://www.centreon.com/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -20,7 +20,7 @@

#include "com/centreon/exceptions/msg_fmt.hh"

using msg_fmt = com::centreon::exceptions::msg_fmt;
using com::centreon::exceptions::msg_fmt;

namespace com::centreon::engine::configuration {

Expand Down Expand Up @@ -57,13 +57,18 @@ bool servicegroup_helper::hook(std::string_view key,

/**
* @brief Check the validity of the Servicegroup object.
*
* @param err An error counter.
*/
void servicegroup_helper::check_validity(error_cnt& err) const {
const Servicegroup* o = static_cast<const Servicegroup*>(obj());

if (o->servicegroup_name().empty())
if (o->servicegroup_name().empty()) {
err.config_errors++;
throw msg_fmt("Service group has no name (property 'servicegroup_name')");
}
}

void servicegroup_helper::_init() {
Servicegroup* obj = static_cast<Servicegroup*>(mut_obj());
obj->mutable_obj()->set_register_(true);
Expand Down
2 changes: 1 addition & 1 deletion common/engine_conf/servicegroup_helper.hh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/**
* Copyright 2022-2024 Centreon (https://www.centreon.com/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
6 changes: 4 additions & 2 deletions common/engine_conf/severity_helper.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/**
* Copyright 2022-2024 Centreon (https://www.centreon.com/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -20,7 +20,7 @@

#include "com/centreon/exceptions/msg_fmt.hh"

using msg_fmt = com::centreon::exceptions::msg_fmt;
using com::centreon::exceptions::msg_fmt;

namespace com::centreon::engine::configuration {

Expand Down Expand Up @@ -75,6 +75,8 @@ bool severity_helper::hook(std::string_view key,

/**
* @brief Check the validity of the Severity object.
*
* @param err An error counter.
*/
void severity_helper::check_validity(error_cnt& err) const {
const Severity* o = static_cast<const Severity*>(obj());
Expand Down
Loading

0 comments on commit d7968a1

Please sign in to comment.