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