1254721Semaste//===-- UserID.h ------------------------------------------------*- C++ -*-===// 2254721Semaste// 3254721Semaste// The LLVM Compiler Infrastructure 4254721Semaste// 5254721Semaste// This file is distributed under the University of Illinois Open Source 6254721Semaste// License. See LICENSE.TXT for details. 7254721Semaste// 8254721Semaste//===----------------------------------------------------------------------===// 9254721Semaste 10254721Semaste 11254721Semaste#ifndef liblldb_UserID_h_ 12254721Semaste#define liblldb_UserID_h_ 13254721Semaste 14254721Semaste#include "lldb/lldb-private.h" 15254721Semaste 16254721Semastenamespace lldb_private { 17254721Semaste 18254721Semaste//---------------------------------------------------------------------- 19254721Semaste/// @class UserID UserID.h "lldb/Core/UserID.h" 20254721Semaste/// @brief A mix in class that contains a generic user ID. 21254721Semaste/// 22254721Semaste/// UserID is desinged as a mix in class that can contain an integer 23254721Semaste/// based unique identifier for a varietly of objects in lldb. 24254721Semaste/// 25254721Semaste/// The value for this identifier is chosen by each parser plug-in. A 26254721Semaste/// value should be chosen that makes sense for each kind of object 27254721Semaste/// should and allows quick access to further and more in depth parsing. 28254721Semaste/// 29254721Semaste/// Symbol table entries can use this to store the original symbol table 30254721Semaste/// index, functions can use it to store the symbol table index or the 31254721Semaste/// DWARF offset. 32254721Semaste//---------------------------------------------------------------------- 33254721Semastestruct UserID 34254721Semaste{ 35254721Semaste //------------------------------------------------------------------ 36254721Semaste /// Construct with optional user ID. 37254721Semaste //------------------------------------------------------------------ 38254721Semaste UserID (lldb::user_id_t uid = LLDB_INVALID_UID) : m_uid(uid) {} 39254721Semaste 40254721Semaste //------------------------------------------------------------------ 41254721Semaste /// Destructor. 42254721Semaste //------------------------------------------------------------------ 43254721Semaste ~UserID () 44254721Semaste { 45254721Semaste } 46254721Semaste 47254721Semaste //------------------------------------------------------------------ 48254721Semaste /// Clears the object state. 49254721Semaste /// 50254721Semaste /// Clears the object contents back to a default invalid state. 51254721Semaste //------------------------------------------------------------------ 52254721Semaste void 53254721Semaste Clear () { m_uid = LLDB_INVALID_UID; } 54254721Semaste 55254721Semaste //------------------------------------------------------------------ 56254721Semaste /// Get accessor for the user ID. 57254721Semaste /// 58254721Semaste /// @return 59254721Semaste /// The user ID. 60254721Semaste //------------------------------------------------------------------ 61254721Semaste lldb::user_id_t 62254721Semaste GetID () const { return m_uid; } 63254721Semaste 64254721Semaste //------------------------------------------------------------------ 65254721Semaste /// Set accessor for the user ID. 66254721Semaste /// 67254721Semaste /// @param[in] uid 68254721Semaste /// The new user ID. 69254721Semaste //------------------------------------------------------------------ 70254721Semaste void 71254721Semaste SetID (lldb::user_id_t uid) { m_uid = uid; } 72254721Semaste 73254721Semaste //------------------------------------------------------------------ 74254721Semaste /// Unary predicate function object that can search for a matching 75254721Semaste /// user ID. 76254721Semaste /// 77254721Semaste /// Function object that can be used on any class that inherits 78254721Semaste /// from UserID: 79254721Semaste /// \code 80254721Semaste /// iterator pos; 81254721Semaste /// pos = std::find_if (coll.begin(), coll.end(), UserID::IDMatches(blockID)); 82254721Semaste /// \endcode 83254721Semaste //------------------------------------------------------------------ 84254721Semaste class IDMatches 85254721Semaste { 86254721Semaste public: 87254721Semaste //-------------------------------------------------------------- 88254721Semaste /// Construct with the user ID to look for. 89254721Semaste //-------------------------------------------------------------- 90254721Semaste IDMatches (lldb::user_id_t uid) : m_uid(uid) {} 91254721Semaste 92254721Semaste //-------------------------------------------------------------- 93254721Semaste /// Unary predicate function object callback. 94254721Semaste //-------------------------------------------------------------- 95254721Semaste bool 96254721Semaste operator () (const UserID& rhs) const { return m_uid == rhs.GetID(); } 97254721Semaste 98254721Semaste private: 99254721Semaste //-------------------------------------------------------------- 100254721Semaste // Member variables. 101254721Semaste //-------------------------------------------------------------- 102254721Semaste const lldb::user_id_t m_uid; ///< The user ID we are looking for 103254721Semaste }; 104254721Semaste 105254721Semaste 106254721Semasteprotected: 107254721Semaste //------------------------------------------------------------------ 108254721Semaste // Member variables. 109254721Semaste //------------------------------------------------------------------ 110254721Semaste lldb::user_id_t m_uid; ///< The user ID that uniquely identifies an object. 111254721Semaste}; 112254721Semaste 113254721Semasteinline bool operator== (const UserID& lhs, const UserID& rhs) 114254721Semaste{ 115254721Semaste return lhs.GetID() == rhs.GetID(); 116254721Semaste} 117254721Semaste 118254721Semasteinline bool operator!= (const UserID& lhs, const UserID& rhs) 119254721Semaste{ 120254721Semaste return lhs.GetID() != rhs.GetID(); 121254721Semaste} 122254721Semaste 123254721Semaste//-------------------------------------------------------------- 124254721Semaste/// Stream the UserID object to a Stream. 125254721Semaste//-------------------------------------------------------------- 126254721SemasteStream& operator << (Stream& strm, const UserID& uid); 127254721Semaste 128254721Semaste} // namespace lldb_private 129254721Semaste 130254721Semaste#endif // liblldb_UserID_h_ 131