Crazy Eddie's GUI System
0.8.4
|
00001 /*********************************************************************** 00002 created: 21/2/2004 00003 author: Paul D Turner 00004 00005 purpose: Defines the Property class which forms part of a 00006 PropertySet 00007 *************************************************************************/ 00008 /*************************************************************************** 00009 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team 00010 * 00011 * Permission is hereby granted, free of charge, to any person obtaining 00012 * a copy of this software and associated documentation files (the 00013 * "Software"), to deal in the Software without restriction, including 00014 * without limitation the rights to use, copy, modify, merge, publish, 00015 * distribute, sublicense, and/or sell copies of the Software, and to 00016 * permit persons to whom the Software is furnished to do so, subject to 00017 * the following conditions: 00018 * 00019 * The above copyright notice and this permission notice shall be 00020 * included in all copies or substantial portions of the Software. 00021 * 00022 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00023 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00024 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00025 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00026 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00027 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00028 * OTHER DEALINGS IN THE SOFTWARE. 00029 ***************************************************************************/ 00030 #ifndef _CEGUIProperty_h_ 00031 #define _CEGUIProperty_h_ 00032 00033 #include "CEGUI/Base.h" 00034 #include "CEGUI/String.h" 00035 #include "CEGUI/XMLSerializer.h" 00036 00037 // Start of CEGUI namespace section 00038 namespace CEGUI 00039 { 00040 00045 class CEGUIEXPORT PropertyReceiver 00046 { 00047 public: 00048 PropertyReceiver() {} 00049 virtual ~PropertyReceiver() {} 00050 }; 00051 00052 00060 class CEGUIEXPORT Property : 00061 public AllocatedObject<Property> 00062 { 00063 public: 00064 static const String XMLElementName; 00065 static const String NameXMLAttributeName; 00066 static const String ValueXMLAttributeName; 00067 00091 Property(const String& name, const String& help, const String& defaultValue = "", bool writesXML = true, const String& dataType = "Unknown", const String& origin = "Unknown") : 00092 d_name(name), 00093 d_help(help), 00094 d_default(defaultValue), 00095 d_writeXML(writesXML), 00096 d_dataType(dataType), 00097 d_origin(origin) 00098 {} 00099 00104 virtual ~Property(void) {} 00105 00106 00114 const String& getHelp(void) const {return d_help;} 00115 00116 00124 const String& getName(void) const {return d_name;} 00125 00133 const String& getDataType(void) const {return d_dataType;} 00134 00142 const String& getOrigin(void) const {return d_origin;} 00143 00154 virtual String get(const PropertyReceiver* receiver) const = 0; 00155 00156 00172 virtual void set(PropertyReceiver* receiver, const String& value) = 0; 00173 00174 00186 virtual bool isDefault(const PropertyReceiver* receiver) const; 00187 00188 00199 virtual String getDefault(const PropertyReceiver* receiver) const; 00200 00201 00210 virtual void writeXMLToStream(const PropertyReceiver* receiver, XMLSerializer& xml_stream) const; 00211 00220 virtual bool isReadable() const; 00221 00230 virtual bool isWritable() const; 00231 00236 virtual bool doesWriteXML() const; 00237 00239 virtual void initialisePropertyReceiver(PropertyReceiver* /*receiver*/) const {} 00240 00241 virtual Property* clone() const = 0; 00242 00243 protected: 00244 String d_name; 00245 String d_help; 00246 String d_default; 00247 bool d_writeXML; 00248 // TODO: This is really ugly but PropertyDefinition forced me to do this to support operator= 00249 String d_dataType; 00250 // TODO: This is really ugly but PropertyDefinition forced me to do this to support operator= 00251 String d_origin; 00252 }; 00253 00254 } // End of CEGUI namespace section 00255 00256 #endif // end of guard _CEGUIProperty_h_