1//===- SectionData.h ------------------------------------------------------===//
2//
3//                     The MCLinker Project
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9#ifndef MCLD_LD_SECTION_DATA_H
10#define MCLD_LD_SECTION_DATA_H
11#ifdef ENABLE_UNITTEST
12#include <gtest.h>
13#endif
14
15#include <llvm/ADT/ilist.h>
16#include <llvm/ADT/ilist_node.h>
17#include <llvm/Support/DataTypes.h>
18
19#include <mcld/LD/Fragment.h>
20
21namespace mcld
22{
23
24class LDSection;
25
26/** \class SectionData
27 *  \brief SectionData provides a container for all Fragments.
28 */
29class SectionData
30{
31private:
32  SectionData(const SectionData &);            // DO NOT IMPLEMENT
33  SectionData& operator=(const SectionData &); // DO NOT IMPLEMENT
34
35public:
36  typedef llvm::iplist<Fragment> FragmentListType;
37  typedef FragmentListType::iterator iterator;
38  typedef FragmentListType::const_iterator const_iterator;
39
40  typedef FragmentListType::reverse_iterator reverse_iterator;
41  typedef FragmentListType::const_reverse_iterator const_reverse_iterator;
42
43public:
44  explicit SectionData(const LDSection &pSection);
45
46  const LDSection &getSection() const { return *m_pSection; }
47
48  unsigned int getAlignment() const { return m_Alignment; }
49  void setAlignment(unsigned int pValue) { m_Alignment = pValue; }
50
51  FragmentListType &getFragmentList() { return m_Fragments; }
52  const FragmentListType &getFragmentList() const { return m_Fragments; }
53
54  iterator begin() { return m_Fragments.begin(); }
55  const_iterator begin() const { return m_Fragments.begin(); }
56
57  iterator end() { return m_Fragments.end(); }
58  const_iterator end() const { return m_Fragments.end(); }
59
60  reverse_iterator rbegin() { return m_Fragments.rbegin(); }
61  const_reverse_iterator rbegin() const { return m_Fragments.rbegin(); }
62
63  reverse_iterator rend() { return m_Fragments.rend(); }
64  const_reverse_iterator rend() const { return m_Fragments.rend(); }
65
66  size_t size() const { return m_Fragments.size(); }
67
68  bool empty() const { return m_Fragments.empty(); }
69
70private:
71  FragmentListType m_Fragments;
72  const LDSection* m_pSection;
73  unsigned int m_Alignment;
74
75};
76
77} // namespace of mcld
78
79#endif
80
81