Crazy Eddie's GUI System  0.8.7
Property.h
1 /***********************************************************************
2  created: 21/2/2004
3  author: Paul D Turner
4 
5  purpose: Defines the Property class which forms part of a
6  PropertySet
7 *************************************************************************/
8 /***************************************************************************
9  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _CEGUIProperty_h_
31 #define _CEGUIProperty_h_
32 
33 #include "CEGUI/Base.h"
34 #include "CEGUI/String.h"
35 #include "CEGUI/XMLSerializer.h"
36 
37 // Start of CEGUI namespace section
38 namespace CEGUI
39 {
40 
45 class CEGUIEXPORT PropertyReceiver
46 {
47 public:
48  PropertyReceiver() {}
49  virtual ~PropertyReceiver() {}
50 };
51 
52 
60 class CEGUIEXPORT Property :
61  public AllocatedObject<Property>
62 {
63 public:
64  static const String XMLElementName;
65  static const String NameXMLAttributeName;
66  static const String ValueXMLAttributeName;
67 
91  Property(const String& name, const String& help, const String& defaultValue = "", bool writesXML = true, const String& dataType = "Unknown", const String& origin = "Unknown") :
92  d_name(name),
93  d_help(help),
94  d_default(defaultValue),
95  d_writeXML(writesXML),
96  d_dataType(dataType),
97  d_origin(origin)
98  {}
99 
104  virtual ~Property(void) {}
105 
106 
114  const String& getHelp(void) const {return d_help;}
115 
116 
124  const String& getName(void) const {return d_name;}
125 
133  const String& getDataType(void) const {return d_dataType;}
134 
142  const String& getOrigin(void) const {return d_origin;}
143 
154  virtual String get(const PropertyReceiver* receiver) const = 0;
155 
156 
172  virtual void set(PropertyReceiver* receiver, const String& value) = 0;
173 
174 
186  virtual bool isDefault(const PropertyReceiver* receiver) const;
187 
188 
199  virtual String getDefault(const PropertyReceiver* receiver) const;
200 
201 
210  virtual void writeXMLToStream(const PropertyReceiver* receiver, XMLSerializer& xml_stream) const;
211 
220  virtual bool isReadable() const;
221 
230  virtual bool isWritable() const;
231 
236  virtual bool doesWriteXML() const;
237 
239  virtual void initialisePropertyReceiver(PropertyReceiver* /*receiver*/) const {}
240 
241  virtual Property* clone() const = 0;
242 
243 protected:
247  bool d_writeXML;
248  // TODO: This is really ugly but PropertyDefinition forced me to do this to support operator=
250  // TODO: This is really ugly but PropertyDefinition forced me to do this to support operator=
252 };
253 
254 } // End of CEGUI namespace section
255 
256 #endif // end of guard _CEGUIProperty_h_
String d_origin
Holds origin of this property.
Definition: Property.h:251
const String & getOrigin(void) const
Return string origin of this Property.
Definition: Property.h:142
Definition: MemoryAllocatedObject.h:109
const String & getName(void) const
Return a the name of this Property.
Definition: Property.h:124
bool d_writeXML
Specifies whether writeXMLToStream should do anything for this property.
Definition: Property.h:247
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
String d_name
String that stores the Property name.
Definition: Property.h:244
String d_dataType
Holds data type of this property.
Definition: Property.h:249
Dummy base class to ensure correct casting of receivers.
Definition: Property.h:45
const String & getHelp(void) const
Return a String that describes the purpose and usage of this Property.
Definition: Property.h:114
String d_default
String that stores the Property default value string.
Definition: Property.h:246
const String & getDataType(void) const
Return string data type of this Property.
Definition: Property.h:133
An abstract class that defines the interface to access object properties by name. ...
Definition: Property.h:60
String d_help
String that stores the Property help text.
Definition: Property.h:245
Property(const String &name, const String &help, const String &defaultValue="", bool writesXML=true, const String &dataType="Unknown", const String &origin="Unknown")
Creates a new Property object.
Definition: Property.h:91
virtual ~Property(void)
Destructor for Property objects.
Definition: Property.h:104
Class used to create XML Document.
Definition: XMLSerializer.h:85
String class used within the GUI system.
Definition: String.h:62
virtual void initialisePropertyReceiver(PropertyReceiver *) const
function to allow initialisation of a PropertyReceiver.
Definition: Property.h:239