#include <iostream>
#include <loki/Factory.h>
using namespace std;
using namespace Loki;
struct jedi
{
virtual ~jedi() {};
virtual void hello() = 0;
};
struct yoda : public jedi
{
virtual ~yoda() {};
virtual void hello() {cout << "i'm yoda" << endl;}
};
struct mace : public jedi
{
virtual ~mace() {};
virtual void hello() {cout << "i'm mace" << endl;}
};
yoda* create_yoda() {return new yoda;}
mace* create_mace() {return new mace;}
struct yavin {yavin(string sz) {cout << sz << endl;}};
yavin* create_yavin(string sz) {return new yavin(sz);}
int main()
{
Factory<jedi, int> jedi_factory;
jedi_factory.Register(1, create_yoda);
jedi_factory.Register(2, create_mace);
jedi* j = jedi_factory.CreateObject(2);
j->hello();
delete j; j = 0;
j = jedi_factory.CreateObject(1);
j->hello();
delete j; j = 0;
Factory<yavin, int, LOKI_TYPELIST_1(string)> fac;
fac.Register(1, create_yavin);
yavin* f = fac.CreateObject(1, "i'm on yavin");
delete f; f=0;
return 0;
}