Crazy Eddie's GUI System  0.8.4
Config_xmlHandler.h
00001 /***********************************************************************
00002     created:    Sat Jul 25 2009
00003     author:     Paul D Turner <paul@cegui.org.uk>
00004 *************************************************************************/
00005 /***************************************************************************
00006  *   Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team
00007  *
00008  *   Permission is hereby granted, free of charge, to any person obtaining
00009  *   a copy of this software and associated documentation files (the
00010  *   "Software"), to deal in the Software without restriction, including
00011  *   without limitation the rights to use, copy, modify, merge, publish,
00012  *   distribute, sublicense, and/or sell copies of the Software, and to
00013  *   permit persons to whom the Software is furnished to do so, subject to
00014  *   the following conditions:
00015  *
00016  *   The above copyright notice and this permission notice shall be
00017  *   included in all copies or substantial portions of the Software.
00018  *
00019  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00020  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00021  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00022  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00023  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00024  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00025  *   OTHER DEALINGS IN THE SOFTWARE.
00026  ***************************************************************************/
00027 #ifndef _CEGUIConfig_xmlHandler_h_
00028 #define _CEGUIConfig_xmlHandler_h_
00029 
00030 #include "CEGUI/Base.h"
00031 #include "CEGUI/String.h"
00032 #include "CEGUI/Logger.h"
00033 #include "CEGUI/XMLHandler.h"
00034 #include <vector>
00035 
00036 #if defined (_MSC_VER)
00037 #   pragma warning(push)
00038 #   pragma warning(disable : 4251)
00039 #endif
00040 
00041 // Start of CEGUI namespace section
00042 namespace CEGUI
00043 {
00045 class Config_xmlHandler : public XMLHandler
00046 {
00047 public:
00049     static const String CEGUIConfigSchemaName;
00050     // xml tag names
00051     static const String CEGUIConfigElement;
00052     static const String LoggingElement;
00053     static const String AutoLoadElement;
00054     static const String ResourceDirectoryElement;
00055     static const String DefaultResourceGroupElement;
00056     static const String ScriptingElement;
00057     static const String XMLParserElement;
00058     static const String ImageCodecElement;
00059     static const String DefaultFontElement;
00060     static const String DefaultMouseCursorElement;
00061     static const String DefaultTooltipElement;
00062     // xml attribute names
00063     static const String FilenameAttribute;
00064     static const String LevelAttribute;
00065     static const String TypeAttribute;
00066     static const String GroupAttribute;
00067     static const String PatternAttribute;
00068     static const String DirectoryAttribute;
00069     static const String InitScriptAttribute;
00070     static const String TerminateScriptAttribute;
00071     static const String ImageAttribute;
00072     static const String NameAttribute;
00073 
00075     Config_xmlHandler();
00076 
00078     ~Config_xmlHandler();
00079 
00081     void initialiseXMLParser() const;
00083     void initialiseImageCodec() const;
00085     void initialiseLogger(const String& default_filename) const;
00087     void initialiseResourceGroupDirectories() const;
00089     void initialiseDefaultResourceGroups() const;
00091     void loadAutoResources() const;
00093     void initialiseDefaultFont() const;
00095     void initialiseDefaultMouseCursor() const;
00097     void initialiseDefaulTooltip() const;
00099     void executeInitScript() const;
00101     const String& getTerminateScriptName() const;
00102 
00103     // XMLHandler overrides
00104     const String& getSchemaName() const;
00105     const String& getDefaultResourceGroup() const;
00106 
00107     void elementStart(const String& element, const XMLAttributes& attributes);
00108     void elementEnd(const String& element);
00109 
00110 private:
00112     enum ResourceType
00113     {
00114         RT_IMAGESET,
00115         RT_FONT,
00116         RT_SCHEME,
00117         RT_LOOKNFEEL,
00118         RT_LAYOUT,
00119         RT_SCRIPT,
00120         RT_XMLSCHEMA,
00121         RT_DEFAULT
00122     };
00123 
00125     struct ResourceDirectory
00126     {
00127         String group;
00128         String directory;
00129     };
00130 
00132     struct DefaultResourceGroup
00133     {
00134         ResourceType type;
00135         String group;
00136     };
00137 
00139     struct AutoLoadResource
00140     {
00141         String type_string;
00142         ResourceType type;
00143         String group;
00144         String pattern;
00145     };
00146 
00147     // functions to handle the various elements
00148     void handleCEGUIConfigElement(const XMLAttributes& attr);
00149     void handleLoggingElement(const XMLAttributes& attr);
00150     void handleAutoLoadElement(const XMLAttributes& attr);
00151     void handleResourceDirectoryElement(const XMLAttributes& attr);
00152     void handleDefaultResourceGroupElement(const XMLAttributes& attr);
00153     void handleScriptingElement(const XMLAttributes& attr);
00154     void handleXMLParserElement(const XMLAttributes& attr);
00155     void handleImageCodecElement(const XMLAttributes& attr);
00156     void handleDefaultTooltipElement(const XMLAttributes& attr);
00157     void handleDefaultFontElement(const XMLAttributes& attr);
00158     void handleDefaultMouseCursorElement(const XMLAttributes& attr);
00159 
00161     ResourceType stringToResourceType(const String& type) const;
00163     void autoLoadLookNFeels(const String& pattern, const String& group) const;
00165     void autoLoadImagesets(const String& pattern, const String& group) const;
00166 
00168     typedef std::vector<ResourceDirectory
00169         CEGUI_VECTOR_ALLOC(ResourceDirectory)> ResourceDirVector;
00171     typedef std::vector<DefaultResourceGroup
00172         CEGUI_VECTOR_ALLOC(DefaultResourceGroup)> DefaultGroupVector;
00174     typedef std::vector<AutoLoadResource
00175         CEGUI_VECTOR_ALLOC(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_defaultMouseImage;
00189     String d_defaultTooltipType;
00191     String d_scriptingInitScript;
00193     String d_scriptingTerminateScript;
00195     ResourceDirVector d_resourceDirectories;
00197     DefaultGroupVector d_defaultResourceGroups;
00199     AutoResourceVector d_autoLoadResources;
00200 };
00201 
00202 } // End of  CEGUI namespace section
00203 
00204 #if defined (_MSC_VER)
00205 #   pragma warning(pop)
00206 #endif
00207 
00208 #endif // end of guard _CEGUIConfig_xmlHandler_h_
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends