Move over to upstream c++ style
This patchset moves bmcweb over to the upstream style naming
conventions for variables, classes, and functions, as well as imposes
the latest clang-format file.
This changeset was mostly built automatically by the included
.clang-tidy file, which has the ability to autoformat and auto rename
variables. At some point in the future I would like to see this in
greater use, but for now, we will impose it on bmcweb, and see how it
goes.
Tested: Code still compiles, and appears to run, although other issues
are possible and likely.
Change-Id: If422a2e36df924e897736b3feffa89f411d9dac1
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
diff --git a/include/dbus_monitor.hpp b/include/dbus_monitor.hpp
index ab7ebef..43385e6 100644
--- a/include/dbus_monitor.hpp
+++ b/include/dbus_monitor.hpp
@@ -11,65 +11,64 @@
std::vector<std::unique_ptr<sdbusplus::bus::match::match>> matches;
};
-static boost::container::flat_map<crow::websocket::connection*,
+static boost::container::flat_map<crow::websocket::Connection*,
DbusWebsocketSession>
sessions;
-int on_property_update(sd_bus_message* m, void* userdata,
- sd_bus_error* ret_error) {
+int onPropertyUpdate(sd_bus_message* m, void* userdata,
+ sd_bus_error* ret_error) {
if (ret_error == nullptr || sd_bus_error_is_set(ret_error)) {
- CROW_LOG_ERROR << "Sdbus error in on_property_update";
+ BMCWEB_LOG_ERROR << "Sdbus error in on_property_update";
return 0;
}
sdbusplus::message::message message(m);
- std::string object_name;
+ std::string objectName;
std::vector<
std::pair<std::string, sdbusplus::message::variant<
std::string, bool, int64_t, uint64_t, double>>>
values;
- message.read(object_name, values);
+ message.read(objectName, values);
nlohmann::json j;
const std::string& path = message.get_path();
for (auto& value : values) {
mapbox::util::apply_visitor([&](auto&& val) { j[path] = val; },
value.second);
}
- std::string data_to_send = j.dump();
+ std::string dataToSend = j.dump();
- for (const std::pair<crow::websocket::connection*, DbusWebsocketSession>&
+ for (const std::pair<crow::websocket::Connection*, DbusWebsocketSession>&
session : sessions) {
- session.first->send_text(data_to_send);
+ session.first->sendText(dataToSend);
}
};
template <typename... Middlewares>
-void request_routes(Crow<Middlewares...>& app) {
- CROW_ROUTE(app, "/dbus_monitor")
+void requestRoutes(Crow<Middlewares...>& app) {
+ BMCWEB_ROUTE(app, "/dbus_monitor")
.websocket()
- .onopen([&](crow::websocket::connection& conn) {
- std::string path_namespace(conn.req.url_params.get("path_namespace"));
- if (path_namespace.empty()) {
- conn.send_text(
+ .onopen([&](crow::websocket::Connection& conn) {
+ std::string pathNamespace(conn.req.urlParams.get("path_namespace"));
+ if (pathNamespace.empty()) {
+ conn.sendText(
nlohmann::json({"error", "Did not specify path_namespace"}));
conn.close("error");
}
sessions[&conn] = DbusWebsocketSession();
- std::string match_string(
+ std::string matchString(
"type='signal',"
"interface='org.freedesktop.DBus.Properties',"
"path_namespace='" +
- path_namespace + "'");
+ pathNamespace + "'");
sessions[&conn].matches.emplace_back(
std::make_unique<sdbusplus::bus::match::match>(
- *crow::connections::system_bus, match_string,
- on_property_update));
+ *crow::connections::systemBus, matchString, onPropertyUpdate));
})
- .onclose([&](crow::websocket::connection& conn,
+ .onclose([&](crow::websocket::Connection& conn,
const std::string& reason) { sessions.erase(&conn); })
- .onmessage([&](crow::websocket::connection& conn, const std::string& data,
+ .onmessage([&](crow::websocket::Connection& conn, const std::string& data,
bool is_binary) {
- CROW_LOG_ERROR << "Got unexpected message from client on sensorws";
+ BMCWEB_LOG_ERROR << "Got unexpected message from client on sensorws";
});
}
} // namespace dbus_monitor