[692] | 1 | /************************************************************************
|
---|
| 2 | filename: CEGUIPropertySet.h
|
---|
| 3 | created: 21/2/2004
|
---|
| 4 | author: Paul D Turner
|
---|
| 5 |
|
---|
| 6 | purpose: Defines interface for the PropertySet class
|
---|
| 7 | *************************************************************************/
|
---|
| 8 | /*************************************************************************
|
---|
| 9 | Crazy Eddie's GUI System (http://www.cegui.org.uk)
|
---|
| 10 | Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
|
---|
| 11 |
|
---|
| 12 | This library is free software; you can redistribute it and/or
|
---|
| 13 | modify it under the terms of the GNU Lesser General Public
|
---|
| 14 | License as published by the Free Software Foundation; either
|
---|
| 15 | version 2.1 of the License, or (at your option) any later version.
|
---|
| 16 |
|
---|
| 17 | This library is distributed in the hope that it will be useful,
|
---|
| 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | Lesser General Public License for more details.
|
---|
| 21 |
|
---|
| 22 | You should have received a copy of the GNU Lesser General Public
|
---|
| 23 | License along with this library; if not, write to the Free Software
|
---|
| 24 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
| 25 | *************************************************************************/
|
---|
| 26 | #ifndef _CEGUIPropertySet_h_
|
---|
| 27 | #define _CEGUIPropertySet_h_
|
---|
| 28 |
|
---|
| 29 | #include "CEGUIBase.h"
|
---|
| 30 | #include "CEGUIString.h"
|
---|
| 31 | #include "CEGUIIteratorBase.h"
|
---|
| 32 | #include "CEGUIProperty.h"
|
---|
| 33 | #include <map>
|
---|
| 34 |
|
---|
| 35 |
|
---|
| 36 | #if defined(_MSC_VER)
|
---|
| 37 | # pragma warning(push)
|
---|
| 38 | # pragma warning(disable : 4251)
|
---|
| 39 | #endif
|
---|
| 40 |
|
---|
| 41 | // Start of CEGUI namespace section
|
---|
| 42 | namespace CEGUI
|
---|
| 43 | {
|
---|
| 44 | /*!
|
---|
| 45 | \brief
|
---|
| 46 | Class that contains a collection of Property objects.
|
---|
| 47 | */
|
---|
| 48 | class CEGUIEXPORT PropertySet : public PropertyReceiver
|
---|
| 49 | {
|
---|
| 50 | public:
|
---|
| 51 | /*!
|
---|
| 52 | \brief
|
---|
| 53 | Constructs a new PropertySet object
|
---|
| 54 | */
|
---|
| 55 | PropertySet(void) {}
|
---|
| 56 |
|
---|
| 57 |
|
---|
| 58 | /*!
|
---|
| 59 | \brief
|
---|
| 60 | Destructor for PropertySet objects.
|
---|
| 61 | */
|
---|
| 62 | virtual ~PropertySet(void) {}
|
---|
| 63 |
|
---|
| 64 |
|
---|
| 65 | /*!
|
---|
| 66 | \brief
|
---|
| 67 | Adds a new Property to the PropertySet
|
---|
| 68 |
|
---|
| 69 | \param property
|
---|
| 70 | Pointer to the Property object to be added to the PropertySet.
|
---|
| 71 |
|
---|
| 72 | \return
|
---|
| 73 | Nothing.
|
---|
| 74 |
|
---|
| 75 | \exception NullObjectException Thrown if \a property is NULL.
|
---|
| 76 | \exception AlreadyExistsException Thrown if a Property with the same name as \a property already exists in the PropertySet
|
---|
| 77 | */
|
---|
| 78 | void addProperty(Property* property);
|
---|
| 79 |
|
---|
| 80 |
|
---|
| 81 | /*!
|
---|
| 82 | \brief
|
---|
| 83 | Removes a Property from the PropertySet.
|
---|
| 84 |
|
---|
| 85 | \param name
|
---|
| 86 | String containing the name of the Property to be removed. If Property \a name is not in the set, nothing happens.
|
---|
| 87 |
|
---|
| 88 | \return
|
---|
| 89 | Nothing.
|
---|
| 90 | */
|
---|
| 91 | void removeProperty(const String& name);
|
---|
| 92 |
|
---|
| 93 |
|
---|
| 94 | /*!
|
---|
| 95 | \brief
|
---|
| 96 | Removes all Property objects from the PropertySet.
|
---|
| 97 |
|
---|
| 98 | \return
|
---|
| 99 | Nothing.
|
---|
| 100 | */
|
---|
| 101 | void clearProperties(void);
|
---|
| 102 |
|
---|
| 103 |
|
---|
| 104 | /*!
|
---|
| 105 | \brief
|
---|
| 106 | Checks to see if a Property with the given name is in the PropertySet
|
---|
| 107 |
|
---|
| 108 | \param name
|
---|
| 109 | String containing the name of the Property to check for.
|
---|
| 110 |
|
---|
| 111 | \return
|
---|
| 112 | true if a Property named \a name is in the PropertySet. false if no Property named \a name is in the PropertySet.
|
---|
| 113 | */
|
---|
| 114 | bool isPropertyPresent(const String& name) const;
|
---|
| 115 |
|
---|
| 116 |
|
---|
| 117 | /*!
|
---|
| 118 | \brief
|
---|
| 119 | Return the help text for the specified Property.
|
---|
| 120 |
|
---|
| 121 | \param name
|
---|
| 122 | String holding the name of the Property who's help text is to be returned.
|
---|
| 123 |
|
---|
| 124 | \return
|
---|
| 125 | String object containing the help text for the Property \a name.
|
---|
| 126 |
|
---|
| 127 | \exception UnknownObjectException Thrown if no Property named \a name is in the PropertySet.
|
---|
| 128 | */
|
---|
| 129 | const String& getPropertyHelp(const String& name) const;
|
---|
| 130 |
|
---|
| 131 |
|
---|
| 132 | /*!
|
---|
| 133 | \brief
|
---|
| 134 | Gets the current value of the specified Property.
|
---|
| 135 |
|
---|
| 136 | \param name
|
---|
| 137 | String containing the name of the Property who's value is to be returned.
|
---|
| 138 |
|
---|
| 139 | \return
|
---|
| 140 | String object containing a textual representation of the requested Property.
|
---|
| 141 |
|
---|
| 142 | \exception UnknownObjectException Thrown if no Property named \a name is in the PropertySet.
|
---|
| 143 | */
|
---|
| 144 | String getProperty(const String& name) const;
|
---|
| 145 |
|
---|
| 146 |
|
---|
| 147 | /*!
|
---|
| 148 | \brief
|
---|
| 149 | Sets the current value of a Property.
|
---|
| 150 |
|
---|
| 151 | \param name
|
---|
| 152 | String containing the name of the Property who's value is to be set.
|
---|
| 153 |
|
---|
| 154 | \param value
|
---|
| 155 | String containing a textual representation of the new value for the Property
|
---|
| 156 |
|
---|
| 157 | \return
|
---|
| 158 | Nothing
|
---|
| 159 |
|
---|
| 160 | \exception UnknownObjectException Thrown if no Property named \a name is in the PropertySet.
|
---|
| 161 | \exception InvalidRequestException Thrown when the Property was unable to interpret the content of \a value.
|
---|
| 162 | */
|
---|
| 163 | void setProperty(const String& name, const String& value);
|
---|
| 164 |
|
---|
| 165 |
|
---|
| 166 | /*!
|
---|
| 167 | \brief
|
---|
| 168 | Returns whether a Property is at it's default value.
|
---|
| 169 |
|
---|
| 170 | \param name
|
---|
| 171 | String containing the name of the Property who's default state is to be tested.
|
---|
| 172 |
|
---|
| 173 | \return
|
---|
| 174 | - true if the property has it's default value.
|
---|
| 175 | - false if the property has been modified from it's default value.
|
---|
| 176 | */
|
---|
| 177 | bool isPropertyDefault(const String& name) const;
|
---|
| 178 |
|
---|
| 179 |
|
---|
| 180 | /*!
|
---|
| 181 | \brief
|
---|
| 182 | Returns the default value of a Property as a String.
|
---|
| 183 |
|
---|
| 184 | \param name
|
---|
| 185 | String containing the name of the Property who's default string is to be returned.
|
---|
| 186 |
|
---|
| 187 | \return
|
---|
| 188 | String object containing a textual representation of the default value for this property.
|
---|
| 189 | */
|
---|
| 190 | String getPropertyDefault(const String& name) const;
|
---|
| 191 |
|
---|
| 192 | private:
|
---|
| 193 | typedef std::map<String, Property*> PropertyRegistry;
|
---|
| 194 | PropertyRegistry d_properties;
|
---|
| 195 |
|
---|
| 196 |
|
---|
| 197 | public:
|
---|
| 198 | /*************************************************************************
|
---|
| 199 | Iterator stuff
|
---|
| 200 | *************************************************************************/
|
---|
| 201 | typedef ConstBaseIterator<PropertyRegistry> PropertyIterator;
|
---|
| 202 |
|
---|
| 203 | /*!
|
---|
| 204 | \brief
|
---|
| 205 | Return a PropertySet::PropertyIterator object to iterate over the available Properties.
|
---|
| 206 | */
|
---|
| 207 | PropertyIterator getIterator(void) const;
|
---|
| 208 | };
|
---|
| 209 |
|
---|
| 210 | } // End of CEGUI namespace section
|
---|
| 211 |
|
---|
| 212 | #if defined(_MSC_VER)
|
---|
| 213 | # pragma warning(pop)
|
---|
| 214 | #endif
|
---|
| 215 |
|
---|
| 216 | #endif // end of guard _CEGUIPropertySet_h_
|
---|