blob: d0f88e11286a1d4147b79c2e8255a270363ad755 [file] [log] [blame]
Matt Spinlerd3335df2019-07-10 11:04:21 -05001#pragma once
2#include "section_header.hpp"
3
4namespace openpower
5{
6namespace pels
7{
8
9/**
10 * @class Section
11 *
12 * The base class for a PEL section. It contains the SectionHeader
13 * as all sections start with it.
14 *
15 */
16class Section
17{
18 public:
19 Section() = default;
20 virtual ~Section() = default;
21 Section(const Section&) = default;
22 Section& operator=(const Section&) = default;
23 Section(Section&&) = default;
24 Section& operator=(Section&&) = default;
25
26 /**
27 * @brief Returns a reference to the SectionHeader
28 */
29 SectionHeader& header()
30 {
31 return _header;
32 }
33
34 /**
35 * @brief Says if the section is valid.
36 */
37 bool valid() const
38 {
39 return _valid;
40 }
41
Matt Spinlercf5a8d02019-09-05 12:58:53 -050042 /**
43 * @brief Flatten the section into the stream
44 *
45 * @param[in] stream - The stream to write to
46 */
47 virtual void flatten(Stream& stream) = 0;
48
Matt Spinlerd3335df2019-07-10 11:04:21 -050049 protected:
50 /**
51 * @brief Returns the flattened size of the section header
52 */
53 static constexpr size_t flattenedSize()
54 {
55 return SectionHeader::flattenedSize();
56 }
57
58 /**
59 * @brief Used to validate the section.
60 *
61 * Implemented by derived classes.
62 */
63 virtual void validate() = 0;
64
65 /**
66 * @brief The section header structure.
67 *
68 * Filled in by derived classes.
69 */
70 SectionHeader _header;
71
72 /**
73 * @brief The section valid flag.
74 *
75 * This is determined by the derived class.
76 */
77 bool _valid = false;
78};
79} // namespace pels
80} // namespace openpower