--- trunk/tengDissertation/Appendix.tex 2006/06/08 07:34:15 2823 +++ trunk/tengDissertation/Appendix.tex 2006/06/08 15:44:14 2824 @@ -141,7 +141,7 @@ The corresponding implementation is }; \end{lstlisting} The corresponding implementation is -\begin{lstlisting}[float,caption={[A classic Singleton design pattern implementation(II)] Implementation of {\tt IntegratorFactory} class.},label={appendixScheme:singletonImplementation}] +\begin{lstlisting}[float,caption={[A classic implementation of Singleton design pattern (II)] Implementation of {\tt IntegratorFactory} class.},label={appendixScheme:singletonImplementation}] IntegratorFactory::instance_ = NULL; @@ -171,7 +171,7 @@ result. identifier in the internal map. If it is found, it invokes the corresponding creator for the type identifier and returns its result. -\begin{lstlisting}[float,caption={[].},label={appendixScheme:factoryDeclaration}] +\begin{lstlisting}[float,caption={[The implementation of Factory pattern (I)].},label={appendixScheme:factoryDeclaration}] class IntegratorCreator; class IntegratorFactory { public: @@ -186,7 +186,7 @@ result. }; \end{lstlisting} -\begin{lstlisting}[float,caption={[].},label={appendixScheme:factoryDeclarationImplementation}] +\begin{lstlisting}[float,caption={[The implementation of Factory pattern (II)].},label={appendixScheme:factoryDeclarationImplementation}] bool IntegratorFactory::unregisterIntegrator(const string& id) { return creatorMap_.erase(id) == 1; } @@ -203,7 +203,7 @@ result. } \end{lstlisting} -\begin{lstlisting}[float,caption={[].},label={appendixScheme:integratorCreator}] +\begin{lstlisting}[float,caption={[The implementation of Factory pattern (III)].},label={appendixScheme:integratorCreator}] class IntegratorCreator { public: @@ -230,12 +230,23 @@ that you want to perform on the elements of a data str \subsection{\label{appendixSection:visitorPattern}Visitor} The purpose of the Visitor Pattern is to encapsulate an operation -that you want to perform on the elements of a data structure. In -this way, you can change the operation being performed on a -structure without the need of changing the class heirarchy of the -elements that you are operating on. +that you want to perform on the elements. The operation being +performed on a structure can be switched without changing the +interfaces of the elements. In other words, one can add virtual +functions into a set of classes without modifying their interfaces. +The UML class diagram of Visitor patten is shown in +Fig.~\ref{appendixFig:visitorUML}. {\tt Dump2XYZ} program in +Sec.~\ref{appendixSection:Dump2XYZ} uses Visitor pattern +extensively. -\begin{lstlisting}[float,caption={[].},label={appendixScheme:visitor}] +\begin{figure} +\centering +\includegraphics[width=\linewidth]{architecture.eps} +\caption[The architecture of {\sc OOPSE}] {Overview of the structure +of {\sc OOPSE}} \label{appendixFig:visitorUML} +\end{figure} + +\begin{lstlisting}[float,caption={[The implementation of Visitor pattern (I)]Source code of the visitor classes.},label={appendixScheme:visitor}] class BaseVisitor{ public: virtual void visit(Atom* atom); @@ -243,7 +254,8 @@ elements that you are operating on. virtual void visit(RigidBody* rb); }; \end{lstlisting} -\begin{lstlisting}[float,caption={[].},label={appendixScheme:element}] + +\begin{lstlisting}[float,caption={[The implementation of Visitor pattern (II)]Source code of the element classes.},label={appendixScheme:element}] class StuntDouble { public: virtual void accept(BaseVisitor* v) = 0;