1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Crazy Eddies GUI System: CEGUINamedXMLResourceManager.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.4 -->
<script type="text/javascript">
function hasClass(ele,cls) {
return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}
function addClass(ele,cls) {
if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}
function removeClass(ele,cls) {
if (hasClass(ele,cls)) {
var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
ele.className=ele.className.replace(reg,' ');
}
}
function toggleVisibility(linkObj) {
var base = linkObj.getAttribute('id');
var summary = document.getElementById(base + '-summary');
var content = document.getElementById(base + '-content');
var trigger = document.getElementById(base + '-trigger');
if ( hasClass(linkObj,'closed') ) {
summary.style.display = 'none';
content.style.display = 'block';
trigger.src = 'open.png';
removeClass(linkObj,'closed');
addClass(linkObj,'opened');
} else if ( hasClass(linkObj,'opened') ) {
summary.style.display = 'block';
content.style.display = 'none';
trigger.src = 'closed.png';
removeClass(linkObj,'opened');
addClass(linkObj,'closed');
}
return false;
}
</script>
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">Crazy Eddies GUI System <span id="projectnumber">0.7.6</span></div>
</td>
</tr>
</tbody>
</table>
</div>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File List</span></a></li>
</ul>
</div>
<div class="header">
<div class="headertitle">
<div class="title">CEGUINamedXMLResourceManager.h</div> </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/***********************************************************************</span>
<a name="l00002"></a>00002 <span class="comment"> filename: CEGUINamedXMLResourceManager.h</span>
<a name="l00003"></a>00003 <span class="comment"> created: Fri Jul 17 2009</span>
<a name="l00004"></a>00004 <span class="comment"> author: Paul D Turner <paul@cegui.org.uk></span>
<a name="l00005"></a>00005 <span class="comment">*************************************************************************/</span>
<a name="l00006"></a>00006 <span class="comment">/***************************************************************************</span>
<a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
<a name="l00010"></a>00010 <span class="comment"> * a copy of this software and associated documentation files (the</span>
<a name="l00011"></a>00011 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
<a name="l00012"></a>00012 <span class="comment"> * without limitation the rights to use, copy, modify, merge, publish,</span>
<a name="l00013"></a>00013 <span class="comment"> * distribute, sublicense, and/or sell copies of the Software, and to</span>
<a name="l00014"></a>00014 <span class="comment"> * permit persons to whom the Software is furnished to do so, subject to</span>
<a name="l00015"></a>00015 <span class="comment"> * the following conditions:</span>
<a name="l00016"></a>00016 <span class="comment"> *</span>
<a name="l00017"></a>00017 <span class="comment"> * The above copyright notice and this permission notice shall be</span>
<a name="l00018"></a>00018 <span class="comment"> * included in all copies or substantial portions of the Software.</span>
<a name="l00019"></a>00019 <span class="comment"> *</span>
<a name="l00020"></a>00020 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
<a name="l00021"></a>00021 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
<a name="l00022"></a>00022 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.</span>
<a name="l00023"></a>00023 <span class="comment"> * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR</span>
<a name="l00024"></a>00024 <span class="comment"> * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,</span>
<a name="l00025"></a>00025 <span class="comment"> * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR</span>
<a name="l00026"></a>00026 <span class="comment"> * OTHER DEALINGS IN THE SOFTWARE.</span>
<a name="l00027"></a>00027 <span class="comment"> ***************************************************************************/</span>
<a name="l00028"></a>00028 <span class="preprocessor">#ifndef _CEGUINamedXMLResourceManager_h_</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span><span class="preprocessor">#define _CEGUINamedXMLResourceManager_h_</span>
<a name="l00030"></a>00030 <span class="preprocessor"></span>
<a name="l00031"></a>00031 <span class="preprocessor">#include "CEGUIEventSet.h"</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include "CEGUIString.h"</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include "CEGUIExceptions.h"</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include "CEGUILogger.h"</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include "CEGUIInputEvent.h"</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include "CEGUISystem.h"</span>
<a name="l00037"></a>00037 <span class="preprocessor">#include <map></span>
<a name="l00038"></a>00038
<a name="l00039"></a>00039 <span class="comment">// Start of CEGUI namespace section</span>
<a name="l00040"></a>00040 <span class="keyword">namespace </span>CEGUI
<a name="l00041"></a>00041 {
<a name="l00043"></a><a class="code" href="namespaceCEGUI.html#a9944966045296e1d2533fe15ee865359">00043</a> <span class="keyword">enum</span> <a class="code" href="namespaceCEGUI.html#a9944966045296e1d2533fe15ee865359" title="Possible actions when loading an XML resource that already exists.">XMLResourceExistsAction</a>
<a name="l00044"></a>00044 {
<a name="l00046"></a><a class="code" href="namespaceCEGUI.html#a9944966045296e1d2533fe15ee865359a5a7a4f246d437106d7232792b62aafc0">00046</a> <a class="code" href="namespaceCEGUI.html#a9944966045296e1d2533fe15ee865359a5a7a4f246d437106d7232792b62aafc0" title="Do not load the resource, return the existing instance.">XREA_RETURN</a>,
<a name="l00048"></a><a class="code" href="namespaceCEGUI.html#a9944966045296e1d2533fe15ee865359a7831e48c1f8853f6d0258257cb596f71">00048</a> <a class="code" href="namespaceCEGUI.html#a9944966045296e1d2533fe15ee865359a7831e48c1f8853f6d0258257cb596f71" title="Destroy the existing instance and replace with the newly loaded one.">XREA_REPLACE</a>,
<a name="l00050"></a><a class="code" href="namespaceCEGUI.html#a9944966045296e1d2533fe15ee865359a27b0097397915ccf62de2355fa7b8000">00050</a> <a class="code" href="namespaceCEGUI.html#a9944966045296e1d2533fe15ee865359a27b0097397915ccf62de2355fa7b8000" title="Throw an AlreadyExistsException.">XREA_THROW</a>
<a name="l00051"></a>00051 };
<a name="l00052"></a>00052
<a name="l00053"></a>00053 <span class="comment">//----------------------------------------------------------------------------//</span>
<a name="l00054"></a>00054
<a name="l00056"></a><a class="code" href="classCEGUI_1_1ResourceEventSet.html">00056</a> <span class="keyword">class </span>CEGUIEXPORT <a class="code" href="classCEGUI_1_1ResourceEventSet.html" title="implementation class to gather EventSet parts for all template instances.">ResourceEventSet</a> : <span class="keyword">public</span> <a class="code" href="classCEGUI_1_1EventSet.html" title="Class that collects together a set of Event objects.">EventSet</a>
<a name="l00057"></a>00057 {
<a name="l00058"></a>00058 <span class="keyword">public</span>:
<a name="l00060"></a><a class="code" href="classCEGUI_1_1ResourceEventSet.html#a14459ea09df304c015a1356b86c50ca0">00060</a> <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classCEGUI_1_1String.html" title="String class used within the GUI system.">String</a> <a class="code" href="classCEGUI_1_1ResourceEventSet.html#a14459ea09df304c015a1356b86c50ca0" title="Namespace name for all resource managers.">EventNamespace</a>;
<a name="l00067"></a><a class="code" href="classCEGUI_1_1ResourceEventSet.html#a3d228a7a40b5083ad02168fefbcbc8a0">00067</a> <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classCEGUI_1_1String.html" title="String class used within the GUI system.">String</a> <a class="code" href="classCEGUI_1_1ResourceEventSet.html#a3d228a7a40b5083ad02168fefbcbc8a0">EventResourceCreated</a>;
<a name="l00074"></a><a class="code" href="classCEGUI_1_1ResourceEventSet.html#abba9c610930535739711c1c445122cf7">00074</a> <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classCEGUI_1_1String.html" title="String class used within the GUI system.">String</a> <a class="code" href="classCEGUI_1_1ResourceEventSet.html#abba9c610930535739711c1c445122cf7">EventResourceDestroyed</a>;
<a name="l00081"></a><a class="code" href="classCEGUI_1_1ResourceEventSet.html#aa94e76312d3e4b5f64dfd7900e59f8c2">00081</a> <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classCEGUI_1_1String.html" title="String class used within the GUI system.">String</a> <a class="code" href="classCEGUI_1_1ResourceEventSet.html#aa94e76312d3e4b5f64dfd7900e59f8c2">EventResourceReplaced</a>;
<a name="l00082"></a>00082 };
<a name="l00083"></a>00083
<a name="l00084"></a>00084 <span class="comment">//----------------------------------------------------------------------------//</span>
<a name="l00085"></a>00085
<a name="l00108"></a>00108 <span class="keyword">template</span><<span class="keyword">typename</span> T, <span class="keyword">typename</span> U>
<a name="l00109"></a><a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html">00109</a> <span class="keyword">class </span><a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html" title="Templatised manager class that loads and manages named XML based resources.">NamedXMLResourceManager</a> : <span class="keyword">public</span> <a class="code" href="classCEGUI_1_1ResourceEventSet.html" title="implementation class to gather EventSet parts for all template instances.">ResourceEventSet</a>
<a name="l00110"></a>00110 {
<a name="l00111"></a>00111 <span class="keyword">public</span>:
<a name="l00121"></a>00121 <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a2ae558736f18e758f1c1b6f1c6d6b70e" title="Constructor.">NamedXMLResourceManager</a>(<span class="keyword">const</span> <a class="code" href="classCEGUI_1_1String.html" title="String class used within the GUI system.">String</a>& resource_type);
<a name="l00122"></a>00122
<a name="l00124"></a>00124 <span class="keyword">virtual</span> <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#aa5a3293c828c5643d71b898a6c29afa0" title="Destructor.">~NamedXMLResourceManager</a>();
<a name="l00125"></a>00125
<a name="l00148"></a>00148 T& <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a13093b377ff84b3cfbd285aaa83ee166" title="Creates a new T object from an XML file and adds it to the collection.">create</a>(<span class="keyword">const</span> <a class="code" href="classCEGUI_1_1String.html" title="String class used within the GUI system.">String</a>& xml_filename, <span class="keyword">const</span> <a class="code" href="classCEGUI_1_1String.html" title="String class used within the GUI system.">String</a>& resource_group = <span class="stringliteral">""</span>,
<a name="l00149"></a>00149 <a class="code" href="namespaceCEGUI.html#a9944966045296e1d2533fe15ee865359" title="Possible actions when loading an XML resource that already exists.">XMLResourceExistsAction</a> action = <a class="code" href="namespaceCEGUI.html#a9944966045296e1d2533fe15ee865359a5a7a4f246d437106d7232792b62aafc0" title="Do not load the resource, return the existing instance.">XREA_RETURN</a>);
<a name="l00150"></a>00150
<a name="l00159"></a>00159 <span class="keywordtype">void</span> <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a22df87b9b35eb05b773d198fdfc49ea1" title="Destroy the object named object_name, or do nothing if such an object does not exist in the collectio...">destroy</a>(<span class="keyword">const</span> <a class="code" href="classCEGUI_1_1String.html" title="String class used within the GUI system.">String</a>& object_name);
<a name="l00160"></a>00160
<a name="l00170"></a>00170 <span class="keywordtype">void</span> <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a22df87b9b35eb05b773d198fdfc49ea1" title="Destroy the object named object_name, or do nothing if such an object does not exist in the collectio...">destroy</a>(<span class="keyword">const</span> T& <span class="keywordtype">object</span>);
<a name="l00171"></a>00171
<a name="l00173"></a>00173 <span class="keywordtype">void</span> <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a99f9ff914c3e562a24b06417130f1f45" title="Destroy all objects.">destroyAll</a>();
<a name="l00174"></a>00174
<a name="l00185"></a>00185 T& <span class="keyword">get</span>(<span class="keyword">const</span> <a class="code" href="classCEGUI_1_1String.html" title="String class used within the GUI system.">String</a>& object_name) <span class="keyword">const</span>;
<a name="l00186"></a>00186
<a name="l00188"></a>00188 <span class="keywordtype">bool</span> <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a05e36d9d715d209ab1fe6658c9202934" title="Return whether an object named object_name exists.">isDefined</a>(<span class="keyword">const</span> <a class="code" href="classCEGUI_1_1String.html" title="String class used within the GUI system.">String</a>& object_name) <span class="keyword">const</span>;
<a name="l00189"></a>00189
<a name="l00191"></a>00191 <span class="keywordtype">void</span> <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a4dfa49b0b241426ee3f5dcb39663c301" title="Create a new T object from files with names matching pattern in resource_group.">createAll</a>(<span class="keyword">const</span> <a class="code" href="classCEGUI_1_1String.html" title="String class used within the GUI system.">String</a>& pattern, <span class="keyword">const</span> <a class="code" href="classCEGUI_1_1String.html" title="String class used within the GUI system.">String</a>& resource_group);
<a name="l00192"></a>00192
<a name="l00193"></a>00193 <span class="keyword">protected</span>:
<a name="l00195"></a><a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a785c2f0127133c3232d6da4673d93080">00195</a> <span class="keyword">typedef</span> std::map<String, T*, String::FastLessCompare> <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a785c2f0127133c3232d6da4673d93080" title="type of collection used to store and manage objects">ObjectRegistry</a>;
<a name="l00197"></a>00197 <span class="keywordtype">void</span> <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a15b34969f913a302e3e6067318563059" title="implementation of object destruction.">destroyObject</a>(<span class="keyword">typename</span> ObjectRegistry::iterator ob);
<a name="l00199"></a>00199 T& <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#aec9e54bb6b310d8062cc90b0dc7692b8" title="function to enforce XMLResourceExistsAction policy.">doExistingObjectAction</a>(<span class="keyword">const</span> <a class="code" href="classCEGUI_1_1String.html" title="String class used within the GUI system.">String</a> object_name, T* <span class="keywordtype">object</span>,
<a name="l00200"></a>00200 <span class="keyword">const</span> <a class="code" href="namespaceCEGUI.html#a9944966045296e1d2533fe15ee865359" title="Possible actions when loading an XML resource that already exists.">XMLResourceExistsAction</a> action);
<a name="l00202"></a>00202 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a02e49a7870cc78742253c1bb43a03cd7" title="Function called each time a new object is added to the collection.">doPostObjectAdditionAction</a>(T& <span class="keywordtype">object</span>);
<a name="l00204"></a><a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a42964e958b8b29c2a10b87e97e0b06b0">00204</a> <span class="keyword">const</span> <a class="code" href="classCEGUI_1_1String.html" title="String class used within the GUI system.">String</a> <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a42964e958b8b29c2a10b87e97e0b06b0" title="String holding the text for the resource type managed.">d_resourceType</a>;
<a name="l00206"></a><a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a61dfea8cd7ed559ac8cfc7354d835c09">00206</a> <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a785c2f0127133c3232d6da4673d93080" title="type of collection used to store and manage objects">ObjectRegistry</a> <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a61dfea8cd7ed559ac8cfc7354d835c09" title="the collection of objects">d_objects</a>;
<a name="l00207"></a>00207 };
<a name="l00208"></a>00208
<a name="l00209"></a>00209 <span class="comment">//----------------------------------------------------------------------------//</span>
<a name="l00210"></a>00210 <span class="keyword">template</span><<span class="keyword">typename</span> T, <span class="keyword">typename</span> U>
<a name="l00211"></a><a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a2ae558736f18e758f1c1b6f1c6d6b70e">00211</a> <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a2ae558736f18e758f1c1b6f1c6d6b70e" title="Constructor.">NamedXMLResourceManager<T, U>::NamedXMLResourceManager</a>(
<a name="l00212"></a>00212 <span class="keyword">const</span> <a class="code" href="classCEGUI_1_1String.html" title="String class used within the GUI system.">String</a>& resource_type) :
<a name="l00213"></a>00213 d_resourceType(resource_type)
<a name="l00214"></a>00214 {
<a name="l00215"></a>00215 }
<a name="l00216"></a>00216
<a name="l00217"></a>00217 <span class="comment">//----------------------------------------------------------------------------//</span>
<a name="l00218"></a>00218 <span class="keyword">template</span><<span class="keyword">typename</span> T, <span class="keyword">typename</span> U>
<a name="l00219"></a><a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#aa5a3293c828c5643d71b898a6c29afa0">00219</a> <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#aa5a3293c828c5643d71b898a6c29afa0" title="Destructor.">NamedXMLResourceManager<T, U>::~NamedXMLResourceManager</a>()
<a name="l00220"></a>00220 {
<a name="l00221"></a>00221 }
<a name="l00222"></a>00222
<a name="l00223"></a>00223 <span class="comment">//----------------------------------------------------------------------------//</span>
<a name="l00224"></a>00224 <span class="keyword">template</span><<span class="keyword">typename</span> T, <span class="keyword">typename</span> U>
<a name="l00225"></a><a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a13093b377ff84b3cfbd285aaa83ee166">00225</a> T& <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a13093b377ff84b3cfbd285aaa83ee166" title="Creates a new T object from an XML file and adds it to the collection.">NamedXMLResourceManager<T, U>::create</a>(<span class="keyword">const</span> <a class="code" href="classCEGUI_1_1String.html" title="String class used within the GUI system.">String</a>& xml_filename,
<a name="l00226"></a>00226 <span class="keyword">const</span> <a class="code" href="classCEGUI_1_1String.html" title="String class used within the GUI system.">String</a>& resource_group,
<a name="l00227"></a>00227 <a class="code" href="namespaceCEGUI.html#a9944966045296e1d2533fe15ee865359" title="Possible actions when loading an XML resource that already exists.">XMLResourceExistsAction</a> action)
<a name="l00228"></a>00228 {
<a name="l00229"></a>00229 U xml_loader(xml_filename, resource_group);
<a name="l00230"></a>00230 <span class="keywordflow">return</span> doExistingObjectAction(xml_loader.getObjectName(),
<a name="l00231"></a>00231 &xml_loader.getObject(), action);
<a name="l00232"></a>00232 }
<a name="l00233"></a>00233
<a name="l00234"></a>00234 <span class="comment">//----------------------------------------------------------------------------//</span>
<a name="l00235"></a>00235 <span class="keyword">template</span><<span class="keyword">typename</span> T, <span class="keyword">typename</span> U>
<a name="l00236"></a><a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a22df87b9b35eb05b773d198fdfc49ea1">00236</a> <span class="keywordtype">void</span> <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a22df87b9b35eb05b773d198fdfc49ea1" title="Destroy the object named object_name, or do nothing if such an object does not exist in the collectio...">NamedXMLResourceManager<T, U>::destroy</a>(<span class="keyword">const</span> <a class="code" href="classCEGUI_1_1String.html" title="String class used within the GUI system.">String</a>& object_name)
<a name="l00237"></a>00237 {
<a name="l00238"></a>00238 <span class="keyword">typename</span> ObjectRegistry::iterator i(d_objects.find(object_name));
<a name="l00239"></a>00239
<a name="l00240"></a>00240 <span class="comment">// exit if no such object.</span>
<a name="l00241"></a>00241 <span class="keywordflow">if</span> (i == d_objects.end())
<a name="l00242"></a>00242 <span class="keywordflow">return</span>;
<a name="l00243"></a>00243
<a name="l00244"></a>00244 destroyObject(i);
<a name="l00245"></a>00245 }
<a name="l00246"></a>00246
<a name="l00247"></a>00247 <span class="comment">//----------------------------------------------------------------------------//</span>
<a name="l00248"></a>00248 <span class="keyword">template</span><<span class="keyword">typename</span> T, <span class="keyword">typename</span> U>
<a name="l00249"></a><a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#aff2ebd2f107a1de1e0143540d508431d">00249</a> <span class="keywordtype">void</span> <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a22df87b9b35eb05b773d198fdfc49ea1" title="Destroy the object named object_name, or do nothing if such an object does not exist in the collectio...">NamedXMLResourceManager<T, U>::destroy</a>(<span class="keyword">const</span> T& <span class="keywordtype">object</span>)
<a name="l00250"></a>00250 {
<a name="l00251"></a>00251 <span class="comment">// don't want to force a 'getName' function on T here, so we'll look for the</span>
<a name="l00252"></a>00252 <span class="comment">// object the hard way.</span>
<a name="l00253"></a>00253 <span class="keyword">typename</span> ObjectRegistry::iterator i(d_objects.begin());
<a name="l00254"></a>00254 <span class="keywordflow">for</span> (; i != d_objects.end(); ++i)
<a name="l00255"></a>00255 <span class="keywordflow">if</span> (i->second == &<span class="keywordtype">object</span>)
<a name="l00256"></a>00256 {
<a name="l00257"></a>00257 destroyObject(i);
<a name="l00258"></a>00258 <span class="keywordflow">return</span>;
<a name="l00259"></a>00259 }
<a name="l00260"></a>00260 }
<a name="l00261"></a>00261
<a name="l00262"></a>00262 <span class="comment">//----------------------------------------------------------------------------//</span>
<a name="l00263"></a>00263 <span class="keyword">template</span><<span class="keyword">typename</span> T, <span class="keyword">typename</span> U>
<a name="l00264"></a><a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a99f9ff914c3e562a24b06417130f1f45">00264</a> <span class="keywordtype">void</span> <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a99f9ff914c3e562a24b06417130f1f45" title="Destroy all objects.">NamedXMLResourceManager<T, U>::destroyAll</a>()
<a name="l00265"></a>00265 {
<a name="l00266"></a>00266 <span class="keywordflow">while</span> (!d_objects.empty())
<a name="l00267"></a>00267 destroyObject(d_objects.begin());
<a name="l00268"></a>00268 }
<a name="l00269"></a>00269
<a name="l00270"></a>00270 <span class="comment">//----------------------------------------------------------------------------//</span>
<a name="l00271"></a>00271 <span class="keyword">template</span><<span class="keyword">typename</span> T, <span class="keyword">typename</span> U>
<a name="l00272"></a><a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a1e14c66d9ab6df184eedeaf3ffcf1655">00272</a> T& <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a1e14c66d9ab6df184eedeaf3ffcf1655" title="Return a reference to the object named object_name.">NamedXMLResourceManager<T, U>::get</a>(<span class="keyword">const</span> <a class="code" href="classCEGUI_1_1String.html" title="String class used within the GUI system.">String</a>& object_name)<span class="keyword"> const</span>
<a name="l00273"></a>00273 <span class="keyword"></span>{
<a name="l00274"></a>00274 <span class="keyword">typename</span> ObjectRegistry::const_iterator i(d_objects.find(object_name));
<a name="l00275"></a>00275
<a name="l00276"></a>00276 <span class="keywordflow">if</span> (i == d_objects.end())
<a name="l00277"></a>00277 CEGUI_THROW(<a class="code" href="classCEGUI_1_1UnknownObjectException.html" title="Exception class used when a request was made for an unknown object.">UnknownObjectException</a>(<span class="stringliteral">"NamedXMLResourceManager::get: "</span>
<a name="l00278"></a>00278 <span class="stringliteral">"No object of type '"</span> + d_resourceType + <span class="stringliteral">"' named '"</span> + object_name +
<a name="l00279"></a>00279 <span class="stringliteral">"' is present in the collection."</span>));
<a name="l00280"></a>00280
<a name="l00281"></a>00281 <span class="keywordflow">return</span> *i->second;
<a name="l00282"></a>00282 }
<a name="l00283"></a>00283
<a name="l00284"></a>00284 <span class="comment">//----------------------------------------------------------------------------//</span>
<a name="l00285"></a>00285 <span class="keyword">template</span><<span class="keyword">typename</span> T, <span class="keyword">typename</span> U>
<a name="l00286"></a><a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a05e36d9d715d209ab1fe6658c9202934">00286</a> <span class="keywordtype">bool</span> <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a05e36d9d715d209ab1fe6658c9202934" title="Return whether an object named object_name exists.">NamedXMLResourceManager<T, U>::isDefined</a>(<span class="keyword">const</span> <a class="code" href="classCEGUI_1_1String.html" title="String class used within the GUI system.">String</a>& object_name)<span class="keyword"> const</span>
<a name="l00287"></a>00287 <span class="keyword"></span>{
<a name="l00288"></a>00288 <span class="keywordflow">return</span> d_objects.find(object_name) != d_objects.end();
<a name="l00289"></a>00289 }
<a name="l00290"></a>00290
<a name="l00291"></a>00291 <span class="comment">//----------------------------------------------------------------------------//</span>
<a name="l00292"></a>00292 <span class="keyword">template</span><<span class="keyword">typename</span> T, <span class="keyword">typename</span> U>
<a name="l00293"></a><a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a15b34969f913a302e3e6067318563059">00293</a> <span class="keywordtype">void</span> <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a15b34969f913a302e3e6067318563059" title="implementation of object destruction.">NamedXMLResourceManager<T, U>::destroyObject</a>(
<a name="l00294"></a>00294 <span class="keyword">typename</span> ObjectRegistry::iterator ob)
<a name="l00295"></a>00295 {
<a name="l00296"></a>00296 <span class="keywordtype">char</span> addr_buff[32];
<a name="l00297"></a>00297 sprintf(addr_buff, <span class="stringliteral">"(%p)"</span>, static_cast<void*>(ob->second));
<a name="l00298"></a>00298 Logger::getSingleton().logEvent(<span class="stringliteral">"Object of type '"</span> + d_resourceType +
<a name="l00299"></a>00299 <span class="stringliteral">"' named '"</span> + ob->first + <span class="stringliteral">"' has been destroyed. "</span> +
<a name="l00300"></a>00300 addr_buff, <a class="code" href="namespaceCEGUI.html#a9e0443bad079b8ad1a6dd35f85595adda30a9a6fa07645407a29be1937cc3847b" title="Useful tracing (object creations etc) information will be logged.">Informative</a>);
<a name="l00301"></a>00301
<a name="l00302"></a>00302 <span class="comment">// Set up event args for event notification</span>
<a name="l00303"></a>00303 <a class="code" href="classCEGUI_1_1ResourceEventArgs.html" title="EventArgs based class that is used for notifications regarding resources.">ResourceEventArgs</a> args(d_resourceType, ob->first);
<a name="l00304"></a>00304
<a name="l00305"></a>00305 <span class="keyword">delete</span> ob->second;
<a name="l00306"></a>00306 d_objects.erase(ob);
<a name="l00307"></a>00307
<a name="l00308"></a>00308 <span class="comment">// fire event signalling an object has been destroyed</span>
<a name="l00309"></a>00309 fireEvent(EventResourceDestroyed, args, EventNamespace);
<a name="l00310"></a>00310 }
<a name="l00311"></a>00311
<a name="l00312"></a>00312 <span class="comment">//----------------------------------------------------------------------------//</span>
<a name="l00313"></a>00313 <span class="keyword">template</span><<span class="keyword">typename</span> T, <span class="keyword">typename</span> U>
<a name="l00314"></a><a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#aec9e54bb6b310d8062cc90b0dc7692b8">00314</a> T& <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#aec9e54bb6b310d8062cc90b0dc7692b8" title="function to enforce XMLResourceExistsAction policy.">NamedXMLResourceManager<T, U>::doExistingObjectAction</a>(
<a name="l00315"></a>00315 <span class="keyword">const</span> <a class="code" href="classCEGUI_1_1String.html" title="String class used within the GUI system.">String</a> object_name,
<a name="l00316"></a>00316 T* <span class="keywordtype">object</span>,
<a name="l00317"></a>00317 <span class="keyword">const</span> <a class="code" href="namespaceCEGUI.html#a9944966045296e1d2533fe15ee865359" title="Possible actions when loading an XML resource that already exists.">XMLResourceExistsAction</a> action)
<a name="l00318"></a>00318 {
<a name="l00319"></a>00319 <a class="code" href="classCEGUI_1_1String.html" title="String class used within the GUI system.">String</a> event_name;
<a name="l00320"></a>00320
<a name="l00321"></a>00321 <span class="keywordflow">if</span> (isDefined(object_name))
<a name="l00322"></a>00322 {
<a name="l00323"></a>00323 <span class="keywordflow">switch</span> (action)
<a name="l00324"></a>00324 {
<a name="l00325"></a>00325 <span class="keywordflow">case</span> <a class="code" href="namespaceCEGUI.html#a9944966045296e1d2533fe15ee865359a5a7a4f246d437106d7232792b62aafc0" title="Do not load the resource, return the existing instance.">XREA_RETURN</a>:
<a name="l00326"></a>00326 Logger::getSingleton().logEvent(<span class="stringliteral">"---- Returning existing instance "</span>
<a name="l00327"></a>00327 <span class="stringliteral">"of "</span> + d_resourceType + <span class="stringliteral">" named '"</span> + object_name + <span class="stringliteral">"'."</span>);
<a name="l00328"></a>00328 <span class="comment">// delete any new object we already had created</span>
<a name="l00329"></a>00329 <span class="keyword">delete</span> object;
<a name="l00330"></a>00330 <span class="comment">// return existing instance of object.</span>
<a name="l00331"></a>00331 <span class="keywordflow">return</span> *d_objects[object_name];
<a name="l00332"></a>00332
<a name="l00333"></a>00333 <span class="keywordflow">case</span> <a class="code" href="namespaceCEGUI.html#a9944966045296e1d2533fe15ee865359a7831e48c1f8853f6d0258257cb596f71" title="Destroy the existing instance and replace with the newly loaded one.">XREA_REPLACE</a>:
<a name="l00334"></a>00334 Logger::getSingleton().logEvent(<span class="stringliteral">"---- Replacing existing instance "</span>
<a name="l00335"></a>00335 <span class="stringliteral">"of "</span> + d_resourceType + <span class="stringliteral">" named '"</span> + object_name +
<a name="l00336"></a>00336 <span class="stringliteral">"' (DANGER!)."</span>);
<a name="l00337"></a>00337 destroy(object_name);
<a name="l00338"></a>00338 event_name = EventResourceReplaced;
<a name="l00339"></a>00339 <span class="keywordflow">break</span>;
<a name="l00340"></a>00340
<a name="l00341"></a>00341 <span class="keywordflow">case</span> <a class="code" href="namespaceCEGUI.html#a9944966045296e1d2533fe15ee865359a27b0097397915ccf62de2355fa7b8000" title="Throw an AlreadyExistsException.">XREA_THROW</a>:
<a name="l00342"></a>00342 <span class="keyword">delete</span> object;
<a name="l00343"></a>00343 CEGUI_THROW(<a class="code" href="classCEGUI_1_1AlreadyExistsException.html" title="Exception class used when an attempt is made create a named object of a particular type when an objec...">AlreadyExistsException</a>(
<a name="l00344"></a>00344 <span class="stringliteral">"NamedXMLResourceManager::checkExistingObjectAction: "</span>
<a name="l00345"></a>00345 <span class="stringliteral">"an object of type '"</span> + d_resourceType + <span class="stringliteral">"' named '"</span> +
<a name="l00346"></a>00346 object_name + <span class="stringliteral">"' already exists in the collection."</span>));
<a name="l00347"></a>00347
<a name="l00348"></a>00348 <span class="keywordflow">default</span>:
<a name="l00349"></a>00349 <span class="keyword">delete</span> object;
<a name="l00350"></a>00350 CEGUI_THROW(<a class="code" href="classCEGUI_1_1InvalidRequestException.html" title="Exception class used when some impossible request was made of the system.">InvalidRequestException</a>(
<a name="l00351"></a>00351 <span class="stringliteral">"NamedXMLResourceManager::checkExistingObjectAction: "</span>
<a name="l00352"></a>00352 <span class="stringliteral">"Invalid CEGUI::XMLResourceExistsAction was specified."</span>));
<a name="l00353"></a>00353 }
<a name="l00354"></a>00354 }
<a name="l00355"></a>00355 <span class="keywordflow">else</span>
<a name="l00356"></a>00356 event_name = EventResourceCreated;
<a name="l00357"></a>00357
<a name="l00358"></a>00358 d_objects[object_name] = object;
<a name="l00359"></a>00359 doPostObjectAdditionAction(*<span class="keywordtype">object</span>);
<a name="l00360"></a>00360
<a name="l00361"></a>00361 <span class="comment">// fire event about this resource change</span>
<a name="l00362"></a>00362 <a class="code" href="classCEGUI_1_1ResourceEventArgs.html" title="EventArgs based class that is used for notifications regarding resources.">ResourceEventArgs</a> args(d_resourceType, object_name);
<a name="l00363"></a>00363 fireEvent(event_name, args, EventNamespace);
<a name="l00364"></a>00364
<a name="l00365"></a>00365 <span class="keywordflow">return</span> *object;
<a name="l00366"></a>00366 }
<a name="l00367"></a>00367
<a name="l00368"></a>00368 <span class="comment">//----------------------------------------------------------------------------//</span>
<a name="l00369"></a>00369 <span class="keyword">template</span><<span class="keyword">typename</span> T, <span class="keyword">typename</span> U>
<a name="l00370"></a><a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a02e49a7870cc78742253c1bb43a03cd7">00370</a> <span class="keywordtype">void</span> <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a02e49a7870cc78742253c1bb43a03cd7" title="Function called each time a new object is added to the collection.">NamedXMLResourceManager<T, U>::doPostObjectAdditionAction</a>(T& <span class="comment">/*object*/</span>)
<a name="l00371"></a>00371 {
<a name="l00372"></a>00372 <span class="comment">// do nothing by default.</span>
<a name="l00373"></a>00373 }
<a name="l00374"></a>00374
<a name="l00375"></a>00375 <span class="comment">//----------------------------------------------------------------------------//</span>
<a name="l00376"></a>00376 <span class="keyword">template</span><<span class="keyword">typename</span> T, <span class="keyword">typename</span> U>
<a name="l00377"></a><a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a4dfa49b0b241426ee3f5dcb39663c301">00377</a> <span class="keywordtype">void</span> <a class="code" href="classCEGUI_1_1NamedXMLResourceManager.html#a4dfa49b0b241426ee3f5dcb39663c301" title="Create a new T object from files with names matching pattern in resource_group.">NamedXMLResourceManager<T, U>::createAll</a>(<span class="keyword">const</span> <a class="code" href="classCEGUI_1_1String.html" title="String class used within the GUI system.">String</a>& pattern,
<a name="l00378"></a>00378 <span class="keyword">const</span> <a class="code" href="classCEGUI_1_1String.html" title="String class used within the GUI system.">String</a>& resource_group)
<a name="l00379"></a>00379 {
<a name="l00380"></a>00380 std::vector<String> names;
<a name="l00381"></a>00381 <span class="keyword">const</span> <span class="keywordtype">size_t</span> num = <a class="code" href="classCEGUI_1_1System.html#a8d059b018d621be0e4b98d069421426f" title="Return singleton System object.">System::getSingleton</a>().<a class="code" href="classCEGUI_1_1System.html#a994b4c72aba1a456ba1a5fad469e93ed" title="Return a pointer to the ResourceProvider being used within the GUI system.">getResourceProvider</a>()->
<a name="l00382"></a>00382 getResourceGroupFileNames(names, pattern, resource_group);
<a name="l00383"></a>00383
<a name="l00384"></a>00384 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i < num; ++i)
<a name="l00385"></a>00385 create(names[i], resource_group);
<a name="l00386"></a>00386 }
<a name="l00387"></a>00387
<a name="l00388"></a>00388 <span class="comment">//----------------------------------------------------------------------------//</span>
<a name="l00389"></a>00389
<a name="l00390"></a>00390 } <span class="comment">// End of CEGUI namespace section</span>
<a name="l00391"></a>00391
<a name="l00392"></a>00392 <span class="preprocessor">#endif // end of guard _CEGUINamedXMLResourceManager_h_</span>
</pre></div></div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Sun Jan 22 2012 16:07:39 for Crazy Eddies GUI System by 
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
</html>
|