AttributeSet.h revision 533eae20118036f425f27bf0536ef0ccbb090b65
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/ADT/Uncopyable.h>
12#include <vector>
13
14namespace mcld {
15
16class Attribute;
17
18/** \class AttributeSet
19 *  \brief AttributeSet is a set of Attribute.
20 *
21 *  Clients delegates Attributes to AttributeSet. AttributeSet deletes delegated
22 *  Attributes during destruction.
23 */
24class AttributeSet : private Uncopyable
25{
26private:
27  typedef std::vector<Attribute*> AttrSet;
28
29public:
30  typedef AttrSet::iterator iterator;
31  typedef AttrSet::const_iterator const_iterator;
32
33public:
34  AttributeSet(unsigned int pNum, const Attribute& pPredefined);
35
36  ~AttributeSet();
37
38  // -----  iterators  ----- //
39  const_iterator begin() const { return m_AttrSet.begin(); }
40  iterator       begin()       { return m_AttrSet.begin(); }
41  const_iterator end  () const { return m_AttrSet.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
51private:
52  AttrSet m_AttrSet;
53  const Attribute& m_Predefined;
54};
55
56} // namespace of mcld
57
58#endif
59
60