Crazy Eddies GUI System 0.7.5

CEGUIConfig_xmlHandler.h

00001 /***********************************************************************
00002     filename:   CEGUIConfig_xmlHandler.h
00003     created:    Sat Jul 25 2009
00004     author:     Paul D Turner <paul@cegui.org.uk>
00005 *************************************************************************/
00006 /***************************************************************************
00007  *   Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team
00008  *
00009  *   Permission is hereby granted, free of charge, to any person obtaining
00010  *   a copy of this software and associated documentation files (the
00011  *   "Software"), to deal in the Software without restriction, including
00012  *   without limitation the rights to use, copy, modify, merge, publish,
00013  *   distribute, sublicense, and/or sell copies of the Software, and to
00014  *   permit persons to whom the Software is furnished to do so, subject to
00015  *   the following conditions:
00016  *
00017  *   The above copyright notice and this permission notice shall be
00018  *   included in all copies or substantial portions of the Software.
00019  *
00020  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00021  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00022  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00023  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00024  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00025  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00026  *   OTHER DEALINGS IN THE SOFTWARE.
00027  ***************************************************************************/
00028 #ifndef _CEGUIConfig_xmlHandler_h_
00029 #define _CEGUIConfig_xmlHandler_h_
00030 
00031 #include "CEGUIBase.h"
00032 #include "CEGUIString.h"
00033 #include "CEGUILogger.h"
00034 #include "CEGUIXMLHandler.h"
00035 #include <vector>
00036 
00037 #if defined (_MSC_VER)
00038 #   pragma warning(push)
00039 #   pragma warning(disable : 4251)
00040 #endif
00041 
00042 // Start of CEGUI namespace section
00043 namespace CEGUI
00044 {
00046 class Config_xmlHandler : public XMLHandler
00047 {
00048 public:
00050     static const String CEGUIConfigSchemaName;
00051     // xml tag names
00052     static const String CEGUIConfigElement;
00053     static const String LoggingElement;
00054     static const String AutoLoadElement;
00055     static const String ResourceDirectoryElement;
00056     static const String DefaultResourceGroupElement;
00057     static const String ScriptingElement;
00058     static const String XMLParserElement;
00059     static const String ImageCodecElement;
00060     static const String DefaultFontElement;
00061     static const String DefaultMouseCursorElement;
00062     static const String DefaultTooltipElement;
00063     static const String DefaultGUISheetElement;
00064     // xml attribute names
00065     static const String FilenameAttribute;
00066     static const String LevelAttribute;
00067     static const String TypeAttribute;
00068     static const String GroupAttribute;
00069     static const String PatternAttribute;
00070     static const String DirectoryAttribute;
00071     static const String InitScriptAttribute;
00072     static const String TerminateScriptAttribute;
00073     static const String ImagesetAttribute;
00074     static const String ImageAttribute;
00075     static const String NameAttribute;
00076 
00078     Config_xmlHandler();
00079 
00081     ~Config_xmlHandler();
00082 
00084     void initialiseXMLParser() const;
00086     void initialiseImageCodec() const;
00088     void initialiseLogger(const String& default_filename) const;
00090     void initialiseResourceGroupDirectories() const;
00092     void initialiseDefaultResourceGroups() const;
00094     void loadAutoResources() const;
00096     void initialiseDefaultFont() const;
00098     void initialiseDefaultMouseCursor() const;
00100     void initialiseDefaulTooltip() const;
00102     void initialiseDefaultGUISheet() const;
00104     void executeInitScript() const;
00106     const String& getTerminateScriptName() const;
00107 
00108     // XMLHandler overrides
00109     void elementStart(const String& element, const XMLAttributes& attributes);
00110     void elementEnd(const String& element);
00111 
00112 private:
00114     enum ResourceType
00115     {
00116         RT_IMAGESET,
00117         RT_FONT,
00118         RT_SCHEME,
00119         RT_LOOKNFEEL,
00120         RT_LAYOUT,
00121         RT_SCRIPT,
00122         RT_XMLSCHEMA,
00123         RT_DEFAULT
00124     };
00125 
00127     struct ResourceDirectory
00128     {
00129         String group;
00130         String directory;
00131     };
00132 
00134     struct DefaultResourceGroup
00135     {
00136         ResourceType type;
00137         String group;
00138     };
00139 
00141     struct AutoLoadResource
00142     {
00143         String type_string;
00144         ResourceType type;
00145         String group;
00146         String pattern;
00147     };
00148 
00149     // functions to handle the various elements
00150     void handleCEGUIConfigElement(const XMLAttributes& attr);
00151     void handleLoggingElement(const XMLAttributes& attr);
00152     void handleAutoLoadElement(const XMLAttributes& attr);
00153     void handleResourceDirectoryElement(const XMLAttributes& attr);
00154     void handleDefaultResourceGroupElement(const XMLAttributes& attr);
00155     void handleScriptingElement(const XMLAttributes& attr);
00156     void handleXMLParserElement(const XMLAttributes& attr);
00157     void handleImageCodecElement(const XMLAttributes& attr);
00158     void handleDefaultTooltipElement(const XMLAttributes& attr);
00159     void handleDefaultGUISheetElement(const XMLAttributes& attr);
00160     void handleDefaultFontElement(const XMLAttributes& attr);
00161     void handleDefaultMouseCursorElement(const XMLAttributes& attr);
00162 
00164     ResourceType stringToResourceType(const String& type) const;
00166     void autoLoadLayouts(const String& pattern, const String& group) const;
00168     void autoLoadLookNFeels(const String& pattern, const String& group) const;
00169 
00171     typedef std::vector<ResourceDirectory> ResourceDirVector;
00173     typedef std::vector<DefaultResourceGroup> DefaultGroupVector;
00175     typedef std::vector<AutoLoadResource> AutoResourceVector;
00177     String d_logFileName;
00179     LoggingLevel d_logLevel;
00181     String d_xmlParserName;
00183     String d_imageCodecName;
00185     String d_defaultFont;
00187     String d_defaultMouseImageset;
00189     String d_defaultMouseImage;
00191     String d_defaultTooltipType;
00193     String d_defaultGUISheet;
00195     String d_scriptingInitScript;
00197     String d_scriptingTerminateScript;
00199     ResourceDirVector d_resourceDirectories;
00201     DefaultGroupVector d_defaultResourceGroups;
00203     AutoResourceVector d_autoLoadResources;
00204 };
00205 
00206 } // End of  CEGUI namespace section
00207 
00208 #if defined (_MSC_VER)
00209 #   pragma warning(pop)
00210 #endif
00211 
00212 #endif // end of guard _CEGUIConfig_xmlHandler_h_