Enable clang-format
Fix up errors and enable clang-format during CI builds.
Change-Id: I4176b81f8b85a287af9354165e09ff66aeb9fb29
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/src/count.hpp b/src/count.hpp
index 9f0ce3e..af3998a 100644
--- a/src/count.hpp
+++ b/src/count.hpp
@@ -31,82 +31,77 @@
* If the oneshot parameter is true, then this condition won't pass
* again until it fails at least once.
*/
-template <typename T>
-class CountCondition : public IndexedConditional
+template <typename T> class CountCondition : public IndexedConditional
{
- public:
- CountCondition() = delete;
- CountCondition(const CountCondition&) = default;
- CountCondition(CountCondition&&) = default;
- CountCondition& operator=(const CountCondition&) = default;
- CountCondition& operator=(CountCondition&&) = default;
- ~CountCondition() = default;
+ public:
+ CountCondition() = delete;
+ CountCondition(const CountCondition&) = default;
+ CountCondition(CountCondition&&) = default;
+ CountCondition& operator=(const CountCondition&) = default;
+ CountCondition& operator=(CountCondition&&) = default;
+ ~CountCondition() = default;
- CountCondition(
- const PropertyIndex& conditionIndex,
- const std::function<bool(size_t)>& _countOp,
- const std::function<bool(T)>& _propertyOp,
- bool oneshot = false) :
- IndexedConditional(conditionIndex),
- countOp(_countOp),
- propertyOp(_propertyOp),
- oneshot(oneshot) {}
+ CountCondition(const PropertyIndex& conditionIndex,
+ const std::function<bool(size_t)>& _countOp,
+ const std::function<bool(T)>& _propertyOp,
+ bool oneshot = false) :
+ IndexedConditional(conditionIndex),
+ countOp(_countOp), propertyOp(_propertyOp), oneshot(oneshot)
+ {
+ }
- bool operator()() override
- {
- // Count the number of properties in the index that
- // pass the condition specified in the config file.
- auto count = std::count_if(
- index.cbegin(),
- index.cend(),
- [this](const auto & item)
+ bool operator()() override
+ {
+ // Count the number of properties in the index that
+ // pass the condition specified in the config file.
+ auto count = std::count_if(
+ index.cbegin(), index.cend(),
+ [this](const auto& item)
// *INDENT-OFF*
- {
- //Get the property value from storage[0],
- //and save the op result in storage[1].
- const auto& storage = std::get<storageIndex>(
- item.second);
- // Don't count properties that don't exist.
- if (std::get<valueIndex>(
- storage.get()).empty())
- {
- return false;
- }
- const auto& value = any_ns::any_cast<T>(
- std::get<valueIndex>(storage.get()));
- auto r = propertyOp(value);
-
- std::get<resultIndex>(storage.get()) = r;
-
- return r;
- });
- // *INDENT-ON*
-
- // Now apply the count condition to the count.
- auto result = countOp(count);
-
- // If this was a oneshot and the the condition has already
- // passed, then don't let it pass again until the condition
- // has gone back to false.
- if (oneshot && result && lastResult)
{
- return false;
- }
+ // Get the property value from storage[0],
+ // and save the op result in storage[1].
+ const auto& storage = std::get<storageIndex>(item.second);
+ // Don't count properties that don't exist.
+ if (std::get<valueIndex>(storage.get()).empty())
+ {
+ return false;
+ }
+ const auto& value =
+ any_ns::any_cast<T>(std::get<valueIndex>(storage.get()));
+ auto r = propertyOp(value);
- lastResult = result;
- return result;
+ std::get<resultIndex>(storage.get()) = r;
+
+ return r;
+ });
+ // *INDENT-ON*
+
+ // Now apply the count condition to the count.
+ auto result = countOp(count);
+
+ // If this was a oneshot and the the condition has already
+ // passed, then don't let it pass again until the condition
+ // has gone back to false.
+ if (oneshot && result && lastResult)
+ {
+ return false;
}
- private:
- /** @brief The comparison to perform on the count. */
- std::function<bool(size_t)> countOp;
- /** @brief The comparison to perform on each property. */
- std::function<bool(T)> propertyOp;
- /** @brief If the condition can be allowed to pass again
- on subsequent checks that are also true. */
- const bool oneshot;
- /** @brief The result of the previous check. */
- bool lastResult = false;
+ lastResult = result;
+ return result;
+ }
+
+ private:
+ /** @brief The comparison to perform on the count. */
+ std::function<bool(size_t)> countOp;
+ /** @brief The comparison to perform on each property. */
+ std::function<bool(T)> propertyOp;
+ /** @brief If the condition can be allowed to pass again
+ on subsequent checks that are also true. */
+ const bool oneshot;
+ /** @brief The result of the previous check. */
+ bool lastResult = false;
};
} // namespace monitoring
} // namespace dbus