blob: ca8dce40735713d9f1cc3c713cda55095f3e87d3 [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:
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 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