| 179 |
|
public: |
| 180 |
|
typedef std::map<string, IntegratorCreator*> CreatorMapType; |
| 181 |
|
|
| 182 |
< |
bool registerIntegrator(IntegratorCreator* creator); |
| 182 |
> |
bool registerIntegrator(IntegratorCreator* creator) { |
| 183 |
> |
return creatorMap_.insert(creator->getIdent(), creator).second; |
| 184 |
> |
} |
| 185 |
|
|
| 186 |
< |
Integrator* createIntegrator(const string& id, SimInfo* info); |
| 186 |
> |
Integrator* createIntegrator(const string& id, SimInfo* info) { |
| 187 |
> |
Integrator* result = NULL; |
| 188 |
> |
CreatorMapType::iterator i = creatorMap_.find(id); |
| 189 |
> |
if (i != creatorMap_.end()) { |
| 190 |
> |
result = (i->second)->create(info); |
| 191 |
> |
} |
| 192 |
> |
return result; |
| 193 |
> |
} |
| 194 |
|
|
| 195 |
|
private: |
| 196 |
|
CreatorMapType creatorMap_; |
| 197 |
|
}; |
| 189 |
– |
|
| 198 |
|
\end{lstlisting} |
| 199 |
< |
|
| 192 |
< |
\begin{lstlisting}[float,caption={[The implementation of Factory pattern (II)].},label={appendixScheme:factoryDeclarationImplementation}] |
| 193 |
< |
|
| 194 |
< |
bool IntegratorFactory::unregisterIntegrator(const string& id) { |
| 195 |
< |
return creatorMap_.erase(id) == 1; |
| 196 |
< |
} |
| 197 |
< |
|
| 198 |
< |
Integrator* IntegratorFactory::createIntegrator(const string& id, |
| 199 |
< |
SimInfo* info) { |
| 200 |
< |
CreatorMapType::iterator i = creatorMap_.find(id); |
| 201 |
< |
if (i != creatorMap_.end()) { |
| 202 |
< |
return (i->second)->create(info); |
| 203 |
< |
} else { |
| 204 |
< |
return NULL; |
| 205 |
< |
} |
| 206 |
< |
} |
| 199 |
> |
\begin{lstlisting}[float,caption={[The implementation of Factory pattern (III)]Souce code of creator classes.},label={appendixScheme:integratorCreator}] |
| 200 |
|
|
| 208 |
– |
\end{lstlisting} |
| 209 |
– |
|
| 210 |
– |
\begin{lstlisting}[float,caption={[The implementation of Factory pattern (III)].},label={appendixScheme:integratorCreator}] |
| 211 |
– |
|
| 201 |
|
class IntegratorCreator { |
| 202 |
|
public: |
| 203 |
|
IntegratorCreator(const string& ident) : ident_(ident) {} |
| 297 |
|
\begin{figure} |
| 298 |
|
\centering |
| 299 |
|
\includegraphics[width=\linewidth]{heirarchy.eps} |
| 300 |
< |
\caption[Class heirarchy for StuntDoubles in {\sc OOPSE}]{ The class |
| 301 |
< |
heirarchy of StuntDoubles in {\sc OOPSE}. |
| 300 |
> |
\caption[Class heirarchy for ojects in {\sc OOPSE}]{ A diagram of |
| 301 |
> |
the class heirarchy. |
| 302 |
|
\begin{itemize} |
| 303 |
|
\item A {\bf StuntDouble} is {\it any} object that can be manipulated by the |
| 304 |
|
integrators and minimizers. |