blob: 6d18822a2eae28c7812a4e6388ba5427cf75bb3d [file] [log] [blame]
Ben Tynerf5210bb2021-01-05 12:58:10 -06001#pragma once
2
3#include "section_header.hpp"
4
5namespace attn
6{
7namespace pel
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:
Zane Shelleyb82cbf72022-06-27 10:28:06 -050019 Section() = default;
20 virtual ~Section() = default;
21 Section(const Section&) = default;
Ben Tynerf5210bb2021-01-05 12:58:10 -060022 Section& operator=(const Section&) = default;
23 Section(Section&&) = default;
Zane Shelleyb82cbf72022-06-27 10:28:06 -050024 Section& operator=(Section&&) = default;
Ben Tynerf5210bb2021-01-05 12:58:10 -060025
26 /**
27 * @brief Returns a reference to the SectionHeader
28 */
29 const SectionHeader& header() const
30 {
31 return _header;
32 }
33
34 /**
35 * @brief Flatten the section into the stream
36 *
37 * @param[in] stream - The stream to write to
38 */
39 virtual void flatten(Stream& stream) const = 0;
40
41 protected:
42 /**
43 * @brief Returns the flattened size of the section header
44 */
45 static constexpr size_t flattenedSize()
46 {
47 return SectionHeader::flattenedSize();
48 }
49
50 /**
51 * @brief The section header structure.
52 *
53 * Filled in by derived classes.
54 */
55 SectionHeader _header;
56};
57
58} // namespace pel
59} // namespace attn