| 175 |
|
class IntegratorCreator; |
| 176 |
|
class IntegratorFactory { |
| 177 |
|
public: |
| 178 |
< |
typedef std::map<std::string, IntegratorCreator*> CreatorMapType; |
| 178 |
> |
typedef std::map<string, IntegratorCreator*> CreatorMapType; |
| 179 |
|
|
| 180 |
|
bool registerIntegrator(IntegratorCreator* creator); |
| 181 |
|
|
| 182 |
< |
Integrator* createIntegrator(const std::string& id, SimInfo* info); |
| 182 |
> |
Integrator* createIntegrator(const string& id, SimInfo* info); |
| 183 |
|
|
| 184 |
|
private: |
| 185 |
|
CreatorMapType creatorMap_; |
| 187 |
|
\end{lstlisting} |
| 188 |
|
|
| 189 |
|
\begin{lstlisting}[float,caption={[].},label={appendixScheme:factoryDeclarationImplementation}] |
| 190 |
< |
bool IntegratorFactory::unregisterIntegrator(const std::string& id) { |
| 190 |
> |
bool IntegratorFactory::unregisterIntegrator(const string& id) { |
| 191 |
|
return creatorMap_.erase(id) == 1; |
| 192 |
|
} |
| 193 |
|
|
| 194 |
|
Integrator* |
| 195 |
< |
IntegratorFactory::createIntegrator(const std::string& id, SimInfo* info) { |
| 195 |
> |
IntegratorFactory::createIntegrator(const string& id, SimInfo* info) { |
| 196 |
|
CreatorMapType::iterator i = creatorMap_.find(id); |
| 197 |
|
if (i != creatorMap_.end()) { |
| 198 |
|
//invoke functor to create object |
| 207 |
|
|
| 208 |
|
class IntegratorCreator { |
| 209 |
|
public: |
| 210 |
< |
IntegratorCreator(const std::string& ident) : ident_(ident) {} |
| 210 |
> |
IntegratorCreator(const string& ident) : ident_(ident) {} |
| 211 |
|
|
| 212 |
< |
const std::string& getIdent() const { return ident_; } |
| 212 |
> |
const string& getIdent() const { return ident_; } |
| 213 |
|
|
| 214 |
|
virtual Integrator* create(SimInfo* info) const = 0; |
| 215 |
|
|
| 216 |
|
private: |
| 217 |
< |
std::string ident_; |
| 217 |
> |
string ident_; |
| 218 |
|
}; |
| 219 |
|
|
| 220 |
|
template<class ConcreteIntegrator> |
| 221 |
|
class IntegratorBuilder : public IntegratorCreator { |
| 222 |
|
public: |
| 223 |
< |
IntegratorBuilder(const std::string& ident) : IntegratorCreator(ident) {} |
| 223 |
> |
IntegratorBuilder(const string& ident) : IntegratorCreator(ident) {} |
| 224 |
|
virtual Integrator* create(SimInfo* info) const { |
| 225 |
|
return new ConcreteIntegrator(info); |
| 226 |
|
} |