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