libyui  3.4.2
YWidgetID.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YWidgetID.h
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 #ifndef YWidgetID_h
26 #define YWidgetID_h
27 
28 #include <iosfwd>
29 #include <string>
30 
31 
32 
33 /**
34  * Abstract base class for widget IDs.
35  **/
36 class YWidgetID
37 {
38 protected:
39  /**
40  * Constructor. Protected since this is an abstract base class.
41  **/
42  YWidgetID() {}
43 
44 public:
45  /**
46  * Destructor.
47  **/
48  virtual ~YWidgetID() {}
49 
50  /**
51  * Check if this ID is equal to another.
52  **/
53  virtual bool isEqual( YWidgetID * otherID ) const = 0;
54 
55  /**
56  * Convert the ID value to string.
57  * Used for logging and debugging.
58  **/
59  virtual std::string toString() const = 0;
60 
61 private:
62  /**
63  * Copy constructor is disabled.
64  **/
65  YWidgetID( const YWidgetID & orig );
66 };
67 
68 
69 /**
70  * Simple widget ID class based on strings.
71  **/
73 {
74 public:
75 
76  /**
77  * Constructor.
78  **/
79  YStringWidgetID( const std::string & value );
80 
81  /**
82  * Destructor.
83  **/
84  virtual ~YStringWidgetID();
85 
86  /**
87  * Check if this ID is equal to another.
88  *
89  * Reimplemented from YWidgetID.
90  **/
91  virtual bool isEqual( YWidgetID * otherID ) const;
92 
93  /**
94  * Convert the ID value to string.
95  * Used for logging and debugging.
96  *
97  * Reimplemented from YWidgetID.
98  **/
99  virtual std::string toString() const;
100 
101  /**
102  * Return the ID value.
103  **/
104  std::string value() const;
105 
106  /**
107  * Return the ID value as a const ref.
108  **/
109  const std::string & valueConstRef() const;
110 
111 private:
112  std::string _value;
113 };
114 
115 std::ostream & operator<<( std::ostream & stream, const YWidgetID * id );
116 
117 
118 #endif // YWidgetID_h
virtual bool isEqual(YWidgetID *otherID) const =0
Check if this ID is equal to another.
Simple widget ID class based on strings.
Definition: YWidgetID.h:72
virtual std::string toString() const =0
Convert the ID value to string.
virtual ~YWidgetID()
Destructor.
Definition: YWidgetID.h:48
YWidgetID()
Constructor.
Definition: YWidgetID.h:42
Abstract base class for widget IDs.
Definition: YWidgetID.h:36