Start using .clang-format
Used the one from docs/style/cpp.
Change-Id: I3bdc2b353bf18a437266b362d8205b8463a9ce2b
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/gpio.hpp b/gpio.hpp
index 04100da..2742d4f 100644
--- a/gpio.hpp
+++ b/gpio.hpp
@@ -1,18 +1,22 @@
#pragma once
-#include <linux/gpio.h>
#include "file.hpp"
+#include <linux/gpio.h>
+
+#include <string>
+#include <type_traits>
+
namespace witherspoon
{
namespace gpio
{
typedef std::remove_reference<decltype(
- gpiohandle_request::lineoffsets[0])>::type gpioNum_t;
+ gpiohandle_request::lineoffsets[0])>::type gpioNum_t;
-typedef std::remove_reference<decltype(
- gpiohandle_data::values[0])>::type gpioValue_t;
+typedef std::remove_reference<decltype(gpiohandle_data::values[0])>::type
+ gpioValue_t;
/**
* If the GPIO is an input or output
@@ -41,79 +45,73 @@
*/
class GPIO
{
- public:
+ public:
+ GPIO() = delete;
+ GPIO(const GPIO&) = delete;
+ GPIO(GPIO&&) = default;
+ GPIO& operator=(const GPIO&) = delete;
+ GPIO& operator=(GPIO&&) = default;
+ ~GPIO() = default;
- GPIO() = delete;
- GPIO(const GPIO&) = delete;
- GPIO(GPIO&&) = default;
- GPIO& operator=(const GPIO&) = delete;
- GPIO& operator=(GPIO&&) = default;
- ~GPIO() = default;
+ /**
+ * Constructor
+ *
+ * @param[in] device - the GPIO device file
+ * @param[in] gpio - the GPIO number
+ * @param[in] direction - the GPIO direction
+ */
+ GPIO(const std::string& device, gpioNum_t gpio, Direction direction) :
+ device(device), gpio(gpio), direction(direction)
+ {
+ }
- /**
- * Constructor
- *
- * @param[in] device - the GPIO device file
- * @param[in] gpio - the GPIO number
- * @param[in] direction - the GPIO direction
- */
- GPIO(const std::string& device,
- gpioNum_t gpio,
- Direction direction) :
- device(device),
- gpio(gpio),
- direction(direction)
- {
- }
+ /**
+ * Reads the GPIO value
+ *
+ * Requests the GPIO line if it hasn't been done already.
+ *
+ * @return Value - the GPIO value
+ */
+ Value read();
- /**
- * Reads the GPIO value
- *
- * Requests the GPIO line if it hasn't been done already.
- *
- * @return Value - the GPIO value
- */
- Value read();
+ /**
+ * Sets the GPIO value to low or high
+ *
+ * Requests the GPIO line if it hasn't been done already.
+ *
+ * @param[in] Value - the value to set
+ */
+ void set(Value value);
- /**
- * Sets the GPIO value to low or high
- *
- * Requests the GPIO line if it hasn't been done already.
- *
- * @param[in] Value - the value to set
- */
- void set(Value value);
+ private:
+ /**
+ * Requests a GPIO line from the GPIO device
+ *
+ * @param[in] defaultValue - The default value, required for
+ * output GPIOs only.
+ */
+ void requestLine(Value defaultValue = Value::high);
- private:
+ /**
+ * The GPIO device name, like /dev/gpiochip0
+ */
+ const std::string device;
- /**
- * Requests a GPIO line from the GPIO device
- *
- * @param[in] defaultValue - The default value, required for
- * output GPIOs only.
- */
- void requestLine(Value defaultValue = Value::high);
+ /**
+ * The GPIO number
+ */
+ const gpioNum_t gpio;
- /**
- * The GPIO device name, like /dev/gpiochip0
- */
- const std::string device;
+ /**
+ * The GPIO direction
+ */
+ const Direction direction;
- /**
- * The GPIO number
- */
- const gpioNum_t gpio;
-
- /**
- * The GPIO direction
- */
- const Direction direction;
-
- /**
- * File descriptor for the GPIO line
- */
- power::util::FileDescriptor lineFD;
+ /**
+ * File descriptor for the GPIO line
+ */
+ power::util::FileDescriptor lineFD;
};
-}
-}
+} // namespace gpio
+} // namespace witherspoon