summaryrefslogtreecommitdiffstats
path: root/occ_errors.hpp
diff options
context:
space:
mode:
authorGunnar Mills <gmills@us.ibm.com>2018-09-14 14:50:03 -0500
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2018-10-18 16:43:22 -0400
commit94df8c9015798764d40665bb363bdbf27510f285 (patch)
treece26611a482f2f03a582838faec29eeb065a6c47 /occ_errors.hpp
parent7db89e36d7c5649b826b607cb2d90e38bb02ab86 (diff)
downloadopenpower-occ-control-94df8c9015798764d40665bb363bdbf27510f285.tar.gz
openpower-occ-control-94df8c9015798764d40665bb363bdbf27510f285.zip
clang-format: Update to match docs repo
Update the .clang-format file and run clang-format-6.0. This .clang-format matches the example one in https://github.com/openbmc/docs/blob/master/cpp-style-and-conventions.md#clang-formatting Change-Id: Id6760866dedbaeafd83ea8ef2e0303e30b8955aa Signed-off-by: Gunnar Mills <gmills@us.ibm.com> Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'occ_errors.hpp')
-rw-r--r--occ_errors.hpp179
1 files changed, 90 insertions, 89 deletions
diff --git a/occ_errors.hpp b/occ_errors.hpp
index 12ae925..ebacc8a 100644
--- a/occ_errors.hpp
+++ b/occ_errors.hpp
@@ -1,10 +1,13 @@
#pragma once
+#include "config.h"
+
+#include "occ_events.hpp"
+
#include <unistd.h>
-#include <functional>
+
#include <experimental/filesystem>
-#include "occ_events.hpp"
-#include "config.h"
+#include <functional>
namespace open_power
{
namespace occ
@@ -17,94 +20,92 @@ namespace fs = std::experimental::filesystem;
*/
class Error
{
- public:
- Error() = delete;
- Error(const Error&) = delete;
- Error& operator=(const Error&) = delete;
- Error(Error&&) = default;
- Error& operator=(Error&&) = default;
-
- /** @brief Constructs the Error object
- *
- * @param[in] event - reference to sd_event unique_ptr
- * @param[in] file - File used by driver to communicate errors
- * @param[in] callBack - Optional function callback on error condition
- */
- Error(EventPtr& event,
- const fs::path& file,
- std::function<void(bool)> callBack = nullptr) :
- event(event),
- file(fs::path(DEV_PATH) / file),
- callBack(callBack)
- {
- // Nothing to do here.
- }
-
- ~Error()
+ public:
+ Error() = delete;
+ Error(const Error&) = delete;
+ Error& operator=(const Error&) = delete;
+ Error(Error&&) = default;
+ Error& operator=(Error&&) = default;
+
+ /** @brief Constructs the Error object
+ *
+ * @param[in] event - reference to sd_event unique_ptr
+ * @param[in] file - File used by driver to communicate errors
+ * @param[in] callBack - Optional function callback on error condition
+ */
+ Error(EventPtr& event, const fs::path& file,
+ std::function<void(bool)> callBack = nullptr) :
+ event(event),
+ file(fs::path(DEV_PATH) / file), callBack(callBack)
+ {
+ // Nothing to do here.
+ }
+
+ ~Error()
+ {
+ if (fd >= 0)
{
- if (fd>= 0)
- {
- close(fd);
- }
+ close(fd);
}
-
- /** @brief Starts to monitor for error conditions */
- void addWatch();
-
- /** @brief Removes error watch */
- void removeWatch();
-
- private:
- /** @brief sd_event wrapped in unique_ptr */
- EventPtr& event;
-
- /** @brief event source wrapped in unique_ptr */
- EventSourcePtr eventSource;
-
- /** @brief Current state of error watching */
- bool watching = false;
-
- /** @brief attaches FD to events and sets up callback handler */
- void registerCallBack();
-
- /** @brief Opens the file and populates fd */
- void openFile();
-
- /** @brief Callback handler when the FD has some activity on it
- *
- * @param[in] es - Populated event source
- * @param[in] fd - Associated File descriptor
- * @param[in] revents - Type of event
- * @param[in] userData - User data that was passed during registration
- *
- * @return - 0 or positive number on success and negative
- * errno otherwise
- */
- static int processEvents(sd_event_source* es, int fd,
- uint32_t revents, void* userData);
-
- /** @brief When the error event is received, analyzes it
- * and makes a callback to error handler if the
- * content denotes an error condition
- */
- virtual void analyzeEvent();
-
- protected:
- /** @brief File descriptor to watch for errors */
- int fd = -1;
-
- /** Error file */
- const fs::path file;
-
- /** @brief Optional function to call on error scenario */
- std::function<void(bool)> callBack;
-
- /** @brief Reads file data
- *
- * @return data read. Since its a /sysfs entry,
- * it would be a string
- */
- std::string readFile(int) const;
+ }
+
+ /** @brief Starts to monitor for error conditions */
+ void addWatch();
+
+ /** @brief Removes error watch */
+ void removeWatch();
+
+ private:
+ /** @brief sd_event wrapped in unique_ptr */
+ EventPtr& event;
+
+ /** @brief event source wrapped in unique_ptr */
+ EventSourcePtr eventSource;
+
+ /** @brief Current state of error watching */
+ bool watching = false;
+
+ /** @brief attaches FD to events and sets up callback handler */
+ void registerCallBack();
+
+ /** @brief Opens the file and populates fd */
+ void openFile();
+
+ /** @brief Callback handler when the FD has some activity on it
+ *
+ * @param[in] es - Populated event source
+ * @param[in] fd - Associated File descriptor
+ * @param[in] revents - Type of event
+ * @param[in] userData - User data that was passed during registration
+ *
+ * @return - 0 or positive number on success and negative
+ * errno otherwise
+ */
+ static int processEvents(sd_event_source* es, int fd, uint32_t revents,
+ void* userData);
+
+ /** @brief When the error event is received, analyzes it
+ * and makes a callback to error handler if the
+ * content denotes an error condition
+ */
+ virtual void analyzeEvent();
+
+ protected:
+ /** @brief File descriptor to watch for errors */
+ int fd = -1;
+
+ /** Error file */
+ const fs::path file;
+
+ /** @brief Optional function to call on error scenario */
+ std::function<void(bool)> callBack;
+
+ /** @brief Reads file data
+ *
+ * @return data read. Since its a /sysfs entry,
+ * it would be a string
+ */
+ std::string readFile(int) const;
};
} // namespace occ
OpenPOWER on IntegriCloud