/usr/include/cegui-0.8.4/CEGUI/WindowFactoryManager.h is in libcegui-mk2-dev 0.8.4+dfsg-4ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 | /***********************************************************************
created: 22/2/2004
author: Paul D Turner
purpose: Defines interface for WindowFactoryManager class
*************************************************************************/
/***************************************************************************
* Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************/
#ifndef _CEGUIWindowFactoryManager_h_
#define _CEGUIWindowFactoryManager_h_
#include "CEGUI/Base.h"
#include "CEGUI/String.h"
#include "CEGUI/Singleton.h"
#include "CEGUI/Logger.h"
#include "CEGUI/IteratorBase.h"
#include "CEGUI/WindowFactory.h"
#include "CEGUI/TplWindowFactory.h"
#include "CEGUI/Exceptions.h"
#include <map>
#include <vector>
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable : 4275)
# pragma warning(disable : 4251)
#endif
// Start of CEGUI namespace section
namespace CEGUI
{
/*!
\brief
Class that manages WindowFactory objects
\todo
I think we could clean up the mapping stuff a bit. Possibly make it more generic now
with the window renderers and all.
*/
class CEGUIEXPORT WindowFactoryManager :
public Singleton<WindowFactoryManager>,
public AllocatedObject<WindowFactoryManager>
{
public:
/*!
\brief
struct used to hold mapping information required to create a falagard based window.
*/
struct CEGUIEXPORT FalagardWindowMapping
{
String d_windowType;
String d_lookName;
String d_baseType;
String d_rendererType;
String d_effectName;
};
/*!
\brief
Class used to track active alias targets for Window factory types.
*/
class CEGUIEXPORT AliasTargetStack
{
public:
/*!
\brief
Constructor for WindowAliasTargetStack objects
*/
AliasTargetStack(void) {}
/*!
\brief
Destructor for WindowAliasTargetStack objects
*/
~AliasTargetStack(void) {}
/*!
\brief
Return a String holding the current target type for this stack
\return
reference to a String object holding the currently active target type name for this stack.
*/
const String& getActiveTarget(void) const;
/*!
\brief
Return the number of stacked target types in the stack
\return
number of target types stacked for this alias.
*/
uint getStackedTargetCount(void) const;
private:
friend class WindowFactoryManager;
typedef std::vector<String
CEGUI_VECTOR_ALLOC(String)> TargetTypeStack; //!< Type used to implement stack of target type names.
TargetTypeStack d_targetStack; //!< Container holding the target types.
};
/*************************************************************************
Construction and Destruction
*************************************************************************/
/*!
\brief
Constructs a new WindowFactoryManager object.
*/
WindowFactoryManager(void);
/*!
\brief
Destructor for WindowFactoryManager objects
*/
~WindowFactoryManager(void)
{
Logger::getSingleton().logEvent("CEGUI::WindowFactoryManager singleton destroyed");
}
/*************************************************************************
Public Interface
*************************************************************************/
/*!
\brief
Adds a new WindowFactory to the list of registered factories.
\param factory
Pointer to the WindowFactory to be added to the WindowManager.
\return
Nothing
\exception NullObjectException \a factory was null.
\exception AlreadyExistsException \a factory provided a Window type name which is in use by another registered WindowFactory.
*/
void addFactory(WindowFactory* factory);
/*!
\brief
Creates a WindowFactory of the type \a T and adds it to the system for
use. The created WindowFactory will automatically be deleted when the
factory is removed from the system (either directly or at system
deletion time).
\tparam T
Specifies the type of WindowFactory subclass to add a factory for.
\return
Nothing
*/
template <typename T>
static void addFactory();
/*!
\brief
Internally creates a factory suitable for creating Window objects
of the given type and adds it to the system.
\note
The internally created factory is owned and managed by CEGUI,
and will be automatically deleted when the window type is removed from
the system - either directly by calling
WindowFactoryManager::removeFactory or at system shut down.
\tparam T
Specifies the type of Window to add a factory for.
*/
template <typename T>
static void addWindowType();
/*!
\brief
Removes a WindowFactory from the list of registered factories.
\note
The WindowFactory object is not destroyed (since it was created externally), instead it is just removed from the list.
\param name
String which holds the name (technically, Window type name) of the WindowFactory to be removed. If \a name is not
in the list, no error occurs (nothing happens).
\return
Nothing
*/
void removeFactory(const String& name);
/*!
\brief
Removes a WindowFactory from the list of registered factories.
\note
The WindowFactory object is not destroyed (since it was created externally), instead it is just removed from the list.
\param factory
Pointer to the factory object to be removed. If \a factory is null, or if no such WindowFactory is in the list, no
error occurs (nothing happens).
\return
Nothing
*/
void removeFactory(WindowFactory* factory);
/*!
\brief
Remove all WindowFactory objects from the list.
\return
Nothing
*/
void removeAllFactories(void);
/*!
\brief
Return a pointer to the specified WindowFactory object.
\param type
String holding the Window object type to return the WindowFactory for.
\return
Pointer to the WindowFactory object that creates Windows of the type \a type.
\exception UnknownObjectException No WindowFactory object for Window objects of type \a type was found.
*/
WindowFactory* getFactory(const String& type) const;
/*!
\brief
Checks the list of registered WindowFactory objects, aliases, and
falagard mapped types for one which can create Window objects of the
specified type.
\param name
String containing the Window type name to check for.
\return
- true if a WindowFactory, alias, or falagard mapping for Window objects
of type \a name is registered.
- false if the system knows nothing about windows of type \a name.
*/
bool isFactoryPresent(const String& name) const;
/*!
\brief
Adds an alias for a current window type.
This method allows you to create an alias for a specified window type. This means that you can then use
either name as the type parameter when creating a window.
\note
You need to be careful using this system. Creating an alias using a name that already exists will replace the previous
mapping for that alias. Each alias name maintains a stack, which means that it is possible to remove an alias and have the
previous alias restored. The windows created via an alias use the real type, so removing an alias after window creation is always
safe (i.e. it is not the same as removing a real factory, which would cause an exception when trying to destroy a window with a missing
factory).
\param aliasName
String object holding the alias name. That is the name that \a targetType will also be known as from no on.
\param targetType
String object holding the type window type name that is to be aliased. This type must already exist.
\return
Nothing.
\exception UnknownObjectException thrown if \a targetType is not known within the system.
*/
void addWindowTypeAlias(const String& aliasName, const String& targetType);
/*!
\brief
Remove the specified alias mapping. If the alias mapping does not exist, nothing happens.
\note
You are required to supply both the alias and target names because there may exist more than one entry for a given
alias - therefore you are required to be explicit about which alias is to be removed.
\param aliasName
String object holding the alias name.
\param targetType
String object holding the type window type name that was aliased.
\return
Nothing.
*/
void removeWindowTypeAlias(const String& aliasName, const String& targetType);
/*!
\brief
Remove all registered window type alias mappings.
*/
void removeAllWindowTypeAliases();
/*!
\brief
Add a mapping for a falagard based window.
This function creates maps a target window type and target 'look' name onto a registered window type, thus allowing
the ususal window creation interface to be used to create windows that require extra information to full initialise
themselves.
\note
These mappings support 'late binding' to the target window type, as such the type indicated by \a targetType need not
exist in the system until attempting to create a Window using the type.
\par
Also note that creating a mapping for an existing type will replace any previous mapping for that same type.
\param newType
The type name that will be used to create windows using the target type and look.
\param targetType
The base window type.
\param lookName
The name of the 'look' that will be used by windows of this type.
\param renderer
The type of window renderer to assign for windows of this type.
\param effectName
The identifier of the RenderEffect to attempt to set up for windows of this type.
\return
Nothing.
*/
void addFalagardWindowMapping(const String& newType,
const String& targetType,
const String& lookName,
const String& renderer,
const String& effectName = String(""));
/*!
\brief
Remove the specified falagard type mapping if it exists.
\return
Nothing.
*/
void removeFalagardWindowMapping(const String& type);
/*!
\brief
Remove all registered falagard type mappings
*/
void removeAllFalagardWindowMappings();
/*!
\brief
Return whether the given type is a falagard mapped type.
\param type
Name of a window type.
\return
- true if the requested type is a Falagard mapped window type.
- false if the requested type is a normal WindowFactory (or alias), or if the type does not exist.
*/
bool isFalagardMappedType(const String& type) const;
/*!
\brief
Return the name of the LookN'Feel assigned to the specified window mapping.
\param type
Name of a window type. The window type referenced should be a falagard mapped type.
\return
String object holding the name of the look mapped for the requested type.
\exception InvalidRequestException thrown if \a type is not a falagard mapping type (or maybe the type didn't exist).
*/
const String& getMappedLookForType(const String& type) const;
/*!
\brief
Return the name of the WindowRenderer assigned to the specified window mapping.
\param type
Name of a window type. The window type referenced should be a falagard mapped type.
\return
String object holding the name of the window renderer mapped for the requested type.
\exception InvalidRequestException thrown if \a type is not a falagard mapping type (or maybe the type didn't exist).
*/
const String& getMappedRendererForType(const String& type) const;
/*!
\brief
Use the alias system, where required, to 'de-reference' the specified
type to an actual window type that can be created directly (that being
either a concrete window type, or a falagard mapped type).
\note
Even though implied by the above description, this method does not
check that a factory for the final type exists; we simply say that the
returned type is not an alias for some other type.
\param type
String describing the type to be de-referenced.
\return
String object holding a type for a window that can be created directly;
that is, a type that does not describe an alias to some other type.
*/
String getDereferencedAliasType(const String& type) const;
/*!
\brief
Return the FalagardWindowMapping for the specified window mapping \a type.
\param type
Name of a window type. The window type referenced should be a falagard mapped type.
\return
FalagardWindowMapping object describing the falagard mapping.
\exception InvalidRequestException thrown if \a type is not a falagard mapping type (or maybe the type didn't exist).
*/
const FalagardWindowMapping& getFalagardMappingForType(const String& type) const;
private:
/*************************************************************************
Implementation Data
*************************************************************************/
typedef std::map<String, WindowFactory*, StringFastLessCompare
CEGUI_MAP_ALLOC(String, WindowFactory*)> WindowFactoryRegistry; //!< Type used to implement registry of WindowFactory objects
typedef std::map<String, AliasTargetStack, StringFastLessCompare
CEGUI_MAP_ALLOC(String, AliasTargetStack)> TypeAliasRegistry; //!< Type used to implement registry of window type aliases.
typedef std::map<String, FalagardWindowMapping, StringFastLessCompare
CEGUI_MAP_ALLOC(String, FalagardWindowMapping)> FalagardMapRegistry; //!< Type used to implement registry of falagard window mappings.
//! Type used for list of WindowFacory objects that we created ourselves
typedef std::vector<WindowFactory*
CEGUI_VECTOR_ALLOC(WindowFactory*)> OwnedWindowFactoryList;
WindowFactoryRegistry d_factoryRegistry; //!< The container that forms the WindowFactory registry
TypeAliasRegistry d_aliasRegistry; //!< The container that forms the window type alias registry.
FalagardMapRegistry d_falagardRegistry; //!< Container that hold all the falagard window mappings.
//! Container that tracks WindowFactory objects we created ourselves.
static OwnedWindowFactoryList d_ownedFactories;
public:
/*************************************************************************
Iterator stuff
*************************************************************************/
typedef ConstMapIterator<WindowFactoryRegistry> WindowFactoryIterator;
typedef ConstMapIterator<TypeAliasRegistry> TypeAliasIterator;
typedef ConstMapIterator<FalagardMapRegistry> FalagardMappingIterator;
/*!
\brief
Return a WindowFactoryManager::WindowFactoryIterator object to iterate over the available WindowFactory types.
*/
WindowFactoryIterator getIterator(void) const;
/*!
\brief
Return a WindowFactoryManager::TypeAliasIterator object to iterate over the defined aliases for window types.
*/
TypeAliasIterator getAliasIterator(void) const;
/*!
\brief
Return a WindowFactoryManager::FalagardMappingIterator object to iterate over the defined falagard window mappings.
*/
FalagardMappingIterator getFalagardMappingIterator() const;
};
//----------------------------------------------------------------------------//
template <typename T>
void WindowFactoryManager::addFactory()
{
// create the factory object
WindowFactory* factory = CEGUI_NEW_AO T;
// only do the actual add now if our singleton has already been created
if (WindowFactoryManager::getSingletonPtr())
{
Logger::getSingleton().logEvent("Created WindowFactory for '" +
factory->getTypeName() +
"' windows.");
// add the factory we just created
CEGUI_TRY
{
WindowFactoryManager::getSingleton().addFactory(factory);
}
CEGUI_CATCH (Exception&)
{
Logger::getSingleton().logEvent("Deleted WindowFactory for '" +
factory->getTypeName() +
"' windows.");
// delete the factory object
CEGUI_DELETE_AO factory;
CEGUI_RETHROW;
}
}
d_ownedFactories.push_back(factory);
}
//----------------------------------------------------------------------------//
template <typename T>
void WindowFactoryManager::addWindowType()
{
WindowFactoryManager::addFactory<TplWindowFactory<T> >();
}
//----------------------------------------------------------------------------//
} // End of CEGUI namespace section
#if defined(_MSC_VER)
# pragma warning(pop)
#endif
#endif // end of guard _CEGUIWindowFactoryManager_h_
|