122add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao//===- AttributeSet.h -----------------------------------------------------===// 222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao// 322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao// The MCLinker Project 422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao// 522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao// This file is distributed under the University of Illinois Open Source 622add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao// License. See LICENSE.TXT for details. 722add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao// 822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao//===----------------------------------------------------------------------===// 937b74a387bb3993387029859c2d9d051c41c724eStephen Hines#ifndef MCLD_MC_ATTRIBUTESET_H_ 1037b74a387bb3993387029859c2d9d051c41c724eStephen Hines#define MCLD_MC_ATTRIBUTESET_H_ 1137b74a387bb3993387029859c2d9d051c41c724eStephen Hines#include "mcld/Support/Compiler.h" 1237b74a387bb3993387029859c2d9d051c41c724eStephen Hines 1322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao#include <vector> 1422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao 1522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaonamespace mcld { 1622add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao 1722add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaoclass Attribute; 1822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao 1922add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao/** \class AttributeSet 2022add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao * \brief AttributeSet is a set of Attribute. 2122add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao * 2222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao * Clients delegates Attributes to AttributeSet. AttributeSet deletes delegated 2322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao * Attributes during destruction. 2422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao */ 2537b74a387bb3993387029859c2d9d051c41c724eStephen Hinesclass AttributeSet { 2637b74a387bb3993387029859c2d9d051c41c724eStephen Hines private: 2722add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao typedef std::vector<Attribute*> AttrSet; 2822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao 2937b74a387bb3993387029859c2d9d051c41c724eStephen Hines public: 3022add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao typedef AttrSet::iterator iterator; 3122add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao typedef AttrSet::const_iterator const_iterator; 3222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao 3337b74a387bb3993387029859c2d9d051c41c724eStephen Hines public: 3422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao AttributeSet(unsigned int pNum, const Attribute& pPredefined); 3522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao 3622add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao ~AttributeSet(); 3722add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao 3822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao // ----- iterators ----- // 3922add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao const_iterator begin() const { return m_AttrSet.begin(); } 4037b74a387bb3993387029859c2d9d051c41c724eStephen Hines iterator begin() { return m_AttrSet.begin(); } 4137b74a387bb3993387029859c2d9d051c41c724eStephen Hines const_iterator end() const { return m_AttrSet.end(); } 4237b74a387bb3993387029859c2d9d051c41c724eStephen Hines iterator end() { return m_AttrSet.end(); } 4322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao 4422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao // exists- return the recorded attribute whose content is identical to the 4522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao // input attribute. 4637b74a387bb3993387029859c2d9d051c41c724eStephen Hines Attribute* exists(const Attribute& pAttr) const; 4722add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao 4822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao // record - record the attribute no mater if it has been recorded. 4922add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao void record(Attribute& pAttr); 5022add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao 5137b74a387bb3993387029859c2d9d051c41c724eStephen Hines private: 5222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao AttrSet m_AttrSet; 5322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao const Attribute& m_Predefined; 5422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao 5537b74a387bb3993387029859c2d9d051c41c724eStephen Hines private: 5637b74a387bb3993387029859c2d9d051c41c724eStephen Hines DISALLOW_COPY_AND_ASSIGN(AttributeSet); 5737b74a387bb3993387029859c2d9d051c41c724eStephen Hines}; 5822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao 5937b74a387bb3993387029859c2d9d051c41c724eStephen Hines} // namespace mcld 6022add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao 6137b74a387bb3993387029859c2d9d051c41c724eStephen Hines#endif // MCLD_MC_ATTRIBUTESET_H_ 62