1 //===- AttributeSet.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_MC_ATTRIBUTESET_H_
10 #define MCLD_MC_ATTRIBUTESET_H_
11 #include "mcld/Support/Compiler.h"
12 
13 #include <vector>
14 
15 namespace mcld {
16 
17 class Attribute;
18 
19 /** \class AttributeSet
20  *  \brief AttributeSet is a set of Attribute.
21  *
22  *  Clients delegates Attributes to AttributeSet. AttributeSet deletes delegated
23  *  Attributes during destruction.
24  */
25 class AttributeSet {
26  private:
27   typedef std::vector<Attribute*> AttrSet;
28 
29  public:
30   typedef AttrSet::iterator iterator;
31   typedef AttrSet::const_iterator const_iterator;
32 
33  public:
34   AttributeSet(unsigned int pNum, const Attribute& pPredefined);
35 
36   ~AttributeSet();
37 
38   // -----  iterators  ----- //
begin()39   const_iterator begin() const { return m_AttrSet.begin(); }
begin()40   iterator begin() { return m_AttrSet.begin(); }
end()41   const_iterator end() const { return m_AttrSet.end(); }
end()42   iterator end() { return m_AttrSet.end(); }
43 
44   // exists- return the recorded attribute whose content is identical to the
45   // input attribute.
46   Attribute* exists(const Attribute& pAttr) const;
47 
48   // record - record the attribute no mater if it has been recorded.
49   void record(Attribute& pAttr);
50 
51  private:
52   AttrSet m_AttrSet;
53   const Attribute& m_Predefined;
54 
55  private:
56   DISALLOW_COPY_AND_ASSIGN(AttributeSet);
57 };
58 
59 }  // namespace mcld
60 
61 #endif  // MCLD_MC_ATTRIBUTESET_H_
62