1/*
2 * File:	OutputSection.h
3 *
4 * Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
5 * See included license file for license details.
6 */
7#if !defined(_OutputSection_h_)
8#define _OutputSection_h_
9
10#include "Operation.h"
11#include "smart_ptr.h"
12#include "Blob.h"
13#include "OptionContext.h"
14
15namespace elftosb
16{
17
18/*!
19 * @brief Base class for data model of sections of the output file.
20 */
21class OutputSection
22{
23public:
24	OutputSection() : m_id(0), m_options(0) {}
25	OutputSection(uint32_t identifier) : m_id(identifier), m_options(0) {}
26	virtual ~OutputSection() {}
27
28	void setIdentifier(uint32_t identifier) { m_id = identifier; }
29	uint32_t getIdentifier() const { return m_id; }
30
31	//! \brief Set the option context.
32	//!
33	//! The output section object will assume ownership of the option context
34	//! and delete it when the section is deleted.
35	inline void setOptions(OptionContext * context) { m_options = context; }
36
37	//! \brief Return the option context.
38	inline const OptionContext * getOptions() const { return m_options; }
39
40protected:
41	uint32_t m_id;	//!< Unique identifier.
42	smart_ptr<OptionContext> m_options;	//!< Options associated with just this section.
43};
44
45/*!
46 * @brief A section of the output that contains boot operations.
47 */
48class OperationSequenceSection : public OutputSection
49{
50public:
51	OperationSequenceSection() : OutputSection() {}
52	OperationSequenceSection(uint32_t identifier) : OutputSection(identifier) {}
53
54	OperationSequence & getSequence() { return m_sequence; }
55
56protected:
57	OperationSequence m_sequence;
58};
59
60/*!
61 * @brief A section of the output file that contains arbitrary binary data.
62 */
63class BinaryDataSection : public OutputSection, public Blob
64{
65public:
66	BinaryDataSection() : OutputSection(), Blob() {}
67	BinaryDataSection(uint32_t identifier) : OutputSection(identifier), Blob() {}
68};
69
70}; // namespace elftosb
71
72#endif // _OutputSection_h_
73