Crazy Eddie's GUI System  0.8.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Property.h
1 /***********************************************************************
2  filename: CEGUIProperty.h
3  created: 21/2/2004
4  author: Paul D Turner
5 
6  purpose: Defines the Property class which forms part of a
7  PropertySet
8 *************************************************************************/
9 /***************************************************************************
10  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining
13  * a copy of this software and associated documentation files (the
14  * "Software"), to deal in the Software without restriction, including
15  * without limitation the rights to use, copy, modify, merge, publish,
16  * distribute, sublicense, and/or sell copies of the Software, and to
17  * permit persons to whom the Software is furnished to do so, subject to
18  * the following conditions:
19  *
20  * The above copyright notice and this permission notice shall be
21  * included in all copies or substantial portions of the Software.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
27  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
28  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
29  * OTHER DEALINGS IN THE SOFTWARE.
30  ***************************************************************************/
31 #ifndef _CEGUIProperty_h_
32 #define _CEGUIProperty_h_
33 
34 #include "CEGUI/Base.h"
35 #include "CEGUI/String.h"
36 #include "CEGUI/XMLSerializer.h"
37 
38 // Start of CEGUI namespace section
39 namespace CEGUI
40 {
41 
46 class CEGUIEXPORT PropertyReceiver
47 {
48 public:
49  PropertyReceiver() {}
50  virtual ~PropertyReceiver() {}
51 };
52 
53 
61 class CEGUIEXPORT Property :
62  public AllocatedObject<Property>
63 {
64 public:
65  static const String XMLElementName;
66  static const String NameXMLAttributeName;
67  static const String ValueXMLAttributeName;
68 
92  Property(const String& name, const String& help, const String& defaultValue = "", bool writesXML = true, const String& dataType = "Unknown", const String& origin = "Unknown") :
93  d_name(name),
94  d_help(help),
95  d_default(defaultValue),
96  d_writeXML(writesXML),
97  d_dataType(dataType),
98  d_origin(origin)
99  {}
100 
105  virtual ~Property(void) {}
106 
107 
115  const String& getHelp(void) const {return d_help;}
116 
117 
125  const String& getName(void) const {return d_name;}
126 
134  const String& getDataType(void) const {return d_dataType;}
135 
143  const String& getOrigin(void) const {return d_origin;}
144 
155  virtual String get(const PropertyReceiver* receiver) const = 0;
156 
157 
173  virtual void set(PropertyReceiver* receiver, const String& value) = 0;
174 
175 
187  virtual bool isDefault(const PropertyReceiver* receiver) const;
188 
189 
200  virtual String getDefault(const PropertyReceiver* receiver) const;
201 
202 
211  virtual void writeXMLToStream(const PropertyReceiver* receiver, XMLSerializer& xml_stream) const;
212 
221  virtual bool isReadable() const;
222 
231  virtual bool isWritable() const;
232 
237  virtual bool doesWriteXML() const;
238 
240  virtual void initialisePropertyReceiver(PropertyReceiver* /*receiver*/) const {}
241 
242  virtual Property* clone() const = 0;
243 
244 protected:
248  bool d_writeXML;
249  // TODO: This is really ugly but PropertyDefinition forced me to do this to support operator=
251  // TODO: This is really ugly but PropertyDefinition forced me to do this to support operator=
253 };
254 
255 } // End of CEGUI namespace section
256 
257 #endif // end of guard _CEGUIProperty_h_