libyui
3.0.10
|
00001 /* 00002 Copyright (C) 2000-2012 Novell, Inc 00003 This library is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU Lesser General Public License as 00005 published by the Free Software Foundation; either version 2.1 of the 00006 License, or (at your option) version 3.0 of the License. This library 00007 is distributed in the hope that it will be useful, but WITHOUT ANY 00008 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00009 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00010 License for more details. You should have received a copy of the GNU 00011 Lesser General Public License along with this library; if not, write 00012 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth 00013 Floor, Boston, MA 02110-1301 USA 00014 */ 00015 00016 00017 /*-/ 00018 00019 File: YWidgetID.h 00020 00021 Author: Stefan Hundhammer <sh@suse.de> 00022 00023 /-*/ 00024 00025 #ifndef YWidgetID_h 00026 #define YWidgetID_h 00027 00028 #include <iosfwd> 00029 #include <string> 00030 00031 00032 00033 /** 00034 * Abstract base class for widget IDs. 00035 **/ 00036 class YWidgetID 00037 { 00038 protected: 00039 /** 00040 * Constructor. Protected since this is an abstract base class. 00041 **/ 00042 YWidgetID() {} 00043 00044 public: 00045 /** 00046 * Destructor. 00047 **/ 00048 virtual ~YWidgetID() {} 00049 00050 /** 00051 * Check if this ID is equal to another. 00052 **/ 00053 virtual bool isEqual( YWidgetID * otherID ) const = 0; 00054 00055 /** 00056 * Convert the ID value to string. 00057 * Used for logging and debugging. 00058 **/ 00059 virtual std::string toString() const = 0; 00060 00061 private: 00062 /** 00063 * Copy constructor is disabled. 00064 **/ 00065 YWidgetID( const YWidgetID & orig ); 00066 }; 00067 00068 00069 /** 00070 * Simple widget ID class based on strings. 00071 **/ 00072 class YStringWidgetID: public YWidgetID 00073 { 00074 public: 00075 00076 /** 00077 * Constructor. 00078 **/ 00079 YStringWidgetID( const std::string & value ); 00080 00081 /** 00082 * Destructor. 00083 **/ 00084 virtual ~YStringWidgetID(); 00085 00086 /** 00087 * Check if this ID is equal to another. 00088 * 00089 * Reimplemented from YWidgetID. 00090 **/ 00091 virtual bool isEqual( YWidgetID * otherID ) const; 00092 00093 /** 00094 * Convert the ID value to string. 00095 * Used for logging and debugging. 00096 * 00097 * Reimplemented from YWidgetID. 00098 **/ 00099 virtual std::string toString() const; 00100 00101 /** 00102 * Return the ID value. 00103 **/ 00104 std::string value() const; 00105 00106 /** 00107 * Return the ID value as a const ref. 00108 **/ 00109 const std::string & valueConstRef() const; 00110 00111 private: 00112 std::string _value; 00113 }; 00114 00115 std::ostream & operator<<( std::ostream & stream, const YWidgetID * id ); 00116 00117 00118 #endif // YWidgetID_h