blob: 7214e17645de2c287c233c7beabdc9734a67b873 [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
42 protected:
43 /**
44 * @brief Returns the flattened size of the section header
45 */
46 static constexpr size_t flattenedSize()
47 {
48 return SectionHeader::flattenedSize();
49 }
50
51 /**
52 * @brief Used to validate the section.
53 *
54 * Implemented by derived classes.
55 */
56 virtual void validate() = 0;
57
58 /**
59 * @brief The section header structure.
60 *
61 * Filled in by derived classes.
62 */
63 SectionHeader _header;
64
65 /**
66 * @brief The section valid flag.
67 *
68 * This is determined by the derived class.
69 */
70 bool _valid = false;
71};
72} // namespace pels
73} // namespace openpower