| 1 |
#pragma once |
| 2 |
|
| 3 |
#include "ComponentEditor.h" |
| 4 |
|
| 5 |
#include <map> |
| 6 |
#include <string> |
| 7 |
class wxWindow; |
| 8 |
|
| 9 |
namespace objectives |
| 10 |
{ |
| 11 |
|
| 12 |
class Component; |
| 13 |
|
| 14 |
namespace ce |
| 15 |
{ |
| 16 |
|
| 17 |
// Map of named ComponentEditor subclasses |
| 18 |
typedef std::map<std::string, ComponentEditorPtr> ComponentEditorMap; |
| 19 |
|
| 20 |
/** |
| 21 |
* Factory class which creates ComponentEditor subclasses based on a named |
| 22 |
* Component type. |
| 23 |
*/ |
| 24 |
class ComponentEditorFactory |
| 25 |
{ |
| 26 |
// Map instance |
| 27 |
static ComponentEditorMap& getMap(); |
| 28 |
|
| 29 |
public: |
| 30 |
|
| 31 |
/** |
| 32 |
* Create a ComponentEditor of the named type. |
| 33 |
* |
| 34 |
* @param parent |
| 35 |
* The parent window needed to construct the widgets. |
| 36 |
* |
| 37 |
* @param type |
| 38 |
* The string type of the ComponentEditor which should be returned. |
| 39 |
* |
| 40 |
* @param component |
| 41 |
* A reference to the Component that the new ComponentEditor will edit. |
| 42 |
* |
| 43 |
* @return |
| 44 |
* A shared pointer to a ComponentEditor of the requested type. If the |
| 45 |
* requested type does not exist, a NULL shared pointer is returned. |
| 46 |
*/ |
| 47 |
static ComponentEditorPtr create(wxWindow* parent, |
| 48 |
const std::string& type, objectives::Component& component); |
| 49 |
|
| 50 |
/** |
| 51 |
* Register a named ComponentEditor subclass. This is intended for use by |
| 52 |
* ComponentEditor subclasses to register themselves during static |
| 53 |
* initialisation, thereby populating the map of instances used for virtual |
| 54 |
* construction. |
| 55 |
* |
| 56 |
* @param type |
| 57 |
* The named type to register. |
| 58 |
* |
| 59 |
* @param subclass |
| 60 |
* An instance of the ComponentEditor subclass used for virtual |
| 61 |
* construction. |
| 62 |
*/ |
| 63 |
static void registerType(const std::string& type, |
| 64 |
ComponentEditorPtr subclass); |
| 65 |
|
| 66 |
/** |
| 67 |
* greebo: Clears the internal storage - no more component editors |
| 68 |
* can be constructed after this call. |
| 69 |
*/ |
| 70 |
static void clear(); |
| 71 |
}; |
| 72 |
|
| 73 |
} |
| 74 |
|
| 75 |
} |