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/power-supply/record_manager.hpp b/power-supply/record_manager.hpp
index 53e5b9b..7ebcc3f 100644
--- a/power-supply/record_manager.hpp
+++ b/power-supply/record_manager.hpp
@@ -25,12 +25,10 @@
*/
class InvalidRecordException : public std::runtime_error
{
- public:
-
- InvalidRecordException() :
- std::runtime_error("Invalid history record")
- {
- }
+ public:
+ InvalidRecordException() : std::runtime_error("Invalid history record")
+ {
+ }
};
/**
@@ -49,157 +47,153 @@
*/
class RecordManager
{
- public:
+ public:
+ static constexpr auto RAW_RECORD_SIZE = 5;
+ static constexpr auto RAW_RECORD_ID_OFFSET = 0;
+ static constexpr auto FIRST_SEQUENCE_ID = 0;
+ static constexpr auto LAST_SEQUENCE_ID = 0xFF;
- static constexpr auto RAW_RECORD_SIZE = 5;
- static constexpr auto RAW_RECORD_ID_OFFSET = 0;
- static constexpr auto FIRST_SEQUENCE_ID = 0;
- static constexpr auto LAST_SEQUENCE_ID = 0xFF;
+ using DBusRecord = std::tuple<uint64_t, int64_t>;
+ using DBusRecordList = std::vector<DBusRecord>;
- using DBusRecord = std::tuple<uint64_t, int64_t>;
- using DBusRecordList = std::vector<DBusRecord>;
+ RecordManager() = delete;
+ ~RecordManager() = default;
+ RecordManager(const RecordManager&) = default;
+ RecordManager& operator=(const RecordManager&) = default;
+ RecordManager(RecordManager&&) = default;
+ RecordManager& operator=(RecordManager&&) = default;
- RecordManager() = delete;
- ~RecordManager() = default;
- RecordManager(const RecordManager&) = default;
- RecordManager& operator=(const RecordManager&) = default;
- RecordManager(RecordManager&&) = default;
- RecordManager& operator=(RecordManager&&) = default;
+ /**
+ * @brief Constructor
+ *
+ * @param[in] maxRec - the maximum number of history
+ * records to keep at a time
+ */
+ RecordManager(size_t maxRec) : RecordManager(maxRec, LAST_SEQUENCE_ID)
+ {
+ }
- /**
- * @brief Constructor
- *
- * @param[in] maxRec - the maximum number of history
- * records to keep at a time
- */
- RecordManager(size_t maxRec) :
- RecordManager(maxRec, LAST_SEQUENCE_ID)
- {
- }
+ /**
+ * @brief Constructor
+ *
+ * @param[in] maxRec - the maximum number of history
+ * records to keep at a time
+ * @param[in] lastSequenceID - the last sequence ID the power supply
+ * will use before starting over
+ */
+ RecordManager(size_t maxRec, size_t lastSequenceID) :
+ maxRecords(maxRec), lastSequenceID(lastSequenceID)
+ {
+ }
- /**
- * @brief Constructor
- *
- * @param[in] maxRec - the maximum number of history
- * records to keep at a time
- * @param[in] lastSequenceID - the last sequence ID the power supply
- * will use before starting over
- */
- RecordManager(size_t maxRec, size_t lastSequenceID) :
- maxRecords(maxRec),
- lastSequenceID(lastSequenceID)
- {
- }
+ /**
+ * @brief Adds a new entry to the history
+ *
+ * Also checks to see if the old history should be
+ * cleared, such as when there is an invalid record
+ * sequence ID or if there was no data from the PS.
+ *
+ * @param[in] rawRecord - the record data straight
+ * from the power supply
+ *
+ * @return bool - If there has been a change to the
+ * history records that needs to be
+ * reflected in D-Bus.
+ */
+ bool add(const std::vector<uint8_t>& rawRecord);
- /**
- * @brief Adds a new entry to the history
- *
- * Also checks to see if the old history should be
- * cleared, such as when there is an invalid record
- * sequence ID or if there was no data from the PS.
- *
- * @param[in] rawRecord - the record data straight
- * from the power supply
- *
- * @return bool - If there has been a change to the
- * history records that needs to be
- * reflected in D-Bus.
- */
- bool add(const std::vector<uint8_t>& rawRecord);
+ /**
+ * @brief Returns the history of average input power
+ * in a representation used by D-Bus.
+ *
+ * @return DBusRecordList - A list of averages with
+ * a timestamp for each entry.
+ */
+ DBusRecordList getAverageRecords();
- /**
- * @brief Returns the history of average input power
- * in a representation used by D-Bus.
- *
- * @return DBusRecordList - A list of averages with
- * a timestamp for each entry.
- */
- DBusRecordList getAverageRecords();
+ /**
+ * @brief Returns the history of maximum input power
+ * in a representation used by D-Bus.
+ *
+ * @return DBusRecordList - A list of maximums with
+ * a timestamp for each entry.
+ */
+ DBusRecordList getMaximumRecords();
- /**
- * @brief Returns the history of maximum input power
- * in a representation used by D-Bus.
- *
- * @return DBusRecordList - A list of maximums with
- * a timestamp for each entry.
- */
- DBusRecordList getMaximumRecords();
+ /**
+ * @brief Converts a Linear Format power number to an integer
+ *
+ * The PMBus spec describes a 2 byte Linear Format
+ * number that is composed of an exponent and mantissa
+ * in two's complement notation.
+ *
+ * Value = Mantissa * 2**Exponent
+ *
+ * @return int64_t the converted value
+ */
+ static int64_t linearToInteger(uint16_t data);
- /**
- * @brief Converts a Linear Format power number to an integer
- *
- * The PMBus spec describes a 2 byte Linear Format
- * number that is composed of an exponent and mantissa
- * in two's complement notation.
- *
- * Value = Mantissa * 2**Exponent
- *
- * @return int64_t the converted value
- */
- static int64_t linearToInteger(uint16_t data);
+ /**
+ * @brief Returns the number of records
+ *
+ * @return size_t - the number of records
+ *
+ */
+ inline size_t getNumRecords() const
+ {
+ return records.size();
+ }
- /**
- * @brief Returns the number of records
- *
- * @return size_t - the number of records
- *
- */
- inline size_t getNumRecords() const
- {
- return records.size();
- }
+ /**
+ * @brief Deletes all records
+ */
+ inline void clear()
+ {
+ records.clear();
+ }
- /**
- * @brief Deletes all records
- */
- inline void clear()
- {
- records.clear();
- }
+ private:
+ /**
+ * @brief returns the sequence ID from a raw history record
+ *
+ * Throws InvalidRecordException if the data is the wrong length.
+ *
+ * @param[in] data - the raw record data as the PS returns it
+ *
+ * @return size_t - the ID from byte 0
+ */
+ size_t getRawRecordID(const std::vector<uint8_t>& data) const;
- private:
+ /**
+ * @brief Creates an instance of a Record from the raw PS data
+ *
+ * @param[in] data - the raw record data as the PS returns it
+ *
+ * @return Record - A filled in Record instance
+ */
+ Record createRecord(const std::vector<uint8_t>& data);
- /**
- * @brief returns the sequence ID from a raw history record
- *
- * Throws InvalidRecordException if the data is the wrong length.
- *
- * @param[in] data - the raw record data as the PS returns it
- *
- * @return size_t - the ID from byte 0
- */
- size_t getRawRecordID(const std::vector<uint8_t>& data) const;
+ /**
+ * @brief The maximum number of entries to keep in the history.
+ *
+ * When a new record is added, the oldest one will be removed.
+ */
+ const size_t maxRecords;
- /**
- * @brief Creates an instance of a Record from the raw PS data
- *
- * @param[in] data - the raw record data as the PS returns it
- *
- * @return Record - A filled in Record instance
- */
- Record createRecord(const std::vector<uint8_t>& data);
+ /**
+ * @brief The last ID the power supply returns before rolling over
+ * back to the first ID of 0.
+ */
+ const size_t lastSequenceID;
- /**
- * @brief The maximum number of entries to keep in the history.
- *
- * When a new record is added, the oldest one will be removed.
- */
- const size_t maxRecords;
-
- /**
- * @brief The last ID the power supply returns before rolling over
- * back to the first ID of 0.
- */
- const size_t lastSequenceID;
-
- /**
- * @brief The list of timestamp/average/maximum records.
- * Newer records are added to the front, and older ones
- * removed from the back.
- */
- std::deque<Record> records;
+ /**
+ * @brief The list of timestamp/average/maximum records.
+ * Newer records are added to the front, and older ones
+ * removed from the back.
+ */
+ std::deque<Record> records;
};
-}
-}
-}
+} // namespace history
+} // namespace power
+} // namespace witherspoon