summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@fuzziesquirrel.com>2018-03-29 10:34:05 -0400
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2018-03-29 10:34:46 -0400
commitd1eac88d18ae7dd11033dba87b6aebb220da9064 (patch)
tree9744e38138ff853c53868d847f86e9ad58e9ac66
parent1abcb06bedadfbd40b4ec6f7e5f6a95021df3c96 (diff)
downloadphosphor-dbus-monitor-d1eac88d18ae7dd11033dba87b6aebb220da9064.zip
phosphor-dbus-monitor-d1eac88d18ae7dd11033dba87b6aebb220da9064.tar.gz
Enable clang-format
Fix up errors and enable clang-format during CI builds. Change-Id: I4176b81f8b85a287af9354165e09ff66aeb9fb29 Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
-rw-r--r--.clang-format85
-rw-r--r--mslverify/util.hpp182
-rw-r--r--mslverify/verify.cpp69
-rw-r--r--src/callback.hpp309
-rw-r--r--src/count.hpp127
-rw-r--r--src/data_types.hpp38
-rw-r--r--src/elog.cpp1
-rw-r--r--src/elog.hpp196
-rw-r--r--src/event.hpp178
-rw-r--r--src/event_entry.hpp66
-rw-r--r--src/event_manager.cpp29
-rw-r--r--src/event_manager.hpp61
-rw-r--r--src/format.hpp1
-rw-r--r--src/journal.cpp6
-rw-r--r--src/journal.hpp94
-rw-r--r--src/method.hpp137
-rw-r--r--src/propertywatch.hpp270
-rw-r--r--src/propertywatchimpl.hpp55
-rw-r--r--src/resolve_errors.cpp43
-rw-r--r--src/resolve_errors.hpp78
-rw-r--r--src/sdbusplus.hpp172
-rw-r--r--src/sdevent.hpp95
-rw-r--r--src/sdevent/event.hpp137
-rw-r--r--src/sdevent/source.hpp145
-rw-r--r--src/sdevent/timer.hpp184
-rw-r--r--src/test/callbackgentest.cpp18
-rw-r--r--src/test/callbackgroupgentest.cpp14
-rw-r--r--src/test/conditiongentest.cpp20
-rw-r--r--src/test/pathgentest.cpp95
-rw-r--r--src/test/propertygentest.cpp65
-rw-r--r--src/test/propertywatchgentest.cpp80
-rw-r--r--src/test/propertywatchtest.cpp134
-rw-r--r--src/test/propertywatchtest.hpp637
-rw-r--r--src/tupleref.hpp17
-rw-r--r--src/watch.hpp23
35 files changed, 1713 insertions, 2148 deletions
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..bbc1bb1
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,85 @@
+---
+Language: Cpp
+# BasedOnStyle: LLVM
+AccessModifierOffset: -2
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignEscapedNewlinesLeft: false
+AlignOperands: true
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortBlocksOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: None
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: false
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:
+ AfterClass: true
+ AfterControlStatement: true
+ AfterEnum: true
+ AfterFunction: true
+ AfterNamespace: true
+ AfterObjCDeclaration: true
+ AfterStruct: true
+ AfterUnion: true
+ BeforeCatch: true
+ BeforeElse: true
+ IndentBraces: false
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Custom
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializers: AfterColon
+ColumnLimit: 80
+CommentPragmas: '^ IWYU pragma:'
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: true
+DerivePointerAlignment: true
+PointerAlignment: Left
+DisableFormat: false
+ExperimentalAutoDetectBinPacking: false
+FixNamespaceComments: true
+ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
+IndentCaseLabels: true
+IndentWidth: 4
+IndentWrappedFunctionNames: true
+KeepEmptyLinesAtTheStartOfBlocks: true
+MacroBlockBegin: ''
+MacroBlockEnd: ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+ObjCBlockIndentWidth: 2
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: true
+PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakComment: 300
+PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 1000
+PenaltyExcessCharacter: 1000000
+PenaltyReturnTypeOnItsOwnLine: 60
+PointerAlignment: Right
+ReflowComments: true
+SortIncludes: false
+SpaceAfterCStyleCast: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: ControlStatements
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles: false
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard: Cpp11
+TabWidth: 4
+UseTab: Never
+...
+
diff --git a/mslverify/util.hpp b/mslverify/util.hpp
index 2c26fc2..f487cee 100644
--- a/mslverify/util.hpp
+++ b/mslverify/util.hpp
@@ -15,7 +15,7 @@ namespace errors = sdbusplus::xyz::openbmc_project::Common::Error;
} // namespace detail
/** @brief Alias for PropertiesChanged signal callbacks. */
-template <typename ...T>
+template <typename... T>
using Properties = std::map<std::string, sdbusplus::message::variant<T...>>;
namespace sdbusplus
@@ -30,31 +30,23 @@ static auto& getBus()
}
/** @brief Invoke a method. */
-template <typename ...Args>
-static auto callMethod(
- ::sdbusplus::bus::bus& bus,
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method,
- Args&& ... args)
+template <typename... Args>
+static auto callMethod(::sdbusplus::bus::bus& bus, const std::string& busName,
+ const std::string& path, const std::string& interface,
+ const std::string& method, Args&&... args)
{
- auto reqMsg = bus.new_method_call(
- busName.c_str(),
- path.c_str(),
- interface.c_str(),
- method.c_str());
+ auto reqMsg = bus.new_method_call(busName.c_str(), path.c_str(),
+ interface.c_str(), method.c_str());
reqMsg.append(std::forward<Args>(args)...);
auto respMsg = bus.call(reqMsg);
if (respMsg.is_method_error())
{
phosphor::logging::log<phosphor::logging::level::INFO>(
- "Failed to invoke DBus method.",
- phosphor::logging::entry("PATH=%s", path.c_str()),
- phosphor::logging::entry(
- "INTERFACE=%s", interface.c_str()),
- phosphor::logging::entry("METHOD=%s", method.c_str()));
+ "Failed to invoke DBus method.",
+ phosphor::logging::entry("PATH=%s", path.c_str()),
+ phosphor::logging::entry("INTERFACE=%s", interface.c_str()),
+ phosphor::logging::entry("METHOD=%s", method.c_str()));
phosphor::logging::elog<detail::errors::InternalFailure>();
}
@@ -62,90 +54,59 @@ static auto callMethod(
}
/** @brief Invoke a method. */
-template <typename ...Args>
-static auto callMethod(
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method,
- Args&& ... args)
+template <typename... Args>
+static auto callMethod(const std::string& busName, const std::string& path,
+ const std::string& interface, const std::string& method,
+ Args&&... args)
{
- return callMethod(
- getBus(),
- busName,
- path,
- interface,
- method,
- std::forward<Args>(args)...);
+ return callMethod(getBus(), busName, path, interface, method,
+ std::forward<Args>(args)...);
}
/** @brief Invoke a method and read the response. */
-template <typename Ret, typename ...Args>
-static auto callMethodAndRead(
- ::sdbusplus::bus::bus& bus,
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method,
- Args&& ... args)
+template <typename Ret, typename... Args>
+static auto
+ callMethodAndRead(::sdbusplus::bus::bus& bus, const std::string& busName,
+ const std::string& path, const std::string& interface,
+ const std::string& method, Args&&... args)
{
- ::sdbusplus::message::message respMsg =
- callMethod<Args...>(
- bus,
- busName,
- path,
- interface,
- method,
- std::forward<Args>(args)...);
+ ::sdbusplus::message::message respMsg = callMethod<Args...>(
+ bus, busName, path, interface, method, std::forward<Args>(args)...);
Ret resp;
respMsg.read(resp);
return resp;
}
/** @brief Invoke a method and read the response. */
- template <typename Ret, typename ...Args>
-static auto callMethodAndRead(
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method,
- Args&& ... args)
+template <typename Ret, typename... Args>
+static auto callMethodAndRead(const std::string& busName,
+ const std::string& path,
+ const std::string& interface,
+ const std::string& method, Args&&... args)
{
- return callMethodAndRead<Ret>(
- getBus(),
- busName,
- path,
- interface,
- method,
- std::forward<Args>(args)...);
+ return callMethodAndRead<Ret>(getBus(), busName, path, interface, method,
+ std::forward<Args>(args)...);
}
-
/** @brief Get service from the mapper. */
-static auto getService(
- ::sdbusplus::bus::bus& bus,
- const std::string& path,
- const std::string& interface)
+static auto getService(::sdbusplus::bus::bus& bus, const std::string& path,
+ const std::string& interface)
{
using namespace std::literals::string_literals;
using GetObject = std::map<std::string, std::vector<std::string>>;
auto mapperResp = callMethodAndRead<GetObject>(
- bus,
- "xyz.openbmc_project.ObjectMapper"s,
- "/xyz/openbmc_project/object_mapper"s,
- "xyz.openbmc_project.ObjectMapper"s,
- "GetObject"s,
- path,
- GetObject::mapped_type{interface});
+ bus, "xyz.openbmc_project.ObjectMapper"s,
+ "/xyz/openbmc_project/object_mapper"s,
+ "xyz.openbmc_project.ObjectMapper"s, "GetObject"s, path,
+ GetObject::mapped_type{interface});
if (mapperResp.empty())
{
phosphor::logging::log<phosphor::logging::level::INFO>(
- "Object not found.",
- phosphor::logging::entry("PATH=%s", path.c_str()),
- phosphor::logging::entry(
- "INTERFACE=%s", interface.c_str()));
+ "Object not found.",
+ phosphor::logging::entry("PATH=%s", path.c_str()),
+ phosphor::logging::entry("INTERFACE=%s", interface.c_str()));
phosphor::logging::elog<detail::errors::InternalFailure>();
}
return mapperResp.begin()->first;
@@ -153,23 +114,15 @@ static auto getService(
/** @brief Get a property without mapper lookup. */
template <typename Property>
-static auto getProperty(
- ::sdbusplus::bus::bus& bus,
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& property)
+static auto getProperty(::sdbusplus::bus::bus& bus, const std::string& busName,
+ const std::string& path, const std::string& interface,
+ const std::string& property)
{
using namespace std::literals::string_literals;
- auto msg = callMethod(
- bus,
- busName,
- path,
- "org.freedesktop.DBus.Properties"s,
- "Get"s,
- interface,
- property);
+ auto msg =
+ callMethod(bus, busName, path, "org.freedesktop.DBus.Properties"s,
+ "Get"s, interface, property);
::sdbusplus::message::variant<Property> value;
msg.read(value);
return value.template get<Property>();
@@ -177,48 +130,29 @@ static auto getProperty(
/** @brief Get a property without mapper lookup. */
template <typename Property>
-static auto getProperty(
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& property)
+static auto getProperty(const std::string& busName, const std::string& path,
+ const std::string& interface,
+ const std::string& property)
{
- return getProperty<Property>(
- getBus(),
- busName,
- path,
- interface,
- property);
+ return getProperty<Property>(getBus(), busName, path, interface, property);
}
/** @brief Get a property with mapper lookup. */
template <typename Property>
-static auto getProperty(
- ::sdbusplus::bus::bus& bus,
- const std::string& path,
- const std::string& interface,
- const std::string& property)
+static auto getProperty(::sdbusplus::bus::bus& bus, const std::string& path,
+ const std::string& interface,
+ const std::string& property)
{
- return getProperty<Property>(
- bus,
- getService(bus, path, interface),
- path,
- interface,
- property);
+ return getProperty<Property>(bus, getService(bus, path, interface), path,
+ interface, property);
}
/** @brief Get a property with mapper lookup. */
template <typename Property>
-static auto getProperty(
- const std::string& path,
- const std::string& interface,
- const std::string& property)
+static auto getProperty(const std::string& path, const std::string& interface,
+ const std::string& property)
{
- return getProperty<Property>(
- getBus(),
- path,
- interface,
- property);
+ return getProperty<Property>(getBus(), path, interface, property);
}
} // namespace sdbusplus
diff --git a/mslverify/verify.cpp b/mslverify/verify.cpp
index 1595166..c9c06aa 100644
--- a/mslverify/verify.cpp
+++ b/mslverify/verify.cpp
@@ -21,13 +21,13 @@
using namespace std::literals::string_literals;
-template <typename T>
-struct BusMeetsMSL
+template <typename T> struct BusMeetsMSL
{
std::string path;
- BusMeetsMSL(const std::string& p)
- :path(p) {}
+ BusMeetsMSL(const std::string& p) : path(p)
+ {
+ }
auto operator()(const T& arg)
{
@@ -36,16 +36,14 @@ struct BusMeetsMSL
const auto& busName = arg.first;
return util::sdbusplus::getProperty<bool>(
- busName,
- path,
- "xyz.openbmc_project.Inventory."
- "Decorator.MeetsMinimumShipLevel"s,
- "MeetsMinimumShipLevel"s);
+ busName, path,
+ "xyz.openbmc_project.Inventory."
+ "Decorator.MeetsMinimumShipLevel"s,
+ "MeetsMinimumShipLevel"s);
}
};
-template <typename T>
-struct PathMeetsMSL
+template <typename T> struct PathMeetsMSL
{
auto operator()(const T& arg)
{
@@ -55,19 +53,17 @@ struct PathMeetsMSL
const auto& path = arg.first;
return std::all_of(
- arg.second.begin(),
- arg.second.end(),
- BusMeetsMSL<typename decltype(arg.second)::value_type>(path));
+ arg.second.begin(), arg.second.end(),
+ BusMeetsMSL<typename decltype(arg.second)::value_type>(path));
}
};
int main(void)
{
- auto mslVerificationRequired =
- util::sdbusplus::getProperty<bool>(
- "/xyz/openbmc_project/control/minimum_ship_level_required"s,
- "xyz.openbmc_project.Control.MinimumShipLevel"s,
- "MinimumShipLevelRequired"s);
+ auto mslVerificationRequired = util::sdbusplus::getProperty<bool>(
+ "/xyz/openbmc_project/control/minimum_ship_level_required"s,
+ "xyz.openbmc_project.Control.MinimumShipLevel"s,
+ "MinimumShipLevelRequired"s);
if (!mslVerificationRequired)
{
@@ -80,32 +76,23 @@ int main(void)
// the minimum ship level has been met.
using SubTreeType =
- std::map<
- std::string,
- std::map<std::string, std::vector<std::string>>>;
-
- auto subtree =
- util::sdbusplus::callMethodAndRead<SubTreeType>(
- "xyz.openbmc_project.ObjectMapper"s,
- "/xyz/openbmc_project/object_mapper"s,
- "xyz.openbmc_project.ObjectMapper"s,
- "GetSubTree"s,
- "/"s,
- 0,
- std::vector<std::string>{
- "xyz.openbmc_project.Inventory"
- ".Decorator.MeetsMinimumShipLevel"s});
-
- auto result = std::all_of(
- subtree.begin(),
- subtree.end(),
- PathMeetsMSL<SubTreeType::value_type>());
+ std::map<std::string, std::map<std::string, std::vector<std::string>>>;
+
+ auto subtree = util::sdbusplus::callMethodAndRead<SubTreeType>(
+ "xyz.openbmc_project.ObjectMapper"s,
+ "/xyz/openbmc_project/object_mapper"s,
+ "xyz.openbmc_project.ObjectMapper"s, "GetSubTree"s, "/"s, 0,
+ std::vector<std::string>{"xyz.openbmc_project.Inventory"
+ ".Decorator.MeetsMinimumShipLevel"s});
+
+ auto result = std::all_of(subtree.begin(), subtree.end(),
+ PathMeetsMSL<SubTreeType::value_type>());
if (!result)
{
phosphor::logging::log<phosphor::logging::level::INFO>(
- "The physical system configuration does not "
- "satisfy the minimum ship level.");
+ "The physical system configuration does not "
+ "satisfy the minimum ship level.");
return 1;
}
diff --git a/src/callback.hpp b/src/callback.hpp
index d476d97..26cd2a1 100644
--- a/src/callback.hpp
+++ b/src/callback.hpp
@@ -17,22 +17,22 @@ namespace monitoring
*/
class Callback
{
- public:
- Callback() = default;
- Callback(const Callback&) = delete;
- Callback(Callback&&) = default;
- Callback& operator=(const Callback&) = delete;
- Callback& operator=(Callback&&) = default;
- virtual ~Callback() = default;
-
- /** @brief Run the callback.
- * @param[in] ctx - caller context
- * Context could be Startup or Signal
- * Startup: Callback is called as part of process startup.
- * Signal: Callback is called as part of watch condition has been met.
- *
- */
- virtual void operator()(Context ctx) = 0;
+ public:
+ Callback() = default;
+ Callback(const Callback&) = delete;
+ Callback(Callback&&) = default;
+ Callback& operator=(const Callback&) = delete;
+ Callback& operator=(Callback&&) = default;
+ virtual ~Callback() = default;
+
+ /** @brief Run the callback.
+ * @param[in] ctx - caller context
+ * Context could be Startup or Signal
+ * Startup: Callback is called as part of process startup.
+ * Signal: Callback is called as part of watch condition has been met.
+ *
+ */
+ virtual void operator()(Context ctx) = 0;
};
/** @class Conditional
@@ -42,16 +42,16 @@ class Callback
*/
class Conditional
{
- public:
- Conditional() = default;
- Conditional(const Conditional&) = delete;
- Conditional(Conditional&&) = default;
- Conditional& operator=(const Conditional&) = delete;
- Conditional& operator=(Conditional&&) = default;
- virtual ~Conditional() = default;
-
- /** @brief Test the condition. */
- virtual bool operator()() = 0;
+ public:
+ Conditional() = default;
+ Conditional(const Conditional&) = delete;
+ Conditional(Conditional&&) = default;
+ Conditional& operator=(const Conditional&) = delete;
+ Conditional& operator=(Conditional&&) = default;
+ virtual ~Conditional() = default;
+
+ /** @brief Test the condition. */
+ virtual bool operator()() = 0;
};
/** @class IndexedConditional
@@ -59,24 +59,25 @@ class Conditional
*/
class IndexedConditional : public Conditional
{
- public:
- IndexedConditional() = delete;
- IndexedConditional(const IndexedConditional&) = delete;
- IndexedConditional(IndexedConditional&&) = default;
- IndexedConditional& operator=(const IndexedConditional&) = delete;
- IndexedConditional& operator=(IndexedConditional&&) = default;
- virtual ~IndexedConditional() = default;
-
- explicit IndexedConditional(const PropertyIndex& conditionIndex)
- : Conditional(), index(conditionIndex) {}
-
- /** @brief Test the condition. */
- virtual bool operator()() override = 0;
-
- protected:
-
- /** @brief Property names and their associated storage. */
- const PropertyIndex& index;
+ public:
+ IndexedConditional() = delete;
+ IndexedConditional(const IndexedConditional&) = delete;
+ IndexedConditional(IndexedConditional&&) = default;
+ IndexedConditional& operator=(const IndexedConditional&) = delete;
+ IndexedConditional& operator=(IndexedConditional&&) = default;
+ virtual ~IndexedConditional() = default;
+
+ explicit IndexedConditional(const PropertyIndex& conditionIndex) :
+ Conditional(), index(conditionIndex)
+ {
+ }
+
+ /** @brief Test the condition. */
+ virtual bool operator()() override = 0;
+
+ protected:
+ /** @brief Property names and their associated storage. */
+ const PropertyIndex& index;
};
/** @class IndexedCallback
@@ -84,23 +85,24 @@ class IndexedConditional : public Conditional
*/
class IndexedCallback : public Callback
{
- public:
- IndexedCallback() = delete;
- IndexedCallback(const IndexedCallback&) = delete;
- IndexedCallback(IndexedCallback&&) = default;
- IndexedCallback& operator=(const IndexedCallback&) = delete;
- IndexedCallback& operator=(IndexedCallback&&) = default;
- virtual ~IndexedCallback() = default;
- explicit IndexedCallback(const PropertyIndex& callbackIndex)
- : Callback(), index(callbackIndex) {}
-
- /** @brief Run the callback. */
- virtual void operator()(Context ctx) override = 0;
-
- protected:
-
- /** @brief Property names and their associated storage. */
- const PropertyIndex& index;
+ public:
+ IndexedCallback() = delete;
+ IndexedCallback(const IndexedCallback&) = delete;
+ IndexedCallback(IndexedCallback&&) = default;
+ IndexedCallback& operator=(const IndexedCallback&) = delete;
+ IndexedCallback& operator=(IndexedCallback&&) = default;
+ virtual ~IndexedCallback() = default;
+ explicit IndexedCallback(const PropertyIndex& callbackIndex) :
+ Callback(), index(callbackIndex)
+ {
+ }
+
+ /** @brief Run the callback. */
+ virtual void operator()(Context ctx) override = 0;
+
+ protected:
+ /** @brief Property names and their associated storage. */
+ const PropertyIndex& index;
};
/** @class GroupOfCallbacks
@@ -113,67 +115,68 @@ class IndexedCallback : public Callback
*
* @tparam CallbackAccess - Access to the array of callbacks.
*/
-template <typename CallbackAccess>
-class GroupOfCallbacks : public Callback
+template <typename CallbackAccess> class GroupOfCallbacks : public Callback
{
- public:
- GroupOfCallbacks() = delete;
- GroupOfCallbacks(const GroupOfCallbacks&) = delete;
- GroupOfCallbacks(GroupOfCallbacks&&) = default;
- GroupOfCallbacks& operator=(const GroupOfCallbacks&) = delete;
- GroupOfCallbacks& operator=(GroupOfCallbacks&&) = default;
- ~GroupOfCallbacks() = default;
- explicit GroupOfCallbacks(
- const std::vector<size_t>& graphEntry)
- : graph(graphEntry) {}
-
- /** @brief Run the callbacks. */
- void operator()(Context ctx) override
+ public:
+ GroupOfCallbacks() = delete;
+ GroupOfCallbacks(const GroupOfCallbacks&) = delete;
+ GroupOfCallbacks(GroupOfCallbacks&&) = default;
+ GroupOfCallbacks& operator=(const GroupOfCallbacks&) = delete;
+ GroupOfCallbacks& operator=(GroupOfCallbacks&&) = default;
+ ~GroupOfCallbacks() = default;
+ explicit GroupOfCallbacks(const std::vector<size_t>& graphEntry) :
+ graph(graphEntry)
+ {
+ }
+
+ /** @brief Run the callbacks. */
+ void operator()(Context ctx) override
+ {
+ for (auto e : graph)
{
- for (auto e : graph)
- {
- (*CallbackAccess::get()[e])(ctx);
- }
+ (*CallbackAccess::get()[e])(ctx);
}
+ }
- private:
- /** @brief The offsets of the callbacks in the group. */
- const std::vector<size_t>& graph;
+ private:
+ /** @brief The offsets of the callbacks in the group. */
+ const std::vector<size_t>& graph;
};
/** @class ConditionalCallback
* @brief Callback adaptor that asssociates a condition with a callback.
*/
-template <typename CallbackAccess>
-class ConditionalCallback: public Callback
+template <typename CallbackAccess> class ConditionalCallback : public Callback
{
- public:
- ConditionalCallback() = delete;
- ConditionalCallback(const ConditionalCallback&) = delete;
- ConditionalCallback(ConditionalCallback&&) = default;
- ConditionalCallback& operator=(const ConditionalCallback&) = delete;
- ConditionalCallback& operator=(ConditionalCallback&&) = default;
- virtual ~ConditionalCallback() = default;
- ConditionalCallback(
- const std::vector<size_t>& graphEntry,
- Conditional& cond)
- : graph(graphEntry), condition(cond) {}
-
- /** @brief Run the callback if the condition is satisfied. */
- virtual void operator()(Context ctx) override
+ public:
+ ConditionalCallback() = delete;
+ ConditionalCallback(const ConditionalCallback&) = delete;
+ ConditionalCallback(ConditionalCallback&&) = default;
+ ConditionalCallback& operator=(const ConditionalCallback&) = delete;
+ ConditionalCallback& operator=(ConditionalCallback&&) = default;
+ virtual ~ConditionalCallback() = default;
+ ConditionalCallback(const std::vector<size_t>& graphEntry,
+ Conditional& cond) :
+ graph(graphEntry),
+ condition(cond)
+ {
+ }
+
+ /** @brief Run the callback if the condition is satisfied. */
+ virtual void operator()(Context ctx) override
+ {
+ if (condition())
{
- if (condition())
- {
- (*CallbackAccess::get()[graph[0]])(ctx);
- }
+ (*CallbackAccess::get()[graph[0]])(ctx);
}
+ }
- protected:
- /** @brief The index of the callback to conditionally invoke. */
- const std::vector<size_t>& graph;
+ protected:
+ /** @brief The index of the callback to conditionally invoke. */
+ const std::vector<size_t>& graph;
- /** @brief The condition to test. */
- Conditional& condition;
+ /** @brief The condition to test. */
+ Conditional& condition;
};
/** @class DeferrableCallback
@@ -192,59 +195,57 @@ class ConditionalCallback: public Callback
template <typename CallbackAccess, typename TimerType>
class DeferrableCallback : public ConditionalCallback<CallbackAccess>
{
- public:
- DeferrableCallback() = delete;
- DeferrableCallback(const DeferrableCallback&) = delete;
- DeferrableCallback(DeferrableCallback&&) = default;
- DeferrableCallback& operator=(const DeferrableCallback&) = delete;
- DeferrableCallback& operator=(DeferrableCallback&&) = default;
- ~DeferrableCallback() = default;
-
- DeferrableCallback(
- const std::vector<size_t>& graphEntry,
- Conditional& cond,
- const std::chrono::microseconds& delay)
- : ConditionalCallback<CallbackAccess>(graphEntry, cond),
- delayInterval(delay),
- timer(nullptr) {}
-
- void operator()(Context ctx) override
+ public:
+ DeferrableCallback() = delete;
+ DeferrableCallback(const DeferrableCallback&) = delete;
+ DeferrableCallback(DeferrableCallback&&) = default;
+ DeferrableCallback& operator=(const DeferrableCallback&) = delete;
+ DeferrableCallback& operator=(DeferrableCallback&&) = default;
+ ~DeferrableCallback() = default;
+
+ DeferrableCallback(const std::vector<size_t>& graphEntry, Conditional& cond,
+ const std::chrono::microseconds& delay) :
+ ConditionalCallback<CallbackAccess>(graphEntry, cond),
+ delayInterval(delay), timer(nullptr)
+ {
+ }
+
+ void operator()(Context ctx) override
+ {
+ if (!timer)
{
- if (!timer)
- {
- timer = std::make_unique<TimerType>(
-// **INDENT-OFF**
- [ctx, this](auto & source)
- {
- this->ConditionalCallback<CallbackAccess>::operator()(ctx);
- });
-// **INDENT-ON**
- timer->disable();
- }
+ timer = std::make_unique<TimerType>(
+ // **INDENT-OFF**
+ [ctx, this](auto& source) {
+ this->ConditionalCallback<CallbackAccess>::operator()(ctx);
+ });
+ // **INDENT-ON**
+ timer->disable();
+ }
- if (this->condition())
- {
- if (!timer->enabled())
- {
- // This is the first time the condition evaluated.
- // Start the countdown.
- timer->update(timer->now() + delayInterval);
- timer->enable();
- }
- }
- else
+ if (this->condition())
+ {
+ if (!timer->enabled())
{
- // The condition did not evaluate. Stop the countdown.
- timer->disable();
+ // This is the first time the condition evaluated.
+ // Start the countdown.
+ timer->update(timer->now() + delayInterval);
+ timer->enable();
}
}
+ else
+ {
+ // The condition did not evaluate. Stop the countdown.
+ timer->disable();
+ }
+ }
- private:
- /** @brief The length to wait for the condition to stop evaluating. */
- std::chrono::microseconds delayInterval;
+ private:
+ /** @brief The length to wait for the condition to stop evaluating. */
+ std::chrono::microseconds delayInterval;
- /** @brief Delegated timer functions. */
- std::unique_ptr<TimerType> timer;
+ /** @brief Delegated timer functions. */
+ std::unique_ptr<TimerType> timer;
};
} // namespace monitoring
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 @@ namespace monitoring
* 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;
+ {
+ // 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);
- return r;
- });
- // *INDENT-ON*
+ std::get<resultIndex>(storage.get()) = r;
- // Now apply the count condition to the count.
- auto result = countOp(count);
+ return r;
+ });
+ // *INDENT-ON*
- // 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;
- }
+ // Now apply the count condition to the count.
+ auto result = countOp(count);
- lastResult = result;
- return result;
+ // 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
diff --git a/src/data_types.hpp b/src/data_types.hpp
index 607289a..6be6431 100644
--- a/src/data_types.hpp
+++ b/src/data_types.hpp
@@ -17,17 +17,17 @@ constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper";
constexpr auto MAPPER_PATH = "/xyz/openbmc_project/object_mapper";
constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper";
-//PropertyIndex::key_type fields
+// PropertyIndex::key_type fields
constexpr auto pathIndex = 0;
constexpr auto interfaceIndex = 1;
constexpr auto propertyIndex = 2;
-//PropertyIndex::mapped_type fields
+// PropertyIndex::mapped_type fields
constexpr auto pathMetaIndex = 0;
constexpr auto propertyMetaIndex = 1;
constexpr auto storageIndex = 2;
-//ConfigPropertyStorage fields
+// ConfigPropertyStorage fields
constexpr auto valueIndex = 0;
constexpr auto resultIndex = 1;
@@ -42,12 +42,11 @@ template <typename Key, typename Value>
using RefKeyMap = std::map<std::reference_wrapper<Key>, Value, std::less<Key>>;
/** @brief A map with a tuple of references as keys. */
-template <typename Value, typename ...Keys>
+template <typename Value, typename... Keys>
using TupleRefMap = std::map<TupleOfRefs<Keys...>, Value, TupleOfRefsLess>;
/** @brief A vector of references. */
-template <typename T>
-using RefVector = std::vector<std::reference_wrapper<T>>;
+template <typename T> using RefVector = std::vector<std::reference_wrapper<T>>;
/** @brief
*
@@ -59,31 +58,23 @@ using MapperPath = std::string;
/** @brief ObjectManager.InterfacesAdded signal signature alias. */
template <typename T>
-using InterfacesAdded = std::map <
- std::string,
- std::map <
- std::string,
- sdbusplus::message::variant<T >>>;
+using InterfacesAdded =
+ std::map<std::string,
+ std::map<std::string, sdbusplus::message::variant<T>>>;
/** @brief ObjectMapper.GetObject response signature alias. */
using GetObject = std::map<MapperPath, std::vector<std::string>>;
/** @brief Properties.GetAll response signature alias. */
template <typename T>
-using PropertiesChanged = std::map <
- std::string,
- sdbusplus::message::variant<T >>;
+using PropertiesChanged = std::map<std::string, sdbusplus::message::variant<T>>;
/** @brief Lookup index for properties . */
// *INDENT-OFF*
-using PropertyIndex = TupleRefMap <
- TupleOfRefs<
- const std::string,
- const std::string,
- std::tuple<any_ns::any, any_ns::any>>,
- const std::string,
- const std::string,
- const std::string >;
+using PropertyIndex =
+ TupleRefMap<TupleOfRefs<const std::string, const std::string,
+ std::tuple<any_ns::any, any_ns::any>>,
+ const std::string, const std::string, const std::string>;
// *INDENT-ON*
/** @brief Convert some C++ types to others.
@@ -97,8 +88,7 @@ template <typename T> struct Downcast
{
using Type = std::remove_cv_t<std::remove_reference_t<T>>;
};
-template <typename T> using DowncastType =
- typename Downcast<T>::Type;
+template <typename T> using DowncastType = typename Downcast<T>::Type;
} // namespace monitoring
} // namespace dbus
diff --git a/src/elog.cpp b/src/elog.cpp
index 116691e..9cd18c8 100644
--- a/src/elog.cpp
+++ b/src/elog.cpp
@@ -27,7 +27,6 @@ void ElogBase::operator()(Context ctx)
log();
}
-
} // namespace monitoring
} // namespace dbus
} // namespace phosphor
diff --git a/src/elog.hpp b/src/elog.hpp
index 234ef6f..996fd58 100644
--- a/src/elog.hpp
+++ b/src/elog.hpp
@@ -39,21 +39,22 @@ template <> struct ToString<std::string>
*/
class ElogBase : public Callback
{
- public:
- ElogBase(const ElogBase&) = delete;
- ElogBase(ElogBase&&) = default;
- ElogBase& operator=(const ElogBase&) = delete;
- ElogBase& operator=(ElogBase&&) = default;
- virtual ~ElogBase() = default;
- ElogBase() :
- Callback() {}
-
- /** @brief Callback interface implementation. */
- void operator()(Context ctx) override;
-
- private:
- /** @brief Delegate type specific calls to subclasses. */
- virtual void log() const = 0;
+ public:
+ ElogBase(const ElogBase&) = delete;
+ ElogBase(ElogBase&&) = default;
+ ElogBase& operator=(const ElogBase&) = delete;
+ ElogBase& operator=(ElogBase&&) = default;
+ virtual ~ElogBase() = default;
+ ElogBase() : Callback()
+ {
+ }
+
+ /** @brief Callback interface implementation. */
+ void operator()(Context ctx) override;
+
+ private:
+ /** @brief Delegate type specific calls to subclasses. */
+ virtual void log() const = 0;
};
namespace detail
@@ -65,10 +66,9 @@ namespace detail
* @tparam T - Error log type
* @tparam Args - Metadata fields types.
*/
-template <typename T, typename ...Args>
-struct CallElog
+template <typename T, typename... Args> struct CallElog
{
- static void op(Args&& ...args)
+ static void op(Args&&... args)
{
phosphor::logging::report<T>(std::forward<Args>(args)...);
}
@@ -84,31 +84,29 @@ struct CallElog
* @tparam Args - Metadata fields types.
* @param[in] arguments - Metadata fields to be added to the error log
*/
-template <typename T, typename ...Args>
-class Elog : public ElogBase
+template <typename T, typename... Args> class Elog : public ElogBase
{
- public:
- Elog(const Elog&) = delete;
- Elog(Elog&&) = default;
- Elog& operator=(const Elog&) = delete;
- Elog& operator=(Elog&&) = default;
- ~Elog() = default;
- Elog(Args&& ... arguments) :
- ElogBase(), args(std::forward<Args>(arguments)...) {}
-
- private:
- /** @brief elog interface implementation. */
- void log() const override
- {
- std::experimental::apply(
- detail::CallElog<T, Args...>::op,
- std::tuple_cat(args));
- }
- std::tuple<Args...> args;
+ public:
+ Elog(const Elog&) = delete;
+ Elog(Elog&&) = default;
+ Elog& operator=(const Elog&) = delete;
+ Elog& operator=(Elog&&) = default;
+ ~Elog() = default;
+ Elog(Args&&... arguments) :
+ ElogBase(), args(std::forward<Args>(arguments)...)
+ {
+ }
+ private:
+ /** @brief elog interface implementation. */
+ void log() const override
+ {
+ std::experimental::apply(detail::CallElog<T, Args...>::op,
+ std::tuple_cat(args));
+ }
+ std::tuple<Args...> args;
};
-
/**
* @class ElogWithMetadataCapture
*
@@ -135,75 +133,69 @@ class Elog : public ElogBase
* @tparam metadataType - The metadata to use
* @tparam propertyType - The data type of the captured properties
*/
-template<typename errorType,
- typename metadataType,
- typename propertyType>
+template <typename errorType, typename metadataType, typename propertyType>
class ElogWithMetadataCapture : public IndexedCallback
{
- public:
- ElogWithMetadataCapture() = delete;
- ElogWithMetadataCapture(const ElogWithMetadataCapture&) = delete;
- ElogWithMetadataCapture(ElogWithMetadataCapture&&) = default;
- ElogWithMetadataCapture& operator=(
- const ElogWithMetadataCapture&) = delete;
- ElogWithMetadataCapture& operator=(
- ElogWithMetadataCapture&&) = default;
- virtual ~ElogWithMetadataCapture() = default;
- explicit ElogWithMetadataCapture(
- const PropertyIndex& index) :
- IndexedCallback(index) {}
-
- /**
- * @brief Callback interface implementation that
- * creates an error log
- */
- void operator()(Context ctx) override
- {
- auto data = captureMetadata();
+ public:
+ ElogWithMetadataCapture() = delete;
+ ElogWithMetadataCapture(const ElogWithMetadataCapture&) = delete;
+ ElogWithMetadataCapture(ElogWithMetadataCapture&&) = default;
+ ElogWithMetadataCapture& operator=(const ElogWithMetadataCapture&) = delete;
+ ElogWithMetadataCapture& operator=(ElogWithMetadataCapture&&) = default;
+ virtual ~ElogWithMetadataCapture() = default;
+ explicit ElogWithMetadataCapture(const PropertyIndex& index) :
+ IndexedCallback(index)
+ {
+ }
- phosphor::logging::report<errorType>(
- metadataType(data.c_str()));
- }
+ /**
+ * @brief Callback interface implementation that
+ * creates an error log
+ */
+ void operator()(Context ctx) override
+ {
+ auto data = captureMetadata();
- private:
-
- /**
- * @brief Builds a metadata string with property information
- *
- * Finds all of the properties in the index that have
- * their condition pass/fail fields (get<resultIndex>(storage))
- * set to true, and then packs those paths, names, and values
- * into a metadata string that looks like:
- *
- * |path1:name1=value1|path2:name2=value2|...
- *
- * @return The metadata string
- */
- std::string captureMetadata()
+ phosphor::logging::report<errorType>(metadataType(data.c_str()));
+ }
+
+ private:
+ /**
+ * @brief Builds a metadata string with property information
+ *
+ * Finds all of the properties in the index that have
+ * their condition pass/fail fields (get<resultIndex>(storage))
+ * set to true, and then packs those paths, names, and values
+ * into a metadata string that looks like:
+ *
+ * |path1:name1=value1|path2:name2=value2|...
+ *
+ * @return The metadata string
+ */
+ std::string captureMetadata()
+ {
+ std::string metadata{'|'};
+
+ for (const auto& n : index)
{
- std::string metadata{'|'};
+ const auto& storage = std::get<storageIndex>(n.second).get();
+ const auto& result = std::get<resultIndex>(storage);
- for (const auto& n : index)
+ if (!result.empty() && any_ns::any_cast<bool>(result))
{
- const auto& storage = std::get<storageIndex>(n.second).get();
- const auto& result = std::get<resultIndex>(storage);
-
- if (!result.empty() && any_ns::any_cast<bool>(result))
- {
- const auto& path = std::get<pathIndex>(n.first).get();
- const auto& propertyName = std::get<propertyIndex>(
- n.first).get();
- auto value = ToString<propertyType>::op(
- any_ns::any_cast<propertyType>(
- std::get<valueIndex>(storage)));
-
- metadata += path + ":" + propertyName +
- '=' + value + '|';
- }
+ const auto& path = std::get<pathIndex>(n.first).get();
+ const auto& propertyName =
+ std::get<propertyIndex>(n.first).get();
+ auto value =
+ ToString<propertyType>::op(any_ns::any_cast<propertyType>(
+ std::get<valueIndex>(storage)));
+
+ metadata += path + ":" + propertyName + '=' + value + '|';
}
+ }
- return metadata;
- };
+ return metadata;
+ };
};
/** @brief Argument type deduction for constructing Elog instances.
@@ -212,11 +204,9 @@ class ElogWithMetadataCapture : public IndexedCallback
* @tparam Args - Metadata fields types.
* @param[in] arguments - Metadata fields to be added to the error log
*/
-template <typename T, typename ...Args>
-auto makeElog(Args&& ... arguments)
+template <typename T, typename... Args> auto makeElog(Args&&... arguments)
{
- return std::make_unique<Elog<T, Args...>>(
- std::forward<Args>(arguments)...);
+ return std::make_unique<Elog<T, Args...>>(std::forward<Args>(arguments)...);
}
} // namespace monitoring
diff --git a/src/event.hpp b/src/event.hpp
index b9f5167..a2a2236 100644
--- a/src/event.hpp
+++ b/src/event.hpp
@@ -22,60 +22,53 @@ namespace monitoring
*/
class EventBase : public IndexedCallback
{
- public:
- EventBase() = delete;
- EventBase(const EventBase&) = delete;
- EventBase(EventBase&&) = default;
- EventBase& operator=(const EventBase&) = delete;
- EventBase& operator=(EventBase&&) = default;
- virtual ~EventBase() = default;
- EventBase(const PropertyIndex& index) :
- IndexedCallback(index) {}
+ public:
+ EventBase() = delete;
+ EventBase(const EventBase&) = delete;
+ EventBase(EventBase&&) = default;
+ EventBase& operator=(const EventBase&) = delete;
+ EventBase& operator=(EventBase&&) = default;
+ virtual ~EventBase() = default;
+ EventBase(const PropertyIndex& index) : IndexedCallback(index)
+ {
+ }
+
+ /** @brief Callback interface implementation. */
+ void operator()(Context ctx) override
+ {
+ if (ctx == Context::START)
+ {
+ // No action should be taken
+ // as this call back is being called from
+ // daemon Startup.
+ return;
+ }
- /** @brief Callback interface implementation. */
- void operator()(Context ctx) override
+ for (const auto& n : index)
{
- if (ctx == Context::START)
- {
- // No action should be taken
- // as this call back is being called from
- // daemon Startup.
- return;
- }
+ const auto& path = std::get<pathIndex>(n.first);
+ const auto& propertyMeta = std::get<propertyIndex>(n.first);
+ const auto& storage = std::get<storageIndex>(n.second);
+ const auto& value = std::get<valueIndex>(storage.get());
- for (const auto& n : index)
+ if (!value.empty())
{
- const auto& path = std::get<pathIndex>(n.first);
- const auto& propertyMeta = std::get<propertyIndex>(n.first);
- const auto& storage = std::get<storageIndex>(n.second);
- const auto& value = std::get<valueIndex>(storage.get());
-
- if (!value.empty())
- {
- createEvent(
- path,
- propertyMeta,
- value);
- }
+ createEvent(path, propertyMeta, value);
}
-
}
-
- private:
-
- /** @brief Create the event Dbus Object.
- * @param[in] path - Dbus Object Path for which the
- * property has changed.
- * @param[in] property - Name of the property whose value
- * has been changed.
- * @param[in] value - Changed property value.
- */
- virtual void createEvent(
- const std::string& path,
- const std::string& property,
- const any_ns::any& value) const = 0;
-
-
+ }
+
+ private:
+ /** @brief Create the event Dbus Object.
+ * @param[in] path - Dbus Object Path for which the
+ * property has changed.
+ * @param[in] property - Name of the property whose value
+ * has been changed.
+ * @param[in] value - Changed property value.
+ */
+ virtual void createEvent(const std::string& path,
+ const std::string& property,
+ const any_ns::any& value) const = 0;
};
/** @class Event
@@ -83,53 +76,50 @@ class EventBase : public IndexedCallback
*
* @tparam T - The C++ type of the property values being traced.
*/
-template <typename T>
-class Event : public EventBase
+template <typename T> class Event : public EventBase
{
- public:
- Event() = delete;
- Event(const Event&) = delete;
- Event(Event&&) = default;
- Event& operator=(const Event&) = delete;
- Event& operator=(Event&&) = default;
- ~Event() = default;
-
- /** @brief Constructor.
- * @param[in] eventName - Name of the event.
- * @param[in] eventMessage- Event Message.
- * @param[in] index - look up index for the properties.
- */
- Event(std::string eventName,
- std::string eventMessage,
- const PropertyIndex& index) :
- EventBase(index),
- name(eventName),
- message(eventMessage) {}
-
- private:
- /** @brief Create the event Dbus Object.
- * @param[in] path - Dbus Object Path for which the
- * property has changed.
- * @param[in] property - Name of the property whose value
- * has been changed.
- * @param[in] value - Changed property value.
- */
- void createEvent(
- const std::string& path,
- const std::string& property,
- const any_ns::any& value) const override
- {
- std::stringstream ss {};
- ss << any_ns::any_cast<T>(value);
- phosphor::events::getManager().create(
- name, message, path, property, ss.str());
- }
-
- /** @brief Event Name */
- std::string name;
-
- /** @brief Event Message */
- std::string message;
+ public:
+ Event() = delete;
+ Event(const Event&) = delete;
+ Event(Event&&) = default;
+ Event& operator=(const Event&) = delete;
+ Event& operator=(Event&&) = default;
+ ~Event() = default;
+
+ /** @brief Constructor.
+ * @param[in] eventName - Name of the event.
+ * @param[in] eventMessage- Event Message.
+ * @param[in] index - look up index for the properties.
+ */
+ Event(std::string eventName, std::string eventMessage,
+ const PropertyIndex& index) :
+ EventBase(index),
+ name(eventName), message(eventMessage)
+ {
+ }
+
+ private:
+ /** @brief Create the event Dbus Object.
+ * @param[in] path - Dbus Object Path for which the
+ * property has changed.
+ * @param[in] property - Name of the property whose value
+ * has been changed.
+ * @param[in] value - Changed property value.
+ */
+ void createEvent(const std::string& path, const std::string& property,
+ const any_ns::any& value) const override
+ {
+ std::stringstream ss{};
+ ss << any_ns::any_cast<T>(value);
+ phosphor::events::getManager().create(name, message, path, property,
+ ss.str());
+ }
+
+ /** @brief Event Name */
+ std::string name;
+
+ /** @brief Event Message */
+ std::string message;
};
} // namespace monitoring
diff --git a/src/event_entry.hpp b/src/event_entry.hpp
index 7be66d9..e39f1e2 100644
--- a/src/event_entry.hpp
+++ b/src/event_entry.hpp
@@ -13,8 +13,8 @@ namespace events
using namespace phosphor::dbus::monitoring;
-using EntryIface = sdbusplus::server::object::object <
- sdbusplus::xyz::openbmc_project::Logging::server::Event >;
+using EntryIface = sdbusplus::server::object::object<
+ sdbusplus::xyz::openbmc_project::Logging::server::Event>;
/** @class Entry
* @brief OpenBMC Event entry implementation.
@@ -23,39 +23,35 @@ using EntryIface = sdbusplus::server::object::object <
*/
class Entry : public EntryIface
{
- public:
- Entry() = delete;
- Entry(const Entry&) = delete;
- Entry& operator=(const Entry&) = delete;
- Entry(Entry&&) = delete;
- Entry& operator=(Entry&&) = delete;
- virtual ~Entry() = default;
-
- /** @brief Constructor to put object onto bus at a dbus path.
- * @param[in] path - Path to attach at.
- * @param[in] eventId - The event entry id.
- * @param[in] timestamp - timestamp when the event created.
- * @param[in] msg - The message of the event.
- * @param[in] metaData - The event metadata.
- */
- Entry(
- const std::string& path,
- uint64_t eventTimestamp,
- std::string&& msg,
- std::vector<std::string>&& metaData) :
- EntryIface(SDBusPlus::getBus(), path.c_str(), true),
- objectPath(path)
- {
- timestamp(eventTimestamp);
- message(msg);
- additionalData(metaData);
- // Emit deferred signal.
- this->emit_object_added();
- }
-
- /** @brief Path of Object. */
- std::string objectPath;
-
+ public:
+ Entry() = delete;
+ Entry(const Entry&) = delete;
+ Entry& operator=(const Entry&) = delete;
+ Entry(Entry&&) = delete;
+ Entry& operator=(Entry&&) = delete;
+ virtual ~Entry() = default;
+
+ /** @brief Constructor to put object onto bus at a dbus path.
+ * @param[in] path - Path to attach at.
+ * @param[in] eventId - The event entry id.
+ * @param[in] timestamp - timestamp when the event created.
+ * @param[in] msg - The message of the event.
+ * @param[in] metaData - The event metadata.
+ */
+ Entry(const std::string& path, uint64_t eventTimestamp, std::string&& msg,
+ std::vector<std::string>&& metaData) :
+ EntryIface(SDBusPlus::getBus(), path.c_str(), true),
+ objectPath(path)
+ {
+ timestamp(eventTimestamp);
+ message(msg);
+ additionalData(metaData);
+ // Emit deferred signal.
+ this->emit_object_added();
+ }
+
+ /** @brief Path of Object. */
+ std::string objectPath;
};
} // namespace events
diff --git a/src/event_manager.cpp b/src/event_manager.cpp
index 2c09f35..6e7d302 100644
--- a/src/event_manager.cpp
+++ b/src/event_manager.cpp
@@ -25,12 +25,11 @@ namespace phosphor
namespace events
{
-void Manager::create(
- const std::string& eventName,
- const std::string& eventMessage,
- const std::string& objectPath,
- const std::string& propertyName,
- const std::string& propertyValue)
+void Manager::create(const std::string& eventName,
+ const std::string& eventMessage,
+ const std::string& objectPath,
+ const std::string& propertyName,
+ const std::string& propertyValue)
{
using namespace std::string_literals;
namespace fs = std::experimental::filesystem;
@@ -53,14 +52,15 @@ void Manager::create(
{
fs::path path(eventQueue.back()->objectPath);
id = std::stoi(std::string(path.filename().c_str()));
- id ++;
+ id++;
}
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
- std::chrono::system_clock::now().time_since_epoch()).count();
+ std::chrono::system_clock::now().time_since_epoch())
+ .count();
- auto objPath = std::string(OBJ_EVENT) + '/' + eventName + '/' +
- std::to_string(id);
+ auto objPath =
+ std::string(OBJ_EVENT) + '/' + eventName + '/' + std::to_string(id);
// check for capping of the events,if cap reached then erase the oldest
// event.
@@ -69,11 +69,10 @@ void Manager::create(
eventQueue.pop();
}
- eventQueue.emplace(std::make_unique<Entry>(
- objPath,
- ms, // Milliseconds since 1970
- std::move(msg),
- std::move(additionalData)));
+ eventQueue.emplace(std::make_unique<Entry>(objPath,
+ ms, // Milliseconds since 1970
+ std::move(msg),
+ std::move(additionalData)));
}
Manager& getManager()
diff --git a/src/event_manager.hpp b/src/event_manager.hpp
index 7184852..a177739 100644
--- a/src/event_manager.hpp
+++ b/src/event_manager.hpp
@@ -17,38 +17,35 @@ namespace events
*/
class Manager
{
- public:
- Manager() = default;
- Manager(const Manager&) = delete;
- Manager& operator=(const Manager&) = delete;
- Manager(Manager&&) = default;
- Manager& operator=(Manager&&) = default;
- virtual ~Manager() = default;
-
- /** @brief Create the D-Bus Event object.
- * @detail Add the objectPath,propertyName, propertyValue
- * as additional data of the event object.
- * @param[in] eventName - Name of the event.
- * @param[in] eventMessage - Message for the event.
- * @param[in] objectPath - Path of the D-Bus object.
- * @param[in] propertyName - Name of the property.
- * @param[in] propertyValue - Value of the property.
- */
- void create(
- const std::string& eventName,
- const std::string& eventMessage,
- const std::string& objectPath,
- const std::string& propertyName,
- const std::string& propertyValue);
-
- private:
- using EventName = std::string;
- /** @brief Queue of events */
- using EventQueue = std::queue<std::unique_ptr<Entry>>;
-
- using EventMap = std::map<EventName, EventQueue>;
- /** @brief Map of event name and the list of events **/
- EventMap eventMap;
+ public:
+ Manager() = default;
+ Manager(const Manager&) = delete;
+ Manager& operator=(const Manager&) = delete;
+ Manager(Manager&&) = default;
+ Manager& operator=(Manager&&) = default;
+ virtual ~Manager() = default;
+
+ /** @brief Create the D-Bus Event object.
+ * @detail Add the objectPath,propertyName, propertyValue
+ * as additional data of the event object.
+ * @param[in] eventName - Name of the event.
+ * @param[in] eventMessage - Message for the event.
+ * @param[in] objectPath - Path of the D-Bus object.
+ * @param[in] propertyName - Name of the property.
+ * @param[in] propertyValue - Value of the property.
+ */
+ void create(const std::string& eventName, const std::string& eventMessage,
+ const std::string& objectPath, const std::string& propertyName,
+ const std::string& propertyValue);
+
+ private:
+ using EventName = std::string;
+ /** @brief Queue of events */
+ using EventQueue = std::queue<std::unique_ptr<Entry>>;
+
+ using EventMap = std::map<EventName, EventQueue>;
+ /** @brief Map of event name and the list of events **/
+ EventMap eventMap;
};
Manager& getManager();
diff --git a/src/format.hpp b/src/format.hpp
index f0b0c8e..f622f2e 100644
--- a/src/format.hpp
+++ b/src/format.hpp
@@ -14,7 +14,6 @@ namespace detail
/** @brief Map format strings to undecorated C++ types. */
template <typename T> struct GetFormatType
{
-
};
template <> struct GetFormatType<bool>
{
diff --git a/src/journal.cpp b/src/journal.cpp
index f54c5b3..41d51e4 100644
--- a/src/journal.cpp
+++ b/src/journal.cpp
@@ -34,11 +34,7 @@ void JournalBase::operator()(Context ctx)
if (!value.empty())
{
- log(message,
- pathMeta,
- path,
- propertyMeta,
- value);
+ log(message, pathMeta, path, propertyMeta, value);
}
}
}
diff --git a/src/journal.hpp b/src/journal.hpp
index d9209af..249a7a2 100644
--- a/src/journal.hpp
+++ b/src/journal.hpp
@@ -20,30 +20,29 @@ namespace monitoring
*/
class JournalBase : public IndexedCallback
{
- public:
- JournalBase() = delete;
- JournalBase(const JournalBase&) = delete;
- JournalBase(JournalBase&&) = default;
- JournalBase& operator=(const JournalBase&) = delete;
- JournalBase& operator=(JournalBase&&) = default;
- virtual ~JournalBase() = default;
- JournalBase(const char* msg, const PropertyIndex& index) :
- IndexedCallback(index), message(msg) {}
+ public:
+ JournalBase() = delete;
+ JournalBase(const JournalBase&) = delete;
+ JournalBase(JournalBase&&) = default;
+ JournalBase& operator=(const JournalBase&) = delete;
+ JournalBase& operator=(JournalBase&&) = default;
+ virtual ~JournalBase() = default;
+ JournalBase(const char* msg, const PropertyIndex& index) :
+ IndexedCallback(index), message(msg)
+ {
+ }
- /** @brief Callback interface implementation. */
- void operator()(Context ctx) override;
+ /** @brief Callback interface implementation. */
+ void operator()(Context ctx) override;
- private:
- /** @brief Delegate type specific calls to subclasses. */
- virtual void log(
- const char* message,
- const std::string& pathMeta,
- const std::string& path,
- const std::string& propertyMeta,
- const any_ns::any& value) const = 0;
+ private:
+ /** @brief Delegate type specific calls to subclasses. */
+ virtual void log(const char* message, const std::string& pathMeta,
+ const std::string& path, const std::string& propertyMeta,
+ const any_ns::any& value) const = 0;
- /** @brief The client provided message to be traced. */
- const char* message;
+ /** @brief The client provided message to be traced. */
+ const char* message;
};
/** @struct Display
@@ -77,34 +76,33 @@ template <> struct Display<std::string>
template <typename T, phosphor::logging::level Severity>
class Journal : public JournalBase
{
- public:
- Journal() = delete;
- Journal(const Journal&) = delete;
- Journal(Journal&&) = default;
- Journal& operator=(const Journal&) = delete;
- Journal& operator=(Journal&&) = default;
- ~Journal() = default;
- Journal(const char* msg, const PropertyIndex& index) :
- JournalBase(msg, index) {}
+ public:
+ Journal() = delete;
+ Journal(const Journal&) = delete;
+ Journal(Journal&&) = default;
+ Journal& operator=(const Journal&) = delete;
+ Journal& operator=(Journal&&) = default;
+ ~Journal() = default;
+ Journal(const char* msg, const PropertyIndex& index) :
+ JournalBase(msg, index)
+ {
+ }
- private:
- /** @brief log interface implementation. */
- void log(
- const char* message,
- const std::string& pathMeta,
- const std::string& path,
- const std::string& propertyMeta,
- const any_ns::any& value) const override
- {
- phosphor::logging::log<Severity>(
- message,
- phosphor::logging::entry(
- (pathMeta + GetFormat<decltype(pathMeta)>::format).c_str(),
- path.c_str()),
- phosphor::logging::entry(
- (propertyMeta + GetFormat<T>::format).c_str(),
- detail::Display<T>::op(any_ns::any_cast<T>(value))));
- }
+ private:
+ /** @brief log interface implementation. */
+ void log(const char* message, const std::string& pathMeta,
+ const std::string& path, const std::string& propertyMeta,
+ const any_ns::any& value) const override
+ {
+ phosphor::logging::log<Severity>(
+ message,
+ phosphor::logging::entry(
+ (pathMeta + GetFormat<decltype(pathMeta)>::format).c_str(),
+ path.c_str()),
+ phosphor::logging::entry(
+ (propertyMeta + GetFormat<T>::format).c_str(),
+ detail::Display<T>::op(any_ns::any_cast<T>(value))));
+ }
};
} // namespace monitoring
diff --git a/src/method.hpp b/src/method.hpp
index 9475fb8..7c29205 100644
--- a/src/method.hpp
+++ b/src/method.hpp
@@ -19,22 +19,14 @@ namespace detail
* @tparam DBusInterface - The DBus interface to use.
* @tparam MethodArgs - DBus method argument types.
*/
-template <typename DBusInterface, typename ...MethodArgs>
-struct CallDBusMethod
+template <typename DBusInterface, typename... MethodArgs> struct CallDBusMethod
{
- static void op(
- const std::string& bus,
- const std::string& path,
- const std::string& iface,
- const std::string& method,
- MethodArgs&& ...args)
+ static void op(const std::string& bus, const std::string& path,
+ const std::string& iface, const std::string& method,
+ MethodArgs&&... args)
{
- DBusInterface::callMethodNoReply(
- bus,
- path,
- iface,
- method,
- std::forward<MethodArgs>(args)...);
+ DBusInterface::callMethodNoReply(bus, path, iface, method,
+ std::forward<MethodArgs>(args)...);
}
};
} // namespace detail
@@ -46,32 +38,28 @@ struct CallDBusMethod
*/
class MethodBase : public Callback
{
- public:
- MethodBase() = delete;
- MethodBase(const MethodBase&) = delete;
- MethodBase(MethodBase&&) = default;
- MethodBase& operator=(const MethodBase&) = delete;
- MethodBase& operator=(MethodBase&&) = default;
- virtual ~MethodBase() = default;
- MethodBase(
- const std::string& b,
- const std::string& p,
- const std::string& i,
- const std::string& m)
- : Callback(),
- bus(b),
- path(p),
- interface(i),
- method(m) {}
+ public:
+ MethodBase() = delete;
+ MethodBase(const MethodBase&) = delete;
+ MethodBase(MethodBase&&) = default;
+ MethodBase& operator=(const MethodBase&) = delete;
+ MethodBase& operator=(MethodBase&&) = default;
+ virtual ~MethodBase() = default;
+ MethodBase(const std::string& b, const std::string& p, const std::string& i,
+ const std::string& m) :
+ Callback(),
+ bus(b), path(p), interface(i), method(m)
+ {
+ }
- /** @brief Callback interface implementation. */
- void operator()(Context ctx) override = 0;
+ /** @brief Callback interface implementation. */
+ void operator()(Context ctx) override = 0;
- protected:
- const std::string& bus;
- const std::string& path;
- const std::string& interface;
- const std::string& method;
+ protected:
+ const std::string& bus;
+ const std::string& path;
+ const std::string& interface;
+ const std::string& method;
};
/** @class Method
@@ -80,57 +68,46 @@ class MethodBase : public Callback
* @tparam DBusInterface - The DBus interface to use to call the method.
* @tparam MethodArgs - DBus method argument types.
*/
-template <typename DBusInterface, typename ...MethodArgs>
+template <typename DBusInterface, typename... MethodArgs>
class Method : public MethodBase
{
- public:
- Method() = delete;
- Method(const Method&) = default;
- Method(Method&&) = default;
- Method& operator=(const Method&) = default;
- Method& operator=(Method&&) = default;
- ~Method() = default;
- Method(
- const std::string& bus,
- const std::string& path,
- const std::string& iface,
- const std::string& method,
- MethodArgs&& ... arguments)
- : MethodBase(bus, path, iface, method),
- args(std::forward<MethodArgs>(arguments)...) {}
+ public:
+ Method() = delete;
+ Method(const Method&) = default;
+ Method(Method&&) = default;
+ Method& operator=(const Method&) = default;
+ Method& operator=(Method&&) = default;
+ ~Method() = default;
+ Method(const std::string& bus, const std::string& path,
+ const std::string& iface, const std::string& method,
+ MethodArgs&&... arguments) :
+ MethodBase(bus, path, iface, method),
+ args(std::forward<MethodArgs>(arguments)...)
+ {
+ }
- /** @brief Callback interface implementation. */
- void operator()(Context ctx) override
- {
- std::experimental::apply(
- detail::CallDBusMethod<DBusInterface, MethodArgs...>::op,
- std::tuple_cat(
- std::make_tuple(bus),
- std::make_tuple(path),
- std::make_tuple(interface),
- std::make_tuple(method),
- args));
- }
+ /** @brief Callback interface implementation. */
+ void operator()(Context ctx) override
+ {
+ std::experimental::apply(
+ detail::CallDBusMethod<DBusInterface, MethodArgs...>::op,
+ std::tuple_cat(std::make_tuple(bus), std::make_tuple(path),
+ std::make_tuple(interface), std::make_tuple(method),
+ args));
+ }
- private:
- std::tuple<MethodArgs...> args;
+ private:
+ std::tuple<MethodArgs...> args;
};
/** @brief Argument type deduction for constructing Method instances. */
-template <typename DBusInterface, typename ...MethodArgs>
-auto makeMethod(
- const std::string& bus,
- const std::string& path,
- const std::string& iface,
- const std::string& method,
- MethodArgs&& ... arguments)
+template <typename DBusInterface, typename... MethodArgs>
+auto makeMethod(const std::string& bus, const std::string& path,
+ const std::string& iface, const std::string& method,
+ MethodArgs&&... arguments)
{
return std::make_unique<Method<DBusInterface, MethodArgs...>>(
- bus,
- path,
- iface,
- method,
- std::forward<MethodArgs>(arguments)...);
+ bus, path, iface, method, std::forward<MethodArgs>(arguments)...);
}
} // namespace monitoring
diff --git a/src/propertywatch.hpp b/src/propertywatch.hpp
index cd286a5..2cbf6f5 100644
--- a/src/propertywatch.hpp
+++ b/src/propertywatch.hpp
@@ -25,80 +25,78 @@ class Callback;
* A property watch maintains the state of one or more DBus properties
* as specified by the supplied index.
*/
-template <typename DBusInterfaceType>
-class PropertyWatch : public Watch
+template <typename DBusInterfaceType> class PropertyWatch : public Watch
{
- public:
- PropertyWatch() = delete;
- PropertyWatch(const PropertyWatch&) = delete;
- PropertyWatch(PropertyWatch&&) = default;
- PropertyWatch& operator=(const PropertyWatch&) = delete;
- PropertyWatch& operator=(PropertyWatch&&) = default;
- virtual ~PropertyWatch() = default;
- PropertyWatch(
- const PropertyIndex& watchIndex,
- Callback* callback = nullptr)
- : Watch(), index(watchIndex), cb(callback), alreadyRan(false) {}
-
- /** @brief Start the watch.
- *
- * Watch start interface implementation for PropertyWatch.
- */
- void start() override;
-
- /** @brief Run the watch callback method.
- *
- * Watch callback interface implementation for PropertyWatch.
- */
- void callback(Context ctx) override;
-
- /** @brief Update properties.
- *
- * Subclasses to query the properties specified by the index
- * and update the cache.
- *
- * @param[in] busName - The busname hosting the interface to query.
- * @param[in] path - The path of the interface to query.
- * @param[in] interface - The interface to query.
- */
- virtual void updateProperties(
- const std::string& busName,
- const std::string& path,
- const std::string& interface) = 0;
-
- /** @brief Dbus signal callback for PropertiesChanged.
- *
- * Subclasses to update the cache.
- *
- * @param[in] message - The org.freedesktop.DBus.PropertiesChanged
- * message.
- * @param[in] path - The path associated with the message.
- * @param[in] interface - The interface associated with the message.
- */
- virtual void propertiesChanged(
- sdbusplus::message::message&,
- const std::string& path,
- const std::string& interface) = 0;
-
- /** @brief Dbus signal callback for InterfacesAdded.
- *
- * Subclasses to update the cache.
- *
- * @param[in] msg - The org.freedesktop.DBus.PropertiesChanged
- * message.
- */
- virtual void interfacesAdded(sdbusplus::message::message& msg) = 0;
-
- protected:
-
- /** @brief Property names and their associated storage. */
- const PropertyIndex& index;
-
- /** @brief Optional callback method. */
- Callback* const cb;
-
- /** @brief The start method should only be invoked once. */
- bool alreadyRan;
+ public:
+ PropertyWatch() = delete;
+ PropertyWatch(const PropertyWatch&) = delete;
+ PropertyWatch(PropertyWatch&&) = default;
+ PropertyWatch& operator=(const PropertyWatch&) = delete;
+ PropertyWatch& operator=(PropertyWatch&&) = default;
+ virtual ~PropertyWatch() = default;
+ PropertyWatch(const PropertyIndex& watchIndex,
+ Callback* callback = nullptr) :
+ Watch(),
+ index(watchIndex), cb(callback), alreadyRan(false)
+ {
+ }
+
+ /** @brief Start the watch.
+ *
+ * Watch start interface implementation for PropertyWatch.
+ */
+ void start() override;
+
+ /** @brief Run the watch callback method.
+ *
+ * Watch callback interface implementation for PropertyWatch.
+ */
+ void callback(Context ctx) override;
+
+ /** @brief Update properties.
+ *
+ * Subclasses to query the properties specified by the index
+ * and update the cache.
+ *
+ * @param[in] busName - The busname hosting the interface to query.
+ * @param[in] path - The path of the interface to query.
+ * @param[in] interface - The interface to query.
+ */
+ virtual void updateProperties(const std::string& busName,
+ const std::string& path,
+ const std::string& interface) = 0;
+
+ /** @brief Dbus signal callback for PropertiesChanged.
+ *
+ * Subclasses to update the cache.
+ *
+ * @param[in] message - The org.freedesktop.DBus.PropertiesChanged
+ * message.
+ * @param[in] path - The path associated with the message.
+ * @param[in] interface - The interface associated with the message.
+ */
+ virtual void propertiesChanged(sdbusplus::message::message&,
+ const std::string& path,
+ const std::string& interface) = 0;
+
+ /** @brief Dbus signal callback for InterfacesAdded.
+ *
+ * Subclasses to update the cache.
+ *
+ * @param[in] msg - The org.freedesktop.DBus.PropertiesChanged
+ * message.
+ */
+ virtual void interfacesAdded(sdbusplus::message::message& msg) = 0;
+
+ protected:
+ /** @brief Property names and their associated storage. */
+ const PropertyIndex& index;
+
+ /** @brief Optional callback method. */
+ Callback* const cb;
+
+ /** @brief The start method should only be invoked once. */
+ bool alreadyRan;
};
/** @class PropertyWatchOfType
@@ -110,71 +108,67 @@ class PropertyWatch : public Watch
template <typename T, typename DBusInterfaceType>
class PropertyWatchOfType : public PropertyWatch<DBusInterfaceType>
{
- public:
- PropertyWatchOfType() = default;
- PropertyWatchOfType(const PropertyWatchOfType&) = delete;
- PropertyWatchOfType(PropertyWatchOfType&&) = default;
- PropertyWatchOfType& operator=(const PropertyWatchOfType&) = delete;
- PropertyWatchOfType& operator=(PropertyWatchOfType&&) = default;
- ~PropertyWatchOfType() = default;
- PropertyWatchOfType(
- const PropertyIndex& watchIndex, Callback& callback) :
- PropertyWatch<DBusInterfaceType>(watchIndex, &callback) {}
- PropertyWatchOfType(
- const PropertyIndex& watchIndex) :
- PropertyWatch<DBusInterfaceType>(watchIndex, nullptr) {}
-
-
- /** @brief PropertyMatch implementation for PropertyWatchOfType.
- *
- * @param[in] busName - The busname hosting the interface to query.
- * @param[in] path - The path of the interface to query.
- * @param[in] interface - The interface to query.
- */
- void updateProperties(
- const std::string& busName,
- const std::string& path,
- const std::string& interface) override;
-
- /** @brief PropertyMatch implementation for PropertyWatchOfType.
- *
- * @param[in] msg - The org.freedesktop.DBus.PropertiesChanged
- * message.
- * @param[in] path - The path associated with the message.
- * @param[in] interface - The interface associated with the message.
- */
- void propertiesChanged(
- sdbusplus::message::message& msg,
- const std::string& path,
- const std::string& interface) override;
-
- /** @brief DBus agnostic implementation of interfacesAdded.
- *
- * @param[in] path - The path of the properties that changed.
- * @param[in] interface - The interface of the properties that
- * changed.
- * @param[in] properites - The properties that changed.
- */
- void propertiesChanged(
- const std::string& path,
- const std::string& interface,
- const PropertiesChanged<T>& properties);
-
- /** @brief PropertyMatch implementation for PropertyWatchOfType.
- *
- * @param[in] msg - The org.freedesktop.DBus.PropertiesChanged
- * message.
- */
- void interfacesAdded(sdbusplus::message::message& msg) override;
-
- /** @brief DBus agnostic implementation of interfacesAdded.
- *
- * @param[in] path - The path of the added interfaces.
- * @param[in] interfaces - The added interfaces.
- */
- void interfacesAdded(
- const std::string& path,
- const InterfacesAdded<T>& interfaces);
+ public:
+ PropertyWatchOfType() = default;
+ PropertyWatchOfType(const PropertyWatchOfType&) = delete;
+ PropertyWatchOfType(PropertyWatchOfType&&) = default;
+ PropertyWatchOfType& operator=(const PropertyWatchOfType&) = delete;
+ PropertyWatchOfType& operator=(PropertyWatchOfType&&) = default;
+ ~PropertyWatchOfType() = default;
+ PropertyWatchOfType(const PropertyIndex& watchIndex, Callback& callback) :
+ PropertyWatch<DBusInterfaceType>(watchIndex, &callback)
+ {
+ }
+ PropertyWatchOfType(const PropertyIndex& watchIndex) :
+ PropertyWatch<DBusInterfaceType>(watchIndex, nullptr)
+ {
+ }
+
+ /** @brief PropertyMatch implementation for PropertyWatchOfType.
+ *
+ * @param[in] busName - The busname hosting the interface to query.
+ * @param[in] path - The path of the interface to query.
+ * @param[in] interface - The interface to query.
+ */
+ void updateProperties(const std::string& busName, const std::string& path,
+ const std::string& interface) override;
+
+ /** @brief PropertyMatch implementation for PropertyWatchOfType.
+ *
+ * @param[in] msg - The org.freedesktop.DBus.PropertiesChanged
+ * message.
+ * @param[in] path - The path associated with the message.
+ * @param[in] interface - The interface associated with the message.
+ */
+ void propertiesChanged(sdbusplus::message::message& msg,
+ const std::string& path,
+ const std::string& interface) override;
+
+ /** @brief DBus agnostic implementation of interfacesAdded.
+ *
+ * @param[in] path - The path of the properties that changed.
+ * @param[in] interface - The interface of the properties that
+ * changed.
+ * @param[in] properites - The properties that changed.
+ */
+ void propertiesChanged(const std::string& path,
+ const std::string& interface,
+ const PropertiesChanged<T>& properties);
+
+ /** @brief PropertyMatch implementation for PropertyWatchOfType.
+ *
+ * @param[in] msg - The org.freedesktop.DBus.PropertiesChanged
+ * message.
+ */
+ void interfacesAdded(sdbusplus::message::message& msg) override;
+
+ /** @brief DBus agnostic implementation of interfacesAdded.
+ *
+ * @param[in] path - The path of the added interfaces.
+ * @param[in] interfaces - The added interfaces.
+ */
+ void interfacesAdded(const std::string& path,
+ const InterfacesAdded<T>& interfaces);
};
} // namespace monitoring
diff --git a/src/propertywatchimpl.hpp b/src/propertywatchimpl.hpp
index 1f0e4d1..003ee37 100644
--- a/src/propertywatchimpl.hpp
+++ b/src/propertywatchimpl.hpp
@@ -16,8 +16,7 @@ namespace monitoring
using MappedPropertyIndex =
RefKeyMap<const std::string,
- RefKeyMap<const std::string,
- RefVector<const std::string>>>;
+ RefKeyMap<const std::string, RefVector<const std::string>>>;
MappedPropertyIndex convert(const PropertyIndex& index);
@@ -41,11 +40,9 @@ void PropertyWatch<DBusInterfaceType>::start()
// Watch for new interfaces on this path.
DBusInterfaceType::addMatch(
sdbusplus::bus::match::rules::interfacesAdded(path),
- [this](auto & msg)
- // *INDENT-OFF*
- {
- this->interfacesAdded(msg);
- });
+ [this](auto& msg)
+ // *INDENT-OFF*
+ { this->interfacesAdded(msg); });
// *INDENT-ON*
// Do a query to populate the cache. Start with a mapper query.
@@ -53,12 +50,8 @@ void PropertyWatch<DBusInterfaceType>::start()
const std::vector<std::string> queryInterfaces; // all interfaces
auto mapperResp =
DBusInterfaceType::template callMethodAndRead<GetObject>(
- MAPPER_BUSNAME,
- MAPPER_PATH,
- MAPPER_INTERFACE,
- "GetObject",
- path,
- queryInterfaces);
+ MAPPER_BUSNAME, MAPPER_PATH, MAPPER_INTERFACE, "GetObject",
+ path, queryInterfaces);
for (const auto& i : interfaces)
{
@@ -66,9 +59,9 @@ void PropertyWatch<DBusInterfaceType>::start()
// Watch for property changes on this interface.
DBusInterfaceType::addMatch(
- sdbusplus::bus::match::rules::propertiesChanged(
- path, interface),
- [this](auto & msg)
+ sdbusplus::bus::match::rules::propertiesChanged(path,
+ interface),
+ [this](auto& msg)
// *INDENT-OFF*
{
std::string interface;
@@ -76,7 +69,7 @@ void PropertyWatch<DBusInterfaceType>::start()
auto path = msg.get_path();
this->propertiesChanged(msg, path, interface);
});
- // *INDENT-ON*
+ // *INDENT-ON*
// The mapper response is a busname:[interfaces] map. Look for
// each interface in the index and if found, query the service and
@@ -85,10 +78,9 @@ void PropertyWatch<DBusInterfaceType>::start()
{
const auto& busName = mr.first;
const auto& mapperInterfaces = mr.second;
- if (mapperInterfaces.end() == std::find(
- mapperInterfaces.begin(),
- mapperInterfaces.end(),
- interface))
+ if (mapperInterfaces.end() ==
+ std::find(mapperInterfaces.begin(), mapperInterfaces.end(),
+ interface))
{
// This interface isn't being watched.
continue;
@@ -115,24 +107,19 @@ void PropertyWatch<DBusInterfaceType>::callback(Context ctx)
template <typename T, typename DBusInterfaceType>
void PropertyWatchOfType<T, DBusInterfaceType>::updateProperties(
- const std::string& busName,
- const std::string& path,
+ const std::string& busName, const std::string& path,
const std::string& interface)
{
auto properties =
DBusInterfaceType::template callMethodAndRead<PropertiesChanged<T>>(
- busName.c_str(),
- path.c_str(),
- "org.freedesktop.DBus.Properties",
- "GetAll",
- interface);
+ busName.c_str(), path.c_str(), "org.freedesktop.DBus.Properties",
+ "GetAll", interface);
propertiesChanged(path, interface, properties);
}
template <typename T, typename DBusInterfaceType>
void PropertyWatchOfType<T, DBusInterfaceType>::propertiesChanged(
- const std::string& path,
- const std::string& interface,
+ const std::string& path, const std::string& interface,
const PropertiesChanged<T>& properties)
{
// Update the cache for any watched properties.
@@ -147,7 +134,7 @@ void PropertyWatchOfType<T, DBusInterfaceType>::propertiesChanged(
}
std::get<valueIndex>(std::get<storageIndex>(item->second).get()) =
- p.second.template get<T>();
+ p.second.template get<T>();
// Invoke callback if present.
this->callback(Context::SIGNAL);
@@ -156,8 +143,7 @@ void PropertyWatchOfType<T, DBusInterfaceType>::propertiesChanged(
template <typename T, typename DBusInterfaceType>
void PropertyWatchOfType<T, DBusInterfaceType>::propertiesChanged(
- sdbusplus::message::message& msg,
- const std::string& path,
+ sdbusplus::message::message& msg, const std::string& path,
const std::string& interface)
{
PropertiesChanged<T> properties;
@@ -167,8 +153,7 @@ void PropertyWatchOfType<T, DBusInterfaceType>::propertiesChanged(
template <typename T, typename DBusInterfaceType>
void PropertyWatchOfType<T, DBusInterfaceType>::interfacesAdded(
- const std::string& path,
- const InterfacesAdded<T>& interfaces)
+ const std::string& path, const InterfacesAdded<T>& interfaces)
{
for (const auto& i : interfaces)
{
diff --git a/src/resolve_errors.cpp b/src/resolve_errors.cpp
index 54f0b78..47277eb 100644
--- a/src/resolve_errors.cpp
+++ b/src/resolve_errors.cpp
@@ -36,7 +36,7 @@ using EndpointsProperty = sdbusplus::message::variant<EndpointList>;
void ResolveCallout::operator()(Context ctx)
{
- //Resolve all errors for this callout:
+ // Resolve all errors for this callout:
// 1) Read the 'endpoints' property for the callout/fault object
//
// 2) Follow each endpoint to its log entry
@@ -50,21 +50,17 @@ void ResolveCallout::operator()(Context ctx)
if (busName.empty())
{
- //Just means there are no error logs with this callout
+ // Just means there are no error logs with this callout
return;
}
auto endpoints = SDBusPlus::callMethodAndRead<EndpointsProperty>(
- busName,
- path,
- PROPERTY_IFACE,
- "Get",
- ASSOCIATION_IFACE,
- ENDPOINTS_PROPERTY);
+ busName, path, PROPERTY_IFACE, "Get", ASSOCIATION_IFACE,
+ ENDPOINTS_PROPERTY);
const auto& logEntries = endpoints.get<EndpointList>();
- //Resolve each log entry
+ // Resolve each log entry
for (const auto& logEntry : logEntries)
{
resolve(logEntry);
@@ -72,10 +68,9 @@ void ResolveCallout::operator()(Context ctx)
}
catch (const std::exception& e)
{
- log<level::ERR>(
- "Failed getting callout fault associations",
- entry("CALLOUT=%s", callout.c_str()),
- entry("MESSAGE=%s", e.what()));
+ log<level::ERR>("Failed getting callout fault associations",
+ entry("CALLOUT=%s", callout.c_str()),
+ entry("MESSAGE=%s", e.what()));
}
}
@@ -95,28 +90,22 @@ void ResolveCallout::resolve(const std::string& logEntry)
sdbusplus::message::variant<bool> resolved = true;
- auto response = SDBusPlus::callMethod(
- busName,
- logEntry,
- PROPERTY_IFACE,
- "Set",
- LOGGING_IFACE,
- RESOLVED_PROPERTY,
- resolved);
+ auto response =
+ SDBusPlus::callMethod(busName, logEntry, PROPERTY_IFACE, "Set",
+ LOGGING_IFACE, RESOLVED_PROPERTY, resolved);
if (response.is_method_error())
{
log<level::ERR>(
- "Failed to set Resolved property on an error log entry",
- entry("ENTRY=%s", logEntry.c_str()));
+ "Failed to set Resolved property on an error log entry",
+ entry("ENTRY=%s", logEntry.c_str()));
}
}
catch (const std::exception& e)
{
- log<level::ERR>(
- "Unable to resolve error log entry",
- entry("ENTRY=%s", logEntry.c_str()),
- entry("MESSAGE=%s", e.what()));
+ log<level::ERR>("Unable to resolve error log entry",
+ entry("ENTRY=%s", logEntry.c_str()),
+ entry("MESSAGE=%s", e.what()));
}
}
diff --git a/src/resolve_errors.hpp b/src/resolve_errors.hpp
index cae4bbc..c58dc7d 100644
--- a/src/resolve_errors.hpp
+++ b/src/resolve_errors.hpp
@@ -17,48 +17,46 @@ namespace monitoring
*/
class ResolveCallout : public Callback
{
- public:
-
- ResolveCallout() = delete;
- ~ResolveCallout() = default;
- ResolveCallout(const ResolveCallout&) = delete;
- ResolveCallout& operator=(const ResolveCallout&) = delete;
- ResolveCallout(ResolveCallout&&) = default;
- ResolveCallout& operator=(ResolveCallout&&) = default;
-
- /**
- * @brief constructor
- *
- * @param[in] callout - The callout whose errors need to be resolved.
- * Normally an inventory path.
- */
- explicit ResolveCallout(const std::string& callout) :
- callout(callout) {}
-
- /**
- * @brief Callback interface to resolve errors
- *
- * Resolves all error log entries that are associated
- * with the callout.
- */
- void operator()(Context ctx) override;
-
- private:
-
- /**
- * @brief Resolves a single error log entry
- *
- * param[in] entry - the object path of the error log entry
- */
- void resolve(const std::string& entry);
-
- /**
- * @brief The object path of the callout, typically an inventory path
- */
- std::string callout;
+ public:
+ ResolveCallout() = delete;
+ ~ResolveCallout() = default;
+ ResolveCallout(const ResolveCallout&) = delete;
+ ResolveCallout& operator=(const ResolveCallout&) = delete;
+ ResolveCallout(ResolveCallout&&) = default;
+ ResolveCallout& operator=(ResolveCallout&&) = default;
+
+ /**
+ * @brief constructor
+ *
+ * @param[in] callout - The callout whose errors need to be resolved.
+ * Normally an inventory path.
+ */
+ explicit ResolveCallout(const std::string& callout) : callout(callout)
+ {
+ }
+
+ /**
+ * @brief Callback interface to resolve errors
+ *
+ * Resolves all error log entries that are associated
+ * with the callout.
+ */
+ void operator()(Context ctx) override;
+
+ private:
+ /**
+ * @brief Resolves a single error log entry
+ *
+ * param[in] entry - the object path of the error log entry
+ */
+ void resolve(const std::string& entry);
+
+ /**
+ * @brief The object path of the callout, typically an inventory path
+ */
+ std::string callout;
};
-
} // namespace monitoring
} // namespace dbus
} // namespace phosphor
diff --git a/src/sdbusplus.hpp b/src/sdbusplus.hpp
index 1a2c9c2..1b54582 100644
--- a/src/sdbusplus.hpp
+++ b/src/sdbusplus.hpp
@@ -19,116 +19,90 @@ namespace monitoring
*/
class SDBusPlus
{
- private:
- static auto& getWatches()
- {
- static std::vector<sdbusplus::bus::match::match> watches;
- return watches;
- }
+ private:
+ static auto& getWatches()
+ {
+ static std::vector<sdbusplus::bus::match::match> watches;
+ return watches;
+ }
- public:
- static auto& getBus()
- {
- static auto bus = sdbusplus::bus::new_default();
- return bus;
- }
+ public:
+ static auto& getBus()
+ {
+ static auto bus = sdbusplus::bus::new_default();
+ return bus;
+ }
- /** @brief Invoke a method; ignore reply. */
- template <typename ...Args>
- static void callMethodNoReply(
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method,
- Args&& ... args)
- {
- auto reqMsg = getBus().new_method_call(
- busName.c_str(),
- path.c_str(),
- interface.c_str(),
- method.c_str());
- reqMsg.append(std::forward<Args>(args)...);
- getBus().call_noreply(reqMsg);
+ /** @brief Invoke a method; ignore reply. */
+ template <typename... Args>
+ static void callMethodNoReply(const std::string& busName,
+ const std::string& path,
+ const std::string& interface,
+ const std::string& method, Args&&... args)
+ {
+ auto reqMsg = getBus().new_method_call(
+ busName.c_str(), path.c_str(), interface.c_str(), method.c_str());
+ reqMsg.append(std::forward<Args>(args)...);
+ getBus().call_noreply(reqMsg);
- // TODO: openbmc/openbmc#1719
- // invoke these methods async, with a callback
- // handler that checks for errors and logs.
- }
+ // TODO: openbmc/openbmc#1719
+ // invoke these methods async, with a callback
+ // handler that checks for errors and logs.
+ }
- /** @brief Invoke a method. */
- template <typename ...Args>
- static auto callMethod(
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method,
- Args&& ... args)
- {
- auto reqMsg = getBus().new_method_call(
- busName.c_str(),
- path.c_str(),
- interface.c_str(),
- method.c_str());
- reqMsg.append(std::forward<Args>(args)...);
- return getBus().call(reqMsg);
- }
+ /** @brief Invoke a method. */
+ template <typename... Args>
+ static auto callMethod(const std::string& busName, const std::string& path,
+ const std::string& interface,
+ const std::string& method, Args&&... args)
+ {
+ auto reqMsg = getBus().new_method_call(
+ busName.c_str(), path.c_str(), interface.c_str(), method.c_str());
+ reqMsg.append(std::forward<Args>(args)...);
+ return getBus().call(reqMsg);
+ }
- /** @brief Invoke a method and read the response. */
- template <typename Ret, typename ...Args>
- static auto callMethodAndRead(
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method,
- Args&& ... args)
- {
- Ret resp;
- sdbusplus::message::message respMsg =
- callMethod<Args...>(
- busName,
- path,
- interface,
- method,
- std::forward<Args>(args)...);
- respMsg.read(resp);
- return resp;
- }
+ /** @brief Invoke a method and read the response. */
+ template <typename Ret, typename... Args>
+ static auto callMethodAndRead(const std::string& busName,
+ const std::string& path,
+ const std::string& interface,
+ const std::string& method, Args&&... args)
+ {
+ Ret resp;
+ sdbusplus::message::message respMsg = callMethod<Args...>(
+ busName, path, interface, method, std::forward<Args>(args)...);
+ respMsg.read(resp);
+ return resp;
+ }
- /** @brief Register a DBus signal callback. */
- static auto addMatch(
- const std::string& match,
- const sdbusplus::bus::match::match::callback_t& callback)
- {
- getWatches().emplace_back(
- getBus(),
- match,
- callback);
- }
+ /** @brief Register a DBus signal callback. */
+ static auto
+ addMatch(const std::string& match,
+ const sdbusplus::bus::match::match::callback_t& callback)
+ {
+ getWatches().emplace_back(getBus(), match, callback);
+ }
- /** @brief Look up the bus name for a path and interface */
- static auto getBusName(
- const std::string& path,
- const std::string& interface)
- {
- std::vector<std::string> interfaces{interface};
+ /** @brief Look up the bus name for a path and interface */
+ static auto getBusName(const std::string& path,
+ const std::string& interface)
+ {
+ std::vector<std::string> interfaces{interface};
- auto object = callMethodAndRead<GetObject>(
- MAPPER_BUSNAME,
- MAPPER_PATH,
- MAPPER_INTERFACE,
- "GetObject",
- path,
- interfaces);
+ auto object = callMethodAndRead<GetObject>(
+ MAPPER_BUSNAME, MAPPER_PATH, MAPPER_INTERFACE, "GetObject", path,
+ interfaces);
- std::string name;
- if (!object.empty())
- {
- name = object.begin()->first;
- }
- return name;
+ std::string name;
+ if (!object.empty())
+ {
+ name = object.begin()->first;
}
+ return name;
+ }
- friend Loop;
+ friend Loop;
};
} // namespace monitoring
diff --git a/src/sdevent.hpp b/src/sdevent.hpp
index dc912c1..4fed159 100644
--- a/src/sdevent.hpp
+++ b/src/sdevent.hpp
@@ -17,22 +17,22 @@ namespace monitoring
*/
class SDEvent
{
- protected:
- /** @brief Share a single event loop amongst users. */
- static auto& getEvent()
- {
- static auto event = sdevent::event::newDefault();
- return event;
- }
+ protected:
+ /** @brief Share a single event loop amongst users. */
+ static auto& getEvent()
+ {
+ static auto event = sdevent::event::newDefault();
+ return event;
+ }
- public:
- /** @brief Wrapper for sd_event_now. */
- static auto now()
- {
- return getEvent().now();
- }
+ public:
+ /** @brief Wrapper for sd_event_now. */
+ static auto now()
+ {
+ return getEvent().now();
+ }
- friend Loop;
+ friend Loop;
};
/** @class SDEventTimer
@@ -40,45 +40,46 @@ class SDEvent
*/
class SDEventTimer : public SDEvent
{
- public:
- SDEventTimer() = delete;
- SDEventTimer(const SDEventTimer&) = default;
- SDEventTimer(SDEventTimer&&) = default;
- SDEventTimer& operator=(const SDEventTimer&) = default;
- SDEventTimer& operator=(SDEventTimer&&) = default;
- ~SDEventTimer() = default;
+ public:
+ SDEventTimer() = delete;
+ SDEventTimer(const SDEventTimer&) = default;
+ SDEventTimer(SDEventTimer&&) = default;
+ SDEventTimer& operator=(const SDEventTimer&) = default;
+ SDEventTimer& operator=(SDEventTimer&&) = default;
+ ~SDEventTimer() = default;
- explicit SDEventTimer(
- const sdevent::event::timer::Timer::Callback& callback)
- : timer(getEvent(), callback) {}
+ explicit SDEventTimer(
+ const sdevent::event::timer::Timer::Callback& callback) :
+ timer(getEvent(), callback)
+ {
+ }
- /** @brief Update a timer expiration. */
- void update(
- const std::chrono::steady_clock::time_point& expires)
- {
- timer.setTime(expires);
- }
+ /** @brief Update a timer expiration. */
+ void update(const std::chrono::steady_clock::time_point& expires)
+ {
+ timer.setTime(expires);
+ }
- /** @brief Query timer state. */
- auto enabled()
- {
- return timer.enabled() != SD_EVENT_OFF;
- }
+ /** @brief Query timer state. */
+ auto enabled()
+ {
+ return timer.enabled() != SD_EVENT_OFF;
+ }
- /** @brief Enable a timer. */
- void enable()
- {
- timer.enable(SD_EVENT_ONESHOT);
- }
+ /** @brief Enable a timer. */
+ void enable()
+ {
+ timer.enable(SD_EVENT_ONESHOT);
+ }
- /** @brief Disable a timer. */
- void disable()
- {
- timer.enable(SD_EVENT_OFF);
- }
+ /** @brief Disable a timer. */
+ void disable()
+ {
+ timer.enable(SD_EVENT_OFF);
+ }
- private:
- sdevent::event::timer::Timer timer;
+ private:
+ sdevent::event::timer::Timer timer;
};
} // namespace monitoring
diff --git a/src/sdevent/event.hpp b/src/sdevent/event.hpp
index 5462202..f47c05d 100644
--- a/src/sdevent/event.hpp
+++ b/src/sdevent/event.hpp
@@ -49,84 +49,81 @@ using Event = std::unique_ptr<sd_event, EventDeleter>;
*/
class Event
{
- public:
- /* Define all of the basic class operations:
- * Not allowed:
- * - Default constructor to avoid nullptrs.
- * - Copy operations due to internal unique_ptr.
- * Allowed:
- * - Move operations.
- * - Destructor.
- */
- Event() = delete;
- Event(const Event&) = delete;
- Event& operator=(const Event&) = delete;
- Event(Event&&) = default;
- Event& operator=(Event&&) = default;
- ~Event() = default;
-
- /** @brief Conversion constructor from 'EventPtr'.
- *
- * Increments ref-count of the event-pointer and releases it when
- * done.
- */
- explicit Event(EventPtr e);
-
- /** @brief Constructor for 'Event'.
- *
- * Takes ownership of the event-pointer and releases it when done.
- */
- Event(EventPtr e, std::false_type);
-
- /** @brief Release ownership of the stored event-pointer. */
- EventPtr release()
- {
- return evt.release();
- }
-
- /** @brief Wait indefinitely for new event sources. */
- void loop()
- {
- sd_event_loop(evt.get());
- }
-
- /** @brief Attach to a DBus loop. */
- void attach(sdbusplus::bus::bus& bus)
- {
- bus.attach_event(evt.get(), SD_EVENT_PRIORITY_NORMAL);
- }
-
- /** @brief C++ wrapper for sd_event_now. */
- auto now()
- {
- using namespace std::chrono;
-
- uint64_t usec;
- sd_event_now(evt.get(), CLOCK_MONOTONIC, &usec);
- microseconds d(usec);
- return steady_clock::time_point(d);
- }
-
- friend class timer::Timer;
-
- private:
-
- EventPtr get()
- {
- return evt.get();
- }
-
- details::Event evt;
+ public:
+ /* Define all of the basic class operations:
+ * Not allowed:
+ * - Default constructor to avoid nullptrs.
+ * - Copy operations due to internal unique_ptr.
+ * Allowed:
+ * - Move operations.
+ * - Destructor.
+ */
+ Event() = delete;
+ Event(const Event&) = delete;
+ Event& operator=(const Event&) = delete;
+ Event(Event&&) = default;
+ Event& operator=(Event&&) = default;
+ ~Event() = default;
+
+ /** @brief Conversion constructor from 'EventPtr'.
+ *
+ * Increments ref-count of the event-pointer and releases it when
+ * done.
+ */
+ explicit Event(EventPtr e);
+
+ /** @brief Constructor for 'Event'.
+ *
+ * Takes ownership of the event-pointer and releases it when done.
+ */
+ Event(EventPtr e, std::false_type);
+
+ /** @brief Release ownership of the stored event-pointer. */
+ EventPtr release()
+ {
+ return evt.release();
+ }
+
+ /** @brief Wait indefinitely for new event sources. */
+ void loop()
+ {
+ sd_event_loop(evt.get());
+ }
+
+ /** @brief Attach to a DBus loop. */
+ void attach(sdbusplus::bus::bus& bus)
+ {
+ bus.attach_event(evt.get(), SD_EVENT_PRIORITY_NORMAL);
+ }
+
+ /** @brief C++ wrapper for sd_event_now. */
+ auto now()
+ {
+ using namespace std::chrono;
+
+ uint64_t usec;
+ sd_event_now(evt.get(), CLOCK_MONOTONIC, &usec);
+ microseconds d(usec);
+ return steady_clock::time_point(d);
+ }
+
+ friend class timer::Timer;
+
+ private:
+ EventPtr get()
+ {
+ return evt.get();
+ }
+
+ details::Event evt;
};
inline Event::Event(EventPtr l) : evt(sd_event_ref(l))
{
-
}
inline Event::Event(EventPtr l, std::false_type) : evt(l)
{
-
}
inline Event newDefault()
diff --git a/src/sdevent/source.hpp b/src/sdevent/source.hpp
index 812f0a3..4f837be 100644
--- a/src/sdevent/source.hpp
+++ b/src/sdevent/source.hpp
@@ -37,77 +37,80 @@ using source = std::unique_ptr<sd_event_source, SourceDeleter>;
*/
class Source
{
- public:
- /* Define all of the basic class operations:
- * Not allowed:
- * - Default constructor to avoid nullptrs.
- * - Copy operations due to internal unique_ptr.
- * Allowed:
- * - Move operations.
- * - Destructor.
- */
- Source() = delete;
- Source(const Source&) = delete;
- Source& operator=(const Source&) = delete;
- Source(Source&&) = default;
- Source& operator=(Source&&) = default;
- ~Source() = default;
-
- /** @brief Conversion constructor from 'SourcePtr'.
- *
- * Increments ref-count of the source-pointer and releases it
- * when done.
- */
- explicit Source(SourcePtr s) : src(sd_event_source_ref(s)) {}
-
- /** @brief Constructor for 'source'.
- *
- * Takes ownership of the source-pointer and releases it when done.
- */
- Source(SourcePtr s, std::false_type) : src(s) {}
-
- /** @brief Check if source contains a real pointer. (non-nullptr). */
- explicit operator bool() const
- {
- return bool(src);
- }
-
- /** @brief Test whether or not the source can generate events. */
- auto enabled()
- {
- int enabled;
- sd_event_source_get_enabled(src.get(), &enabled);
- return enabled;
- }
-
- /** @brief Allow the source to generate events. */
- void enable(int enable)
- {
- sd_event_source_set_enabled(src.get(), enable);
- }
-
- /** @brief Set the expiration on a timer source. */
- void setTime(
- const std::chrono::steady_clock::time_point& expires)
- {
- using namespace std::chrono;
- auto epoch = expires.time_since_epoch();
- auto time = duration_cast<microseconds>(epoch);
- sd_event_source_set_time(src.get(), time.count());
- }
-
- /** @brief Get the expiration on a timer source. */
- auto getTime()
- {
- using namespace std::chrono;
- uint64_t usec;
- sd_event_source_get_time(src.get(), &usec);
- microseconds d(usec);
- return steady_clock::time_point(d);
- }
-
- private:
- details::source src;
+ public:
+ /* Define all of the basic class operations:
+ * Not allowed:
+ * - Default constructor to avoid nullptrs.
+ * - Copy operations due to internal unique_ptr.
+ * Allowed:
+ * - Move operations.
+ * - Destructor.
+ */
+ Source() = delete;
+ Source(const Source&) = delete;
+ Source& operator=(const Source&) = delete;
+ Source(Source&&) = default;
+ Source& operator=(Source&&) = default;
+ ~Source() = default;
+
+ /** @brief Conversion constructor from 'SourcePtr'.
+ *
+ * Increments ref-count of the source-pointer and releases it
+ * when done.
+ */
+ explicit Source(SourcePtr s) : src(sd_event_source_ref(s))
+ {
+ }
+
+ /** @brief Constructor for 'source'.
+ *
+ * Takes ownership of the source-pointer and releases it when done.
+ */
+ Source(SourcePtr s, std::false_type) : src(s)
+ {
+ }
+
+ /** @brief Check if source contains a real pointer. (non-nullptr). */
+ explicit operator bool() const
+ {
+ return bool(src);
+ }
+
+ /** @brief Test whether or not the source can generate events. */
+ auto enabled()
+ {
+ int enabled;
+ sd_event_source_get_enabled(src.get(), &enabled);
+ return enabled;
+ }
+
+ /** @brief Allow the source to generate events. */
+ void enable(int enable)
+ {
+ sd_event_source_set_enabled(src.get(), enable);
+ }
+
+ /** @brief Set the expiration on a timer source. */
+ void setTime(const std::chrono::steady_clock::time_point& expires)
+ {
+ using namespace std::chrono;
+ auto epoch = expires.time_since_epoch();
+ auto time = duration_cast<microseconds>(epoch);
+ sd_event_source_set_time(src.get(), time.count());
+ }
+
+ /** @brief Get the expiration on a timer source. */
+ auto getTime()
+ {
+ using namespace std::chrono;
+ uint64_t usec;
+ sd_event_source_get_time(src.get(), &usec);
+ microseconds d(usec);
+ return steady_clock::time_point(d);
+ }
+
+ private:
+ details::source src;
};
} // namespace source
} // namespace sdevent
diff --git a/src/sdevent/timer.hpp b/src/sdevent/timer.hpp
index 863e725..5e45b94 100644
--- a/src/sdevent/timer.hpp
+++ b/src/sdevent/timer.hpp
@@ -22,117 +22,99 @@ namespace timer
*/
class Timer
{
- public:
- /* Define all of the basic class operations:
- * Not allowed:
- * - Default constructor to avoid nullptrs.
- * - Copy operations due to internal unique_ptr.
- * Allowed:
- * - Move operations.
- * - Destructor.
- */
- Timer() = delete;
- Timer(const Timer&) = delete;
- Timer& operator=(const Timer&) = delete;
- Timer(Timer&&) = default;
- Timer& operator=(Timer&&) = default;
- ~Timer() = default;
+ public:
+ /* Define all of the basic class operations:
+ * Not allowed:
+ * - Default constructor to avoid nullptrs.
+ * - Copy operations due to internal unique_ptr.
+ * Allowed:
+ * - Move operations.
+ * - Destructor.
+ */
+ Timer() = delete;
+ Timer(const Timer&) = delete;
+ Timer& operator=(const Timer&) = delete;
+ Timer(Timer&&) = default;
+ Timer& operator=(Timer&&) = default;
+ ~Timer() = default;
- using Callback = std::function<void(source::Source&)>;
+ using Callback = std::function<void(source::Source&)>;
- /** @brief Register a timer callback.
- *
- * @param[in] event - The event to register on.
- * @param[in] expires - The initial timer expiration time.
- * @param[in] callback - The callback method.
- */
- Timer(
- sdevent::event::Event& event,
- const std::chrono::steady_clock::time_point& expires,
- Callback callback)
- : src(nullptr),
- cb(std::make_unique<Callback>(std::move(callback)))
- {
- using namespace std::chrono;
- auto epoch = expires.time_since_epoch();
- auto time = duration_cast<microseconds>(epoch);
- sd_event_source* source = nullptr;
- sd_event_add_time(
- event.get(),
- &source,
- CLOCK_MONOTONIC,
- time.count(),
- 0,
- callCallback,
- cb.get());
-// **INDENT-OFF**
- src = decltype(src){source, std::false_type()};
-// **INDENT-ON**
- }
+ /** @brief Register a timer callback.
+ *
+ * @param[in] event - The event to register on.
+ * @param[in] expires - The initial timer expiration time.
+ * @param[in] callback - The callback method.
+ */
+ Timer(sdevent::event::Event& event,
+ const std::chrono::steady_clock::time_point& expires,
+ Callback callback) :
+ src(nullptr),
+ cb(std::make_unique<Callback>(std::move(callback)))
+ {
+ using namespace std::chrono;
+ auto epoch = expires.time_since_epoch();
+ auto time = duration_cast<microseconds>(epoch);
+ sd_event_source* source = nullptr;
+ sd_event_add_time(event.get(), &source, CLOCK_MONOTONIC, time.count(),
+ 0, callCallback, cb.get());
+ // **INDENT-OFF**
+ src = decltype(src){source, std::false_type()};
+ // **INDENT-ON**
+ }
- /** @brief Register a disabled timer callback.
- *
- * @param[in] event - The event to register on.
- * @param[in] callback - The callback method.
- */
- Timer(
- sdevent::event::Event& event,
- Callback callback)
- : src(nullptr),
- cb(std::make_unique<Callback>(std::move(callback)))
- {
- sd_event_source* source = nullptr;
- sd_event_add_time(
- event.get(),
- &source,
- CLOCK_MONOTONIC,
- ULLONG_MAX,
- 0,
- callCallback,
- cb.get());
-// **INDENT-OFF**
- src = decltype(src){source, std::false_type()};
-// **INDENT-ON**
- }
+ /** @brief Register a disabled timer callback.
+ *
+ * @param[in] event - The event to register on.
+ * @param[in] callback - The callback method.
+ */
+ Timer(sdevent::event::Event& event, Callback callback) :
+ src(nullptr), cb(std::make_unique<Callback>(std::move(callback)))
+ {
+ sd_event_source* source = nullptr;
+ sd_event_add_time(event.get(), &source, CLOCK_MONOTONIC, ULLONG_MAX, 0,
+ callCallback, cb.get());
+ // **INDENT-OFF**
+ src = decltype(src){source, std::false_type()};
+ // **INDENT-ON**
+ }
- /** @brief Set the timer expiration time. */
- void setTime(
- const std::chrono::steady_clock::time_point& expires)
- {
- src.setTime(expires);
- }
+ /** @brief Set the timer expiration time. */
+ void setTime(const std::chrono::steady_clock::time_point& expires)
+ {
+ src.setTime(expires);
+ }
- /** @brief Get the timer expiration time. */
- auto getTime()
- {
- return src.getTime();
- }
+ /** @brief Get the timer expiration time. */
+ auto getTime()
+ {
+ return src.getTime();
+ }
- /** @brief Set the timer source enable state. */
- void enable(int enable)
- {
- src.enable(enable);
- }
+ /** @brief Set the timer source enable state. */
+ void enable(int enable)
+ {
+ src.enable(enable);
+ }
- /** @brief Query timer state. */
- auto enabled()
- {
- return src.enabled();
- }
+ /** @brief Query timer state. */
+ auto enabled()
+ {
+ return src.enabled();
+ }
- private:
- source::Source src;
- std::unique_ptr<Callback> cb = nullptr;
+ private:
+ source::Source src;
+ std::unique_ptr<Callback> cb = nullptr;
- static int callCallback(sd_event_source* s, uint64_t usec,
- void* context)
- {
- source::Source source(s);
- auto c = static_cast<Callback*>(context);
- (*c)(source);
+ static int callCallback(sd_event_source* s, uint64_t usec, void* context)
+ {
+ source::Source source(s);
+ auto c = static_cast<Callback*>(context);
+ (*c)(source);
- return 0;
- }
+ return 0;
+ }
};
} // namespace timer
} // namespace event
diff --git a/src/test/callbackgentest.cpp b/src/test/callbackgentest.cpp
index 77fe60a..cda665d 100644
--- a/src/test/callbackgentest.cpp
+++ b/src/test/callbackgentest.cpp
@@ -9,15 +9,12 @@ using Index = std::map<std::tuple<size_t, size_t, size_t>, size_t>;
#include "callbackgentest.hpp"
-const std::array<std::tuple<std::string, size_t>, 4> expectedCallbacks =
-{
- {
- std::tuple<std::string, size_t>{"int32_t", 0},
- std::tuple<std::string, size_t>{"int32_t", 0},
- std::tuple<std::string, size_t>{"std::string", 1},
- std::tuple<std::string, size_t>{"std::string", 2},
- }
-};
+const std::array<std::tuple<std::string, size_t>, 4> expectedCallbacks = {{
+ std::tuple<std::string, size_t>{"int32_t", 0},
+ std::tuple<std::string, size_t>{"int32_t", 0},
+ std::tuple<std::string, size_t>{"std::string", 1},
+ std::tuple<std::string, size_t>{"std::string", 2},
+}};
TEST(CallbackGenTest, CallbacksSameSize)
{
@@ -29,7 +26,6 @@ TEST(CallbackGenTest, CallbacksSameContent)
size_t i;
for (i = 0; i < expectedCallbacks.size(); ++i)
{
- ASSERT_EQ(callbacks[i],
- expectedCallbacks[i]);
+ ASSERT_EQ(callbacks[i], expectedCallbacks[i]);
}
}
diff --git a/src/test/callbackgroupgentest.cpp b/src/test/callbackgroupgentest.cpp
index 3112295..fe760ec 100644
--- a/src/test/callbackgroupgentest.cpp
+++ b/src/test/callbackgroupgentest.cpp
@@ -8,12 +8,11 @@ using namespace phosphor::dbus::monitoring;
#include "callbackgroupgentest.hpp"
const std::array<std::vector<size_t>, 4> expectedGroups = {{
- {0, 1, 2, 3},
- {0, 1, 4},
- {2, 6, 7},
- {7},
- }
-};
+ {0, 1, 2, 3},
+ {0, 1, 4},
+ {2, 6, 7},
+ {7},
+}};
TEST(CallbackGroupGenTest, GroupsSameSize)
{
@@ -25,7 +24,6 @@ TEST(CallbackGroupGenTest, GroupsSameContent)
size_t i;
for (i = 0; i < expectedGroups.size(); ++i)
{
- ASSERT_EQ(groups[i],
- expectedGroups[i]);
+ ASSERT_EQ(groups[i], expectedGroups[i]);
}
}
diff --git a/src/test/conditiongentest.cpp b/src/test/conditiongentest.cpp
index 76ea608..d0df215 100644
--- a/src/test/conditiongentest.cpp
+++ b/src/test/conditiongentest.cpp
@@ -7,16 +7,12 @@ using namespace phosphor::dbus::monitoring;
#include "conditiongentest.hpp"
-const std::array<std::vector<size_t>, 2> expectedGroups =
-{
- {
- {0},
- {1},
- }
-};
+const std::array<std::vector<size_t>, 2> expectedGroups = {{
+ {0},
+ {1},
+}};
-const std::array<size_t, 4> expectedCallbacks =
-{
+const std::array<size_t, 4> expectedCallbacks = {
0,
0,
1,
@@ -38,8 +34,7 @@ TEST(ConditionGenTest, GroupsSameContent)
size_t i;
for (i = 0; i < expectedGroups.size(); ++i)
{
- ASSERT_EQ(groups[i],
- expectedGroups[i]);
+ ASSERT_EQ(groups[i], expectedGroups[i]);
}
}
@@ -48,7 +43,6 @@ TEST(ConditionGenTest, CallbacksSameContent)
size_t i;
for (i = 0; i < expectedCallbacks.size(); ++i)
{
- ASSERT_EQ(callbacks[i],
- expectedCallbacks[i]);
+ ASSERT_EQ(callbacks[i], expectedCallbacks[i]);
}
}
diff --git a/src/test/pathgentest.cpp b/src/test/pathgentest.cpp
index d13c82e..1f75153 100644
--- a/src/test/pathgentest.cpp
+++ b/src/test/pathgentest.cpp
@@ -9,15 +9,13 @@ using PathMeta = TupleOfRefs<const std::string, const std::string>;
#include "pathgentest.hpp"
-const std::array<std::string, 3> expectedMeta =
-{
+const std::array<std::string, 3> expectedMeta = {
"PATH1"s,
"PATH3"s,
"PATH2"s,
};
-const std::array<std::string, 6> expectedPaths =
-{
+const std::array<std::string, 6> expectedPaths = {
"/xyz/openbmc_project/testing/inst1"s,
"/xyz/openbmc_project/testing/inst2"s,
"/xyz/openbmc_project/testing/inst3"s,
@@ -26,55 +24,49 @@ const std::array<std::string, 6> expectedPaths =
"/xyz/openbmc_project/testing/inst6"s,
};
-const std::array<PathMeta, 14> expectedPathMeta =
-{
+const std::array<PathMeta, 14> expectedPathMeta = {{
+ PathMeta{paths[0], meta[0]},
+ PathMeta{paths[1], meta[0]},
+ PathMeta{paths[2], meta[0]},
+ PathMeta{paths[3], meta[0]},
+ PathMeta{paths[0], meta[1]},
+ PathMeta{paths[1], meta[1]},
+ PathMeta{paths[2], meta[1]},
+ PathMeta{paths[3], meta[1]},
+ PathMeta{paths[4], meta[0]},
+ PathMeta{paths[5], meta[0]},
+ PathMeta{paths[3], meta[2]},
+ PathMeta{paths[2], meta[2]},
+ PathMeta{paths[1], meta[2]},
+ PathMeta{paths[0], meta[2]},
+}};
+
+const std::array<RefVector<const std::string>, 4> expectedGroups = {{
{
- PathMeta{ paths[0], meta[0] },
- PathMeta{ paths[1], meta[0] },
- PathMeta{ paths[2], meta[0] },
- PathMeta{ paths[3], meta[0] },
- PathMeta{ paths[0], meta[1] },
- PathMeta{ paths[1], meta[1] },
- PathMeta{ paths[2], meta[1] },
- PathMeta{ paths[3], meta[1] },
- PathMeta{ paths[4], meta[0] },
- PathMeta{ paths[5], meta[0] },
- PathMeta{ paths[3], meta[2] },
- PathMeta{ paths[2], meta[2] },
- PathMeta{ paths[1], meta[2] },
- PathMeta{ paths[0], meta[2] },
- }
-};
-
-const std::array<RefVector<const std::string>, 4> expectedGroups =
-{
+ paths[0],
+ paths[1],
+ paths[2],
+ paths[3],
+ },
{
- {
- paths[0],
- paths[1],
- paths[2],
- paths[3],
- },
- {
- paths[0],
- paths[1],
- paths[2],
- paths[3],
- },
- {
- paths[0],
- paths[1],
- paths[4],
- paths[5],
- },
- {
- paths[3],
- paths[2],
- paths[1],
- paths[0],
- },
- }
-};
+ paths[0],
+ paths[1],
+ paths[2],
+ paths[3],
+ },
+ {
+ paths[0],
+ paths[1],
+ paths[4],
+ paths[5],
+ },
+ {
+ paths[3],
+ paths[2],
+ paths[1],
+ paths[0],
+ },
+}};
TEST(PathGenTest, MetaSameSize)
{
@@ -138,7 +130,6 @@ TEST(PathGenTest, GroupsSameContent)
for (j = 0; j < groups[i].size(); ++j)
{
ASSERT_EQ(groups[i][j].get(), expectedGroups[i][j].get());
-
}
}
}
diff --git a/src/test/propertygentest.cpp b/src/test/propertygentest.cpp
index e5c95c2..d17f6a1 100644
--- a/src/test/propertygentest.cpp
+++ b/src/test/propertygentest.cpp
@@ -7,62 +7,52 @@ using namespace std::string_literals;
using namespace phosphor::dbus::monitoring;
using Property =
- TupleOfRefs <
- const std::string,
- const std::string,
- const std::string >;
+ TupleOfRefs<const std::string, const std::string, const std::string>;
using GroupOfProperties = std::vector<Property>;
#include "propertygentest.hpp"
-const std::array<std::string, 3> expectedMeta =
-{
+const std::array<std::string, 3> expectedMeta = {
"PROPERTY1"s,
"PROPERTY2"s,
"PROPERTY3"s,
};
-const std::array<std::string, 4> expectedInterfaces =
-{
+const std::array<std::string, 4> expectedInterfaces = {
"xyz.openbmc_project.Test.Iface3"s,
"xyz.openbmc_project.Test.Iface2"s,
"xyz.openbmc_project.Test.Iface6"s,
"xyz.openbmc_project.Test.Iface1"s,
};
-const std::array<std::string, 4> expectedProperties =
-{
+const std::array<std::string, 4> expectedProperties = {
"Foo"s,
"Value"s,
"Bar"s,
"Baz"s,
};
-const std::array<GroupOfProperties, 4> expectedGroups =
-{
+const std::array<GroupOfProperties, 4> expectedGroups = {{
{
- {
- Property{ interfaces[0], properties[0], meta[0] },
- Property{ interfaces[1], properties[1], meta[1] },
- },
- {
- Property{ interfaces[0], properties[2], meta[0] },
- Property{ interfaces[1], properties[0], meta[1] },
- },
- {
- Property{ interfaces[2], properties[0], meta[0] },
- Property{ interfaces[3], properties[1], meta[1] },
- },
- {
- Property{ interfaces[0], properties[2], meta[0] },
- Property{ interfaces[1], properties[1], meta[1] },
- Property{ interfaces[2], properties[3], meta[2] },
- },
- }
-};
+ Property{interfaces[0], properties[0], meta[0]},
+ Property{interfaces[1], properties[1], meta[1]},
+ },
+ {
+ Property{interfaces[0], properties[2], meta[0]},
+ Property{interfaces[1], properties[0], meta[1]},
+ },
+ {
+ Property{interfaces[2], properties[0], meta[0]},
+ Property{interfaces[3], properties[1], meta[1]},
+ },
+ {
+ Property{interfaces[0], properties[2], meta[0]},
+ Property{interfaces[1], properties[1], meta[1]},
+ Property{interfaces[2], properties[3], meta[2]},
+ },
+}};
-const std::array<std::string, 4> expectedTypes =
-{
+const std::array<std::string, 4> expectedTypes = {
"uint32_t"s,
"int32_t"s,
"std::string"s,
@@ -99,8 +89,7 @@ TEST(PropertyGenTest, MetaSameContent)
size_t i;
for (i = 0; i < expectedMeta.size(); ++i)
{
- ASSERT_EQ(meta[i],
- expectedMeta[i]);
+ ASSERT_EQ(meta[i], expectedMeta[i]);
}
}
@@ -109,8 +98,7 @@ TEST(PropertyGenTest, IfacesSameContent)
size_t i;
for (i = 0; i < expectedInterfaces.size(); ++i)
{
- ASSERT_EQ(interfaces[i],
- expectedInterfaces[i]);
+ ASSERT_EQ(interfaces[i], expectedInterfaces[i]);
}
}
@@ -135,7 +123,8 @@ TEST(PropertyGenTest, GroupsSameContent)
const auto& actualIface = std::get<0>(groups[i][j]).get();
ASSERT_EQ(expectedIface, actualIface);
- const auto& expectedProperty = std::get<1>(expectedGroups[i][j]).get();
+ const auto& expectedProperty =
+ std::get<1>(expectedGroups[i][j]).get();
const auto& actualProperty = std::get<1>(groups[i][j]).get();
ASSERT_EQ(expectedProperty, actualProperty);
diff --git a/src/test/propertywatchgentest.cpp b/src/test/propertywatchgentest.cpp
index 5973f92..2e446a4 100644
--- a/src/test/propertywatchgentest.cpp
+++ b/src/test/propertywatchgentest.cpp
@@ -12,48 +12,42 @@ using Index = std::map<std::tuple<size_t, size_t, size_t>, size_t>;
auto expectedStorageCount = 16;
-const std::array<Index, 4> expectedIndicies =
-{
+const std::array<Index, 4> expectedIndicies = {{
{
- {
- {Index::key_type{0, 0, 0}, 0},
- {Index::key_type{0, 1, 0}, 1},
- {Index::key_type{1, 0, 0}, 2},
- {Index::key_type{1, 1, 0}, 3},
- {Index::key_type{2, 0, 0}, 4},
- {Index::key_type{2, 1, 0}, 5},
- {Index::key_type{3, 0, 0}, 6},
- {Index::key_type{3, 1, 0}, 7},
- },
- {
- {Index::key_type{2, 2, 1}, 8},
- {Index::key_type{2, 2, 2}, 9},
- {Index::key_type{3, 2, 1}, 10},
- {Index::key_type{3, 2, 2}, 11},
- {Index::key_type{4, 2, 1}, 12},
- {Index::key_type{4, 2, 2}, 13},
- {Index::key_type{5, 2, 1}, 14},
- {Index::key_type{5, 2, 2}, 15},
- },
- {
- {Index::key_type{3, 0, 0}, 6},
- },
- {
- {Index::key_type{3, 2, 2}, 11},
- {Index::key_type{5, 2, 2}, 15},
- },
- }
-};
-
-const std::array<std::tuple<std::string, size_t>, 4> expectedWatches =
-{
+ {Index::key_type{0, 0, 0}, 0},
+ {Index::key_type{0, 1, 0}, 1},
+ {Index::key_type{1, 0, 0}, 2},
+ {Index::key_type{1, 1, 0}, 3},
+ {Index::key_type{2, 0, 0}, 4},
+ {Index::key_type{2, 1, 0}, 5},
+ {Index::key_type{3, 0, 0}, 6},
+ {Index::key_type{3, 1, 0}, 7},
+ },
{
- std::tuple<std::string, size_t>{"std::string"s, 0},
- std::tuple<std::string, size_t>{"uint32_t"s, 1},
- std::tuple<std::string, size_t>{"int32_t"s, 2},
- std::tuple<std::string, size_t>{"std::string"s, 3},
- }
-};
+ {Index::key_type{2, 2, 1}, 8},
+ {Index::key_type{2, 2, 2}, 9},
+ {Index::key_type{3, 2, 1}, 10},
+ {Index::key_type{3, 2, 2}, 11},
+ {Index::key_type{4, 2, 1}, 12},
+ {Index::key_type{4, 2, 2}, 13},
+ {Index::key_type{5, 2, 1}, 14},
+ {Index::key_type{5, 2, 2}, 15},
+ },
+ {
+ {Index::key_type{3, 0, 0}, 6},
+ },
+ {
+ {Index::key_type{3, 2, 2}, 11},
+ {Index::key_type{5, 2, 2}, 15},
+ },
+}};
+
+const std::array<std::tuple<std::string, size_t>, 4> expectedWatches = {{
+ std::tuple<std::string, size_t>{"std::string"s, 0},
+ std::tuple<std::string, size_t>{"uint32_t"s, 1},
+ std::tuple<std::string, size_t>{"int32_t"s, 2},
+ std::tuple<std::string, size_t>{"std::string"s, 3},
+}};
TEST(PropertyWatchGenTest, storageCount)
{
@@ -75,8 +69,7 @@ TEST(PropertyWatchGenTest, WatchesSameContent)
size_t i;
for (i = 0; i < expectedWatches.size(); ++i)
{
- ASSERT_EQ(watches[i],
- expectedWatches[i]);
+ ASSERT_EQ(watches[i], expectedWatches[i]);
}
}
@@ -85,7 +78,6 @@ TEST(PropertyWatchGenTest, IndiciesSameContent)
size_t i;
for (i = 0; i < expectedIndicies.size(); ++i)
{
- ASSERT_EQ(indices[i],
- expectedIndicies[i]);
+ ASSERT_EQ(indices[i], expectedIndicies[i]);
}
}
diff --git a/src/test/propertywatchtest.cpp b/src/test/propertywatchtest.cpp
index c97e8d3..6576bfd 100644
--- a/src/test/propertywatchtest.cpp
+++ b/src/test/propertywatchtest.cpp
@@ -5,75 +5,56 @@
using namespace std::string_literals;
using namespace phosphor::dbus::monitoring;
-const std::array<std::string, 4> paths =
-{
+const std::array<std::string, 4> paths = {
"/xyz/openbmc_project/testing/inst1"s,
"/xyz/openbmc_project/testing/inst2"s,
"/xyz/openbmc_project/testing/inst3"s,
"/xyz/openbmc_project/testing/inst4"s,
};
-const std::array<std::string, 2> interfaces =
-{
+const std::array<std::string, 2> interfaces = {
"xyz.openbmc_project.Iface1"s,
"xyz.openbmc_project.Iface2"s,
};
-const std::array<std::string, 2> properties =
-{
+const std::array<std::string, 2> properties = {
"Value1"s,
"Value2"s,
};
const std::string meta;
-std::array<std::tuple<any_ns::any, any_ns::any>, 8> storage = { };
+std::array<std::tuple<any_ns::any, any_ns::any>, 8> storage = {};
-const PropertyIndex watchIndex =
-{
+const PropertyIndex watchIndex = {
{
- {
- PropertyIndex::key_type{paths[0], interfaces[0], properties[0]},
- PropertyIndex::mapped_type{meta, meta, storage[0]}
- },
- {
- PropertyIndex::key_type{paths[0], interfaces[1], properties[1]},
- PropertyIndex::mapped_type{meta, meta, storage[1]}
- },
- {
- PropertyIndex::key_type{paths[1], interfaces[0], properties[0]},
- PropertyIndex::mapped_type{meta, meta, storage[2]}
- },
- {
- PropertyIndex::key_type{paths[1], interfaces[1], properties[1]},
- PropertyIndex::mapped_type{meta, meta, storage[3]}
- },
- {
- PropertyIndex::key_type{paths[2], interfaces[0], properties[0]},
- PropertyIndex::mapped_type{meta, meta, storage[4]}
- },
- {
- PropertyIndex::key_type{paths[2], interfaces[1], properties[1]},
- PropertyIndex::mapped_type{meta, meta, storage[5]}
- },
- {
- PropertyIndex::key_type{paths[3], interfaces[0], properties[0]},
- PropertyIndex::mapped_type{meta, meta, storage[6]}
- },
- {
- PropertyIndex::key_type{paths[3], interfaces[1], properties[1]},
- PropertyIndex::mapped_type{meta, meta, storage[7]}
- },
+ {PropertyIndex::key_type{paths[0], interfaces[0], properties[0]},
+ PropertyIndex::mapped_type{meta, meta, storage[0]}},
+ {PropertyIndex::key_type{paths[0], interfaces[1], properties[1]},
+ PropertyIndex::mapped_type{meta, meta, storage[1]}},
+ {PropertyIndex::key_type{paths[1], interfaces[0], properties[0]},
+ PropertyIndex::mapped_type{meta, meta, storage[2]}},
+ {PropertyIndex::key_type{paths[1], interfaces[1], properties[1]},
+ PropertyIndex::mapped_type{meta, meta, storage[3]}},
+ {PropertyIndex::key_type{paths[2], interfaces[0], properties[0]},
+ PropertyIndex::mapped_type{meta, meta, storage[4]}},
+ {PropertyIndex::key_type{paths[2], interfaces[1], properties[1]},
+ PropertyIndex::mapped_type{meta, meta, storage[5]}},
+ {PropertyIndex::key_type{paths[3], interfaces[0], properties[0]},
+ PropertyIndex::mapped_type{meta, meta, storage[6]}},
+ {PropertyIndex::key_type{paths[3], interfaces[1], properties[1]},
+ PropertyIndex::mapped_type{meta, meta, storage[7]}},
},
};
-template <typename T> struct ExpectedValues {};
+template <typename T> struct ExpectedValues
+{
+};
template <> struct ExpectedValues<uint8_t>
{
static auto& get(size_t i)
{
- static const std::array<uint8_t, 8> values =
- {
+ static const std::array<uint8_t, 8> values = {
{0, 1, 2, 3, 4, 5, 6, 7},
};
return values[i];
@@ -84,8 +65,7 @@ template <> struct ExpectedValues<uint16_t>
{
static auto& get(size_t i)
{
- static const std::array<uint16_t, 8> values =
- {
+ static const std::array<uint16_t, 8> values = {
{88, 77, 66, 55, 44, 33, 22, 11},
};
return values[i];
@@ -96,8 +76,7 @@ template <> struct ExpectedValues<uint32_t>
{
static auto& get(size_t i)
{
- static const std::array<uint32_t, 8> values =
- {
+ static const std::array<uint32_t, 8> values = {
{0xffffffff, 1, 3, 0, 5, 7, 9, 0xffffffff},
};
return values[i];
@@ -108,8 +87,7 @@ template <> struct ExpectedValues<uint64_t>
{
static auto& get(size_t i)
{
- static const std::array<uint64_t, 8> values =
- {
+ static const std::array<uint64_t, 8> values = {
{0xffffffffffffffff, 3, 7, 12234, 0, 3, 9, 0xffffffff},
};
return values[i];
@@ -120,16 +98,14 @@ template <> struct ExpectedValues<std::string>
{
static auto& get(size_t i)
{
- static const std::array<std::string, 8> values =
- {
+ static const std::array<std::string, 8> values = {
{""s, "foo"s, "bar"s, "baz"s, "hello"s, "string", "\x2\x3", "\\"},
};
return values[i];
}
};
-template <typename T>
-void testStart()
+template <typename T> void testStart()
{
using ::testing::Return;
using ::testing::_;
@@ -146,34 +122,22 @@ void testStart()
const auto& path = o.first.get();
const auto& interfaces = o.second;
std::vector<std::string> mapperResponse;
- std::transform(
- interfaces.begin(),
- interfaces.end(),
- std::back_inserter(mapperResponse),
- // *INDENT-OFF*
- [](const auto & item)
- {
- return item.first;
- });
+ std::transform(interfaces.begin(), interfaces.end(),
+ std::back_inserter(mapperResponse),
+ // *INDENT-OFF*
+ [](const auto& item) { return item.first; });
// *INDENT-ON*
+ EXPECT_CALL(dbus, mapperGetObject(MAPPER_BUSNAME, MAPPER_PATH,
+ MAPPER_INTERFACE, "GetObject", path,
+ expectedMapperInterfaces))
+ .WillOnce(Return(GetObject({{"", mapperResponse}})));
EXPECT_CALL(
- dbus,
- mapperGetObject(
- MAPPER_BUSNAME,
- MAPPER_PATH,
- MAPPER_INTERFACE,
- "GetObject",
- path,
- expectedMapperInterfaces))
- .WillOnce(Return(GetObject({{"", mapperResponse}})));
- EXPECT_CALL(
- dbus,
- fwdAddMatch(
- sdbusplus::bus::match::rules::member("InterfacesAdded") +
- sdbusplus::bus::match::rules::path(path) +
- sdbusplus::bus::match::rules::interface(
- "org.freedesktop.DBus.ObjectManager"),
- _));
+ dbus, fwdAddMatch(
+ sdbusplus::bus::match::rules::member("InterfacesAdded") +
+ sdbusplus::bus::match::rules::path(path) +
+ sdbusplus::bus::match::rules::interface(
+ "org.freedesktop.DBus.ObjectManager"),
+ _));
for (const auto& i : interfaces)
{
const auto& interface = i.first.get();
@@ -182,10 +146,10 @@ void testStart()
dbus,
fwdAddMatch(
sdbusplus::bus::match::rules::member("PropertiesChanged") +
- sdbusplus::bus::match::rules::path(path) +
- sdbusplus::bus::match::rules::argN(0, interface) +
- sdbusplus::bus::match::rules::interface(
- "org.freedesktop.DBus.Properties"),
+ sdbusplus::bus::match::rules::path(path) +
+ sdbusplus::bus::match::rules::argN(0, interface) +
+ sdbusplus::bus::match::rules::interface(
+ "org.freedesktop.DBus.Properties"),
_));
PropertiesChanged<T> serviceResponse;
@@ -195,7 +159,7 @@ void testStart()
++ndx;
}
Expect<T>::getProperties(dbus, path, interface)
- .WillOnce(Return(serviceResponse));
+ .WillOnce(Return(serviceResponse));
}
}
diff --git a/src/test/propertywatchtest.hpp b/src/test/propertywatchtest.hpp
index f965096..d226f93 100644
--- a/src/test/propertywatchtest.hpp
+++ b/src/test/propertywatchtest.hpp
@@ -26,19 +26,12 @@ namespace monitoring
*
* Specialize to implement new forwards.
*/
-template <
- typename DBusInterfaceType,
- typename Ret,
- typename ...Args >
+template <typename DBusInterfaceType, typename Ret, typename... Args>
struct CallMethodAndRead
{
- static Ret op(
- DBusInterfaceType& dbus,
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method,
- Args&& ... args)
+ static Ret op(DBusInterfaceType& dbus, const std::string& busName,
+ const std::string& path, const std::string& interface,
+ const std::string& method, Args&&... args)
{
static_assert(true, "Missing CallMethodAndRead definition.");
return Ret();
@@ -48,253 +41,160 @@ struct CallMethodAndRead
/** @brief CallMethodAndRead specialization for
* xyz.openbmc_project.ObjectMapper.GetObject. */
template <typename DBusInterfaceType>
-struct CallMethodAndRead <
- DBusInterfaceType,
- GetObject,
- const MapperPath&,
- const std::vector<std::string>& >
+struct CallMethodAndRead<DBusInterfaceType, GetObject, const MapperPath&,
+ const std::vector<std::string>&>
{
- static GetObject op(
- DBusInterfaceType& dbus,
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method,
- const MapperPath& objectPath,
- const std::vector<std::string>& interfaces)
+ static GetObject op(DBusInterfaceType& dbus, const std::string& busName,
+ const std::string& path, const std::string& interface,
+ const std::string& method, const MapperPath& objectPath,
+ const std::vector<std::string>& interfaces)
{
- return dbus.mapperGetObject(
- busName,
- path,
- interface,
- method,
- objectPath,
- interfaces);
+ return dbus.mapperGetObject(busName, path, interface, method,
+ objectPath, interfaces);
}
};
/** @brief CallMethodAndRead specialization for
* org.freedesktop.DBus.Properties.GetAll(uint64_t). */
template <typename DBusInterfaceType>
-struct CallMethodAndRead <
- DBusInterfaceType,
- PropertiesChanged<uint64_t>,
- const std::string& >
+struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<uint64_t>,
+ const std::string&>
{
- static PropertiesChanged<uint64_t> op(
- DBusInterfaceType& dbus,
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method,
- const std::string& propertiesInterface)
+ static PropertiesChanged<uint64_t>
+ op(DBusInterfaceType& dbus, const std::string& busName,
+ const std::string& path, const std::string& interface,
+ const std::string& method, const std::string& propertiesInterface)
{
- return dbus.getPropertiesU64(
- busName,
- path,
- interface,
- method,
- propertiesInterface);
+ return dbus.getPropertiesU64(busName, path, interface, method,
+ propertiesInterface);
}
};
/** @brief CallMethodAndRead specialization for
* org.freedesktop.DBus.Properties.GetAll(uint32_t). */
template <typename DBusInterfaceType>
-struct CallMethodAndRead <
- DBusInterfaceType,
- PropertiesChanged<uint32_t>,
- const std::string& >
+struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<uint32_t>,
+ const std::string&>
{
- static PropertiesChanged<uint32_t> op(
- DBusInterfaceType& dbus,
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method,
- const std::string& propertiesInterface)
+ static PropertiesChanged<uint32_t>
+ op(DBusInterfaceType& dbus, const std::string& busName,
+ const std::string& path, const std::string& interface,
+ const std::string& method, const std::string& propertiesInterface)
{
- return dbus.getPropertiesU32(
- busName,
- path,
- interface,
- method,
- propertiesInterface);
+ return dbus.getPropertiesU32(busName, path, interface, method,
+ propertiesInterface);
}
};
/** @brief CallMethodAndRead specialization for
* org.freedesktop.DBus.Properties.GetAll(uint16_t). */
template <typename DBusInterfaceType>
-struct CallMethodAndRead <
- DBusInterfaceType,
- PropertiesChanged<uint16_t>,
- const std::string& >
+struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<uint16_t>,
+ const std::string&>
{
- static PropertiesChanged<uint16_t> op(
- DBusInterfaceType& dbus,
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method,
- const std::string& propertiesInterface)
+ static PropertiesChanged<uint16_t>
+ op(DBusInterfaceType& dbus, const std::string& busName,
+ const std::string& path, const std::string& interface,
+ const std::string& method, const std::string& propertiesInterface)
{
- return dbus.getPropertiesU16(
- busName,
- path,
- interface,
- method,
- propertiesInterface);
+ return dbus.getPropertiesU16(busName, path, interface, method,
+ propertiesInterface);
}
};
/** @brief CallMethodAndRead specialization for
* org.freedesktop.DBus.Properties.GetAll(uint8_t). */
template <typename DBusInterfaceType>
-struct CallMethodAndRead <
- DBusInterfaceType,
- PropertiesChanged<uint8_t>,
- const std::string& >
+struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<uint8_t>,
+ const std::string&>
{
- static PropertiesChanged<uint8_t> op(
- DBusInterfaceType& dbus,
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method,
- const std::string& propertiesInterface)
+ static PropertiesChanged<uint8_t>
+ op(DBusInterfaceType& dbus, const std::string& busName,
+ const std::string& path, const std::string& interface,
+ const std::string& method, const std::string& propertiesInterface)
{
- return dbus.getPropertiesU8(
- busName,
- path,
- interface,
- method,
- propertiesInterface);
+ return dbus.getPropertiesU8(busName, path, interface, method,
+ propertiesInterface);
}
};
/** @brief CallMethodAndRead specialization for
* org.freedesktop.DBus.Properties.GetAll(int64_t). */
template <typename DBusInterfaceType>
-struct CallMethodAndRead <
- DBusInterfaceType,
- PropertiesChanged<int64_t>,
- const std::string& >
+struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<int64_t>,
+ const std::string&>
{
- static PropertiesChanged<int64_t> op(
- DBusInterfaceType& dbus,
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method,
- const std::string& propertiesInterface)
+ static PropertiesChanged<int64_t>
+ op(DBusInterfaceType& dbus, const std::string& busName,
+ const std::string& path, const std::string& interface,
+ const std::string& method, const std::string& propertiesInterface)
{
- return dbus.getPropertiesU64(
- busName,
- path,
- interface,
- method,
- propertiesInterface);
+ return dbus.getPropertiesU64(busName, path, interface, method,
+ propertiesInterface);
}
};
/** @brief CallMethodAndRead specialization for
* org.freedesktop.DBus.Properties.GetAll(int32_t). */
template <typename DBusInterfaceType>
-struct CallMethodAndRead <
- DBusInterfaceType,
- PropertiesChanged<int32_t>,
- const std::string& >
+struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<int32_t>,
+ const std::string&>
{
- static PropertiesChanged<int32_t> op(
- DBusInterfaceType& dbus,
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method,
- const std::string& propertiesInterface)
+ static PropertiesChanged<int32_t>
+ op(DBusInterfaceType& dbus, const std::string& busName,
+ const std::string& path, const std::string& interface,
+ const std::string& method, const std::string& propertiesInterface)
{
- return dbus.getPropertiesU32(
- busName,
- path,
- interface,
- method,
- propertiesInterface);
+ return dbus.getPropertiesU32(busName, path, interface, method,
+ propertiesInterface);
}
};
/** @brief CallMethodAndRead specialization for
* org.freedesktop.DBus.Properties.GetAll(int16_t). */
template <typename DBusInterfaceType>
-struct CallMethodAndRead <
- DBusInterfaceType,
- PropertiesChanged<int16_t>,
- const std::string& >
+struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<int16_t>,
+ const std::string&>
{
- static PropertiesChanged<int16_t> op(
- DBusInterfaceType& dbus,
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method,
- const std::string& propertiesInterface)
+ static PropertiesChanged<int16_t>
+ op(DBusInterfaceType& dbus, const std::string& busName,
+ const std::string& path, const std::string& interface,
+ const std::string& method, const std::string& propertiesInterface)
{
- return dbus.getPropertiesU16(
- busName,
- path,
- interface,
- method,
- propertiesInterface);
+ return dbus.getPropertiesU16(busName, path, interface, method,
+ propertiesInterface);
}
};
/** @brief CallMethodAndRead specialization for
* org.freedesktop.DBus.Properties.GetAll(int8_t). */
template <typename DBusInterfaceType>
-struct CallMethodAndRead <
- DBusInterfaceType,
- PropertiesChanged<int8_t>,
- const std::string& >
+struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<int8_t>,
+ const std::string&>
{
- static PropertiesChanged<int8_t> op(
- DBusInterfaceType& dbus,
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method,
- const std::string& propertiesInterface)
+ static PropertiesChanged<int8_t>
+ op(DBusInterfaceType& dbus, const std::string& busName,
+ const std::string& path, const std::string& interface,
+ const std::string& method, const std::string& propertiesInterface)
{
- return dbus.getPropertiesU8(
- busName,
- path,
- interface,
- method,
- propertiesInterface);
+ return dbus.getPropertiesU8(busName, path, interface, method,
+ propertiesInterface);
}
};
/** @brief CallMethodAndRead specialization for
* org.freedesktop.DBus.Properties.GetAll(std::string). */
template <typename DBusInterfaceType>
-struct CallMethodAndRead <
- DBusInterfaceType,
- PropertiesChanged<std::string>,
- const std::string& >
+struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<std::string>,
+ const std::string&>
{
- static PropertiesChanged<std::string> op(
- DBusInterfaceType& dbus,
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method,
- const std::string& propertiesInterface)
+ static PropertiesChanged<std::string>
+ op(DBusInterfaceType& dbus, const std::string& busName,
+ const std::string& path, const std::string& interface,
+ const std::string& method, const std::string& propertiesInterface)
{
- return dbus.getPropertiesString(
- busName,
- path,
- interface,
- method,
- propertiesInterface);
+ return dbus.getPropertiesString(busName, path, interface, method,
+ propertiesInterface);
}
};
@@ -304,102 +204,59 @@ struct CallMethodAndRead <
*/
struct MockDBusInterface
{
- MOCK_METHOD6(
- mapperGetObject,
- GetObject(
- const std::string&,
- const std::string&,
- const std::string&,
- const std::string&,
- const MapperPath&,
- const std::vector<std::string>&));
-
- MOCK_METHOD5(
- getPropertiesU64,
- PropertiesChanged<uint64_t>(
- const std::string&,
- const std::string&,
- const std::string&,
- const std::string&,
- const std::string&));
-
- MOCK_METHOD5(
- getPropertiesU32,
- PropertiesChanged<uint32_t>(
- const std::string&,
- const std::string&,
- const std::string&,
- const std::string&,
- const std::string&));
-
- MOCK_METHOD5(
- getPropertiesU16,
- PropertiesChanged<uint16_t>(
- const std::string&,
- const std::string&,
- const std::string&,
- const std::string&,
- const std::string&));
-
- MOCK_METHOD5(
- getPropertiesU8,
- PropertiesChanged<uint8_t>(
- const std::string&,
- const std::string&,
- const std::string&,
- const std::string&,
- const std::string&));
-
- MOCK_METHOD5(
- getPropertiesS64,
- PropertiesChanged<int64_t>(
- const std::string&,
- const std::string&,
- const std::string&,
- const std::string&,
- const std::string&));
-
- MOCK_METHOD5(
- getPropertiesS32,
- PropertiesChanged<int32_t>(
- const std::string&,
- const std::string&,
- const std::string&,
- const std::string&,
- const std::string&));
-
- MOCK_METHOD5(
- getPropertiesS16,
- PropertiesChanged<int16_t>(
- const std::string&,
- const std::string&,
- const std::string&,
- const std::string&,
- const std::string&));
-
- MOCK_METHOD5(
- getPropertiesS8,
- PropertiesChanged<int8_t>(
- const std::string&,
- const std::string&,
- const std::string&,
- const std::string&,
- const std::string&));
-
- MOCK_METHOD5(
- getPropertiesString,
- PropertiesChanged<std::string>(
- const std::string&,
- const std::string&,
- const std::string&,
- const std::string&,
- const std::string&));
-
- MOCK_METHOD2(
- fwdAddMatch,
- void(
- const std::string&,
- const sdbusplus::bus::match::match::callback_t&));
+ MOCK_METHOD6(mapperGetObject,
+ GetObject(const std::string&, const std::string&,
+ const std::string&, const std::string&,
+ const MapperPath&, const std::vector<std::string>&));
+
+ MOCK_METHOD5(getPropertiesU64,
+ PropertiesChanged<uint64_t>(
+ const std::string&, const std::string&, const std::string&,
+ const std::string&, const std::string&));
+
+ MOCK_METHOD5(getPropertiesU32,
+ PropertiesChanged<uint32_t>(
+ const std::string&, const std::string&, const std::string&,
+ const std::string&, const std::string&));
+
+ MOCK_METHOD5(getPropertiesU16,
+ PropertiesChanged<uint16_t>(
+ const std::string&, const std::string&, const std::string&,
+ const std::string&, const std::string&));
+
+ MOCK_METHOD5(getPropertiesU8,
+ PropertiesChanged<uint8_t>(
+ const std::string&, const std::string&, const std::string&,
+ const std::string&, const std::string&));
+
+ MOCK_METHOD5(getPropertiesS64,
+ PropertiesChanged<int64_t>(
+ const std::string&, const std::string&, const std::string&,
+ const std::string&, const std::string&));
+
+ MOCK_METHOD5(getPropertiesS32,
+ PropertiesChanged<int32_t>(
+ const std::string&, const std::string&, const std::string&,
+ const std::string&, const std::string&));
+
+ MOCK_METHOD5(getPropertiesS16,
+ PropertiesChanged<int16_t>(
+ const std::string&, const std::string&, const std::string&,
+ const std::string&, const std::string&));
+
+ MOCK_METHOD5(getPropertiesS8,
+ PropertiesChanged<int8_t>(
+ const std::string&, const std::string&, const std::string&,
+ const std::string&, const std::string&));
+
+ MOCK_METHOD5(getPropertiesString,
+ PropertiesChanged<std::string>(
+ const std::string&, const std::string&, const std::string&,
+ const std::string&, const std::string&));
+
+ MOCK_METHOD2(fwdAddMatch,
+ void(const std::string&,
+ const sdbusplus::bus::match::match::callback_t&));
static MockDBusInterface* ptr;
static MockDBusInterface& instance()
@@ -412,27 +269,21 @@ struct MockDBusInterface
}
/** @brief GMock member template/free function forward. */
- template <typename Ret, typename ...Args>
- static auto callMethodAndRead(
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method,
- Args&& ... args)
+ template <typename Ret, typename... Args>
+ static auto callMethodAndRead(const std::string& busName,
+ const std::string& path,
+ const std::string& interface,
+ const std::string& method, Args&&... args)
{
- return CallMethodAndRead <MockDBusInterface, Ret, Args... >::op(
- instance(),
- busName,
- path,
- interface,
- method,
- std::forward<Args>(args)...);
+ return CallMethodAndRead<MockDBusInterface, Ret, Args...>::op(
+ instance(), busName, path, interface, method,
+ std::forward<Args>(args)...);
}
/** @brief GMock free function forward. */
- static auto addMatch(
- const std::string& match,
- const sdbusplus::bus::match::match::callback_t& callback)
+ static auto
+ addMatch(const std::string& match,
+ const sdbusplus::bus::match::match::callback_t& callback)
{
instance().fwdAddMatch(match, callback);
}
@@ -441,185 +292,125 @@ struct MockDBusInterface
/** @class Expect
* @brief Enable use of EXPECT_CALL from a C++ template.
*/
-template <typename T> struct Expect {};
+template <typename T> struct Expect
+{
+};
-template <>
-struct Expect<uint64_t>
+template <> struct Expect<uint64_t>
{
template <typename MockObjType>
- static auto& getProperties(
- MockObjType&& mockObj,
- const std::string& path,
- const std::string& interface)
+ static auto& getProperties(MockObjType&& mockObj, const std::string& path,
+ const std::string& interface)
{
- return EXPECT_CALL(
- std::forward<MockObjType>(mockObj),
- getPropertiesU64(
- ::testing::_,
- path,
- "org.freedesktop.DBus.Properties",
- "GetAll",
- interface));
+ return EXPECT_CALL(std::forward<MockObjType>(mockObj),
+ getPropertiesU64(::testing::_, path,
+ "org.freedesktop.DBus.Properties",
+ "GetAll", interface));
}
};
-template <>
-struct Expect<uint32_t>
+template <> struct Expect<uint32_t>
{
template <typename MockObjType>
- static auto& getProperties(
- MockObjType&& mockObj,
- const std::string& path,
- const std::string& interface)
+ static auto& getProperties(MockObjType&& mockObj, const std::string& path,
+ const std::string& interface)
{
- return EXPECT_CALL(
- std::forward<MockObjType>(mockObj),
- getPropertiesU32(
- ::testing::_,
- path,
- "org.freedesktop.DBus.Properties",
- "GetAll",
- interface));
+ return EXPECT_CALL(std::forward<MockObjType>(mockObj),
+ getPropertiesU32(::testing::_, path,
+ "org.freedesktop.DBus.Properties",
+ "GetAll", interface));
}
};
-template <>
-struct Expect<uint16_t>
+template <> struct Expect<uint16_t>
{
template <typename MockObjType>
- static auto& getProperties(
- MockObjType&& mockObj,
- const std::string& path,
- const std::string& interface)
+ static auto& getProperties(MockObjType&& mockObj, const std::string& path,
+ const std::string& interface)
{
- return EXPECT_CALL(
- std::forward<MockObjType>(mockObj),
- getPropertiesU16(
- ::testing::_,
- path,
- "org.freedesktop.DBus.Properties",
- "GetAll",
- interface));
+ return EXPECT_CALL(std::forward<MockObjType>(mockObj),
+ getPropertiesU16(::testing::_, path,
+ "org.freedesktop.DBus.Properties",
+ "GetAll", interface));
}
};
-template <>
-struct Expect<uint8_t>
+template <> struct Expect<uint8_t>
{
template <typename MockObjType>
- static auto& getProperties(
- MockObjType&& mockObj,
- const std::string& path,
- const std::string& interface)
+ static auto& getProperties(MockObjType&& mockObj, const std::string& path,
+ const std::string& interface)
{
- return EXPECT_CALL(
- std::forward<MockObjType>(mockObj),
- getPropertiesU8(
- ::testing::_,
- path,
- "org.freedesktop.DBus.Properties",
- "GetAll",
- interface));
+ return EXPECT_CALL(std::forward<MockObjType>(mockObj),
+ getPropertiesU8(::testing::_, path,
+ "org.freedesktop.DBus.Properties",
+ "GetAll", interface));
}
};
-template <>
-struct Expect<int64_t>
+template <> struct Expect<int64_t>
{
template <typename MockObjType>
- static auto& getProperties(
- MockObjType&& mockObj,
- const std::string& path,
- const std::string& interface)
+ static auto& getProperties(MockObjType&& mockObj, const std::string& path,
+ const std::string& interface)
{
- return EXPECT_CALL(
- std::forward<MockObjType>(mockObj),
- getPropertiesS64(
- ::testing::_,
- path,
- "org.freedesktop.DBus.Properties",
- "GetAll",
- interface));
+ return EXPECT_CALL(std::forward<MockObjType>(mockObj),
+ getPropertiesS64(::testing::_, path,
+ "org.freedesktop.DBus.Properties",
+ "GetAll", interface));
}
};
-template <>
-struct Expect<int32_t>
+template <> struct Expect<int32_t>
{
template <typename MockObjType>
- static auto& getProperties(
- MockObjType&& mockObj,
- const std::string& path,
- const std::string& interface)
+ static auto& getProperties(MockObjType&& mockObj, const std::string& path,
+ const std::string& interface)
{
- return EXPECT_CALL(
- std::forward<MockObjType>(mockObj),
- getPropertiesS32(
- ::testing::_,
- path,
- "org.freedesktop.DBus.Properties",
- "GetAll",
- interface));
+ return EXPECT_CALL(std::forward<MockObjType>(mockObj),
+ getPropertiesS32(::testing::_, path,
+ "org.freedesktop.DBus.Properties",
+ "GetAll", interface));
}
};
-template <>
-struct Expect<int16_t>
+template <> struct Expect<int16_t>
{
template <typename MockObjType>
- static auto& getProperties(
- MockObjType&& mockObj,
- const std::string& path,
- const std::string& interface)
+ static auto& getProperties(MockObjType&& mockObj, const std::string& path,
+ const std::string& interface)
{
- return EXPECT_CALL(
- std::forward<MockObjType>(mockObj),
- getPropertiesS16(
- ::testing::_,
- path,
- "org.freedesktop.DBus.Properties",
- "GetAll",
- interface));
+ return EXPECT_CALL(std::forward<MockObjType>(mockObj),
+ getPropertiesS16(::testing::_, path,
+ "org.freedesktop.DBus.Properties",
+ "GetAll", interface));
}
};
-template <>
-struct Expect<int8_t>
+template <> struct Expect<int8_t>
{
template <typename MockObjType>
- static auto& getProperties(
- MockObjType&& mockObj,
- const std::string& path,
- const std::string& interface)
+ static auto& getProperties(MockObjType&& mockObj, const std::string& path,
+ const std::string& interface)
{
- return EXPECT_CALL(
- std::forward<MockObjType>(mockObj),
- getPropertiesS8(
- ::testing::_,
- path,
- "org.freedesktop.DBus.Properties",
- "GetAll",
- interface));
+ return EXPECT_CALL(std::forward<MockObjType>(mockObj),
+ getPropertiesS8(::testing::_, path,
+ "org.freedesktop.DBus.Properties",
+ "GetAll", interface));
}
};
-template <>
-struct Expect<std::string>
+template <> struct Expect<std::string>
{
template <typename MockObjType>
- static auto& getProperties(
- MockObjType&& mockObj,
- const std::string& path,
- const std::string& interface)
+ static auto& getProperties(MockObjType&& mockObj, const std::string& path,
+ const std::string& interface)
{
return EXPECT_CALL(
- std::forward<MockObjType>(mockObj),
- getPropertiesString(
- ::testing::_,
- path,
- "org.freedesktop.DBus.Properties",
- "GetAll",
- interface));
+ std::forward<MockObjType>(mockObj),
+ getPropertiesString(::testing::_, path,
+ "org.freedesktop.DBus.Properties", "GetAll",
+ interface));
}
};
diff --git a/src/tupleref.hpp b/src/tupleref.hpp
index c6a6dcd..3e896be 100644
--- a/src/tupleref.hpp
+++ b/src/tupleref.hpp
@@ -17,8 +17,7 @@ using TupleOfRefs = std::tuple<std::reference_wrapper<T>...>;
namespace detail
{
/** @brief Less than implementation for tuples of references. */
-template <size_t size, size_t i, typename T, typename U>
-struct TupleOfRefsLess
+template <size_t size, size_t i, typename T, typename U> struct TupleOfRefsLess
{
static constexpr bool compare(const T& l, const U& r)
{
@@ -30,7 +29,7 @@ struct TupleOfRefsLess
{
return false;
}
- return TupleOfRefsLess < size, i + 1, T, U >::compare(l, r);
+ return TupleOfRefsLess<size, i + 1, T, U>::compare(l, r);
}
};
@@ -49,17 +48,13 @@ struct TupleOfRefsLess<size, size, T, U>
struct TupleOfRefsLess
{
template <typename... T, typename... U>
- constexpr bool operator()(
- const TupleOfRefs<T...>& l,
- const TupleOfRefs<U...>& r) const
+ constexpr bool operator()(const TupleOfRefs<T...>& l,
+ const TupleOfRefs<U...>& r) const
{
static_assert(sizeof...(T) == sizeof...(U),
"Cannot compare tuples of different lengths.");
- return detail::TupleOfRefsLess <
- sizeof...(T),
- 0,
- TupleOfRefs<T...>,
- TupleOfRefs<U... >>::compare(l, r);
+ return detail::TupleOfRefsLess<sizeof...(T), 0, TupleOfRefs<T...>,
+ TupleOfRefs<U...>>::compare(l, r);
}
};
diff --git a/src/watch.hpp b/src/watch.hpp
index d420458..9c97b9e 100644
--- a/src/watch.hpp
+++ b/src/watch.hpp
@@ -24,20 +24,19 @@ namespace monitoring
*/
class Watch
{
- public:
- Watch() = default;
- Watch(const Watch&) = default;
- Watch(Watch&&) = default;
- Watch& operator=(const Watch&) = default;
- Watch& operator=(Watch&&) = default;
- virtual ~Watch() = default;
+ public:
+ Watch() = default;
+ Watch(const Watch&) = default;
+ Watch(Watch&&) = default;
+ Watch& operator=(const Watch&) = default;
+ Watch& operator=(Watch&&) = default;
+ virtual ~Watch() = default;
- /** @brief Start the watch. */
- virtual void start() = 0;
-
- /** @brief Invoke the callback associated with the watch. */
- virtual void callback(Context ctx) = 0;
+ /** @brief Start the watch. */
+ virtual void start() = 0;
+ /** @brief Invoke the callback associated with the watch. */
+ virtual void callback(Context ctx) = 0;
};
} // namespace monitoring
OpenPOWER on IntegriCloud