1 #pragma once
2 #include "section_header.hpp"
3 
4 namespace openpower
5 {
6 namespace 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  */
16 class 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 
42     /**
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 
49   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
81