| 2 |
|
#include "BaseLattice.hpp" |
| 3 |
|
#include "LatticeCreator.hpp" |
| 4 |
|
|
| 5 |
+ |
LatticeFactory* LatticeFactory::instance = NULL; |
| 6 |
|
LatticeFactory::~LatticeFactory(){ |
| 7 |
|
map<string, BaseLatticeCreator*>::iterator mapIter; |
| 8 |
|
for (mapIter = creatorMap.begin(); mapIter == creatorMap.end(); ++mapIter) { |
| 10 |
|
} |
| 11 |
|
} |
| 12 |
|
|
| 13 |
< |
static LatticeFactory::LatticeFactory* getInstance(){ |
| 13 |
> |
LatticeFactory* LatticeFactory::getInstance(){ |
| 14 |
|
if (instance == NULL) |
| 15 |
|
instance = new LatticeFactory(); |
| 16 |
|
|
| 17 |
|
return instance; |
| 18 |
|
} |
| 19 |
|
|
| 20 |
< |
bool LatticeFactory::registerCreator( const LatticeCreator* latCreator ){ |
| 21 |
< |
string latticeType = latCreator->GetType(); |
| 20 |
> |
bool LatticeFactory::registerCreator( BaseLatticeCreator* latCreator ){ |
| 21 |
> |
string latticeType = latCreator->getType(); |
| 22 |
|
map<string, BaseLatticeCreator*>::iterator mapIter; |
| 23 |
|
|
| 24 |
|
mapIter = creatorMap.find(latticeType); |
| 34 |
|
} |
| 35 |
|
} |
| 36 |
|
|
| 37 |
< |
BaseLattice* LatticeFactory::createLattice( const string& latticeType ){ |
| 38 |
< |
string latticeType = latCreator->GetType(); |
| 38 |
< |
map<string, BaseLatticeCreator*>::iterator mapIter; |
| 39 |
< |
BaseLatticeCreator* creator; |
| 37 |
> |
BaseLattice* LatticeFactory::createLattice( const string& latticeType ){ |
| 38 |
> |
map<string, BaseLatticeCreator*>::iterator mapIter; |
| 39 |
|
|
| 40 |
|
mapIter = creatorMap.find(latticeType); |
| 41 |
|
|
| 42 |
|
if (mapIter != creatorMap.end()) { |
| 43 |
< |
creator = mapIter->second; |
| 45 |
< |
return creator->createLattice(); |
| 43 |
> |
return (mapIter->second)->createLattice(); |
| 44 |
|
} |
| 45 |
|
else |
| 46 |
|
return NULL; |