blob: 4ffe03eb26820f3fbc37ccf46af6d7cd90fe42ce [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:
Patrick Williams27dd6362023-05-10 07:51:20 -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;
Patrick Williams27dd6362023-05-10 07:51:20 -050023 Section(Section&&) = default;
24 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