Matt Spinler | 89fa082 | 2019-07-17 13:54:30 -0500 | [diff] [blame^] | 1 | #pragma once |
| 2 | #include "bcd_time.hpp" |
| 3 | #include "pel.hpp" |
| 4 | |
| 5 | #include <algorithm> |
| 6 | #include <filesystem> |
| 7 | |
| 8 | namespace openpower |
| 9 | { |
| 10 | namespace pels |
| 11 | { |
| 12 | |
| 13 | /** |
| 14 | * @class Repository |
| 15 | * |
| 16 | * The class handles saving and retrieving PELs on the BMC. |
| 17 | */ |
| 18 | class Repository |
| 19 | { |
| 20 | public: |
| 21 | Repository() = delete; |
| 22 | ~Repository() = default; |
| 23 | Repository(const Repository&) = default; |
| 24 | Repository& operator=(const Repository&) = default; |
| 25 | Repository(Repository&&) = default; |
| 26 | Repository& operator=(Repository&&) = default; |
| 27 | |
| 28 | /** |
| 29 | * @brief Constructor |
| 30 | * |
| 31 | * @param[in] basePath - the base filesystem path for the repository |
| 32 | */ |
| 33 | Repository(const std::filesystem::path& basePath); |
| 34 | |
| 35 | /** |
| 36 | * @brief Adds a PEL to the repository |
| 37 | * |
| 38 | * Throws File.Error.Open or File.Error.Write exceptions on failure |
| 39 | * |
| 40 | * @param[in] pel - the PEL to add |
| 41 | */ |
| 42 | void add(std::unique_ptr<PEL>& pel); |
| 43 | |
| 44 | /** |
| 45 | * @brief Generates the filename to use for the PEL ID and BCDTime. |
| 46 | * |
| 47 | * @param[in] pelID - the PEL ID |
| 48 | * @param[in] time - the BCD time |
| 49 | * |
| 50 | * @return string - A filename string of <BCD_time>_<pelID> |
| 51 | */ |
| 52 | static std::string getPELFilename(uint32_t pelID, const BCDTime& time); |
| 53 | |
| 54 | private: |
| 55 | /** |
| 56 | * @brief The filesystem path to the PEL logs. |
| 57 | */ |
| 58 | const std::filesystem::path _logPath; |
| 59 | }; |
| 60 | |
| 61 | } // namespace pels |
| 62 | } // namespace openpower |