Produces AVR devices. More...
#include <avrfactory.h>
Public Types | |
typedef AvrDevice *(* | AvrDeviceCreator )() |
Public Member Functions | |
AvrDevice * | makeDevice (const char *config) |
Static Public Member Functions | |
static AvrFactory & | instance () |
Singleton class access. | |
static std::string | supportedDevices () |
static void | reg (const std::string name, AvrDeviceCreator create) |
Register a creation static method with the factory. | |
Private Member Functions | |
AvrFactory () | |
Private Attributes | |
std::map< std::string, AvrFactory::AvrDeviceCreator > | devmap |
map of registered AVR devices |
Produces AVR devices.
Factory for producing AVR devices according to a configuration string. This decouples the instantiation of concrete AVR devices from the code using them. It is helpful to remove all direct references to particular AVR devices in the code which uses them, such as in main.cpp.
Definition at line 39 of file avrfactory.h.
typedef AvrDevice*(* AvrFactory::AvrDeviceCreator)() |
Definition at line 42 of file avrfactory.h.
AvrFactory::AvrFactory | ( | ) | [inline, private] |
Definition at line 62 of file avrfactory.h.
AvrFactory & AvrFactory::instance | ( | ) | [static] |
Singleton class access.
Definition at line 72 of file avrfactory.cpp.
Referenced by avr_create_tf(), main(), reg(), and supportedDevices().
AvrDevice * AvrFactory::makeDevice | ( | const char * | config | ) |
Produces an AVR device according to the configuration string. Right now, the configuration string is simply the full name of the AVR device, like AT90S4433 or ATMEGA128.
Definition at line 50 of file avrfactory.cpp.
References avr_error, and devmap.
Referenced by avr_create_tf(), and main().
void AvrFactory::reg | ( | const std::string | name, | |
AvrDeviceCreator | create | |||
) | [static] |
Register a creation static method with the factory.
Definition at line 37 of file avrfactory.cpp.
References avr_error, devmap, and instance().
std::string AvrFactory::supportedDevices | ( | ) | [static] |
Gives a list of all supported devices, which can be supplied to makeDevice() as is.
Definition at line 63 of file avrfactory.cpp.
References devmap, and instance().
Referenced by main().
std::map<std::string, AvrFactory::AvrDeviceCreator> AvrFactory::devmap [private] |
map of registered AVR devices
Definition at line 64 of file avrfactory.h.
Referenced by makeDevice(), reg(), and supportedDevices().