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
|
#pragma once
#include "ComponentEditor.h"
#include <map>
#include <string>
class wxWindow;
namespace objectives
{
class Component;
namespace ce
{
// Map of named ComponentEditor subclasses
typedef std::map<std::string, ComponentEditorPtr> ComponentEditorMap;
/**
* Factory class which creates ComponentEditor subclasses based on a named
* Component type.
*/
class ComponentEditorFactory
{
// Map instance
static ComponentEditorMap& getMap();
public:
/**
* Create a ComponentEditor of the named type.
*
* @param parent
* The parent window needed to construct the widgets.
*
* @param type
* The string type of the ComponentEditor which should be returned.
*
* @param component
* A reference to the Component that the new ComponentEditor will edit.
*
* @return
* A shared pointer to a ComponentEditor of the requested type. If the
* requested type does not exist, a NULL shared pointer is returned.
*/
static ComponentEditorPtr create(wxWindow* parent,
const std::string& type, objectives::Component& component);
/**
* Register a named ComponentEditor subclass. This is intended for use by
* ComponentEditor subclasses to register themselves during static
* initialisation, thereby populating the map of instances used for virtual
* construction.
*
* @param type
* The named type to register.
*
* @param subclass
* An instance of the ComponentEditor subclass used for virtual
* construction.
*/
static void registerType(const std::string& type,
ComponentEditorPtr subclass);
/**
* greebo: Clears the internal storage - no more component editors
* can be constructed after this call.
*/
static void clear();
};
}
}
|