ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/tengDissertation/Appendix.tex
(Generate patch)

Comparing trunk/tengDissertation/Appendix.tex (file contents):
Revision 2821 by tim, Thu Jun 8 06:39:37 2006 UTC vs.
Revision 2823 by tim, Thu Jun 8 07:34:15 2006 UTC

# Line 166 | Line 166 | implemented by delegating the creation operation to th
166   with the problem of creating objects without specifying the exact
167   class of object that will be created. Factory Method is typically
168   implemented by delegating the creation operation to the subclasses.
169 +
170 + Registers a creator with a type identifier. Looks up the type
171 + identifier in the internal map. If it is found, it invokes the
172 + corresponding creator for the type identifier and returns its
173 + result.
174   \begin{lstlisting}[float,caption={[].},label={appendixScheme:factoryDeclaration}]
175    class IntegratorCreator;
176    class IntegratorFactory {
177      public:
178 <      typedef std::map<std::string, IntegratorCreator*> CreatorMapType;
178 >      typedef std::map<string, IntegratorCreator*> CreatorMapType;
179  
175      /**
176       * Registers a creator with a type identifier
177       * @return true if registration is successful, otherwise return false
178       * @id the identification of the concrete object
179       * @creator the object responsible to create the concrete object
180       */
180        bool registerIntegrator(IntegratorCreator* creator);
181  
182 <      /**
184 <       * Looks up the type identifier in the internal map. If it is found, it invokes the
185 <       * corresponding creator for the type identifier and returns its result.
186 <       * @return a pointer of the concrete object, return NULL if no creator is registed for
187 <       * creating this concrete object
188 <       * @param id the identification of the concrete object
189 <       */
190 <      Integrator* createIntegrator(const std::string& id, SimInfo* info);
182 >      Integrator* createIntegrator(const string& id, SimInfo* info);
183  
184      private:
185        CreatorMapType creatorMap_;
# Line 195 | Line 187 | implemented by delegating the creation operation to th
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* IntegratorFactory::createIntegrator(const std::string& id, SimInfo* info) {
194 >  Integrator*
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
# Line 214 | Line 207 | implemented by delegating the creation operation to th
207  
208    class IntegratorCreator {
209    public:
210 <    IntegratorCreator(const std::string& ident) : ident_(ident) {}
211 <    virtual ~IntegratorCreator() {}
212 <    const std::string& getIdent() const { return ident_; }
210 >    IntegratorCreator(const string& ident) : ident_(ident) {}
211 >
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) {}
224 <    virtual  Integrator* create(SimInfo* info) const {return new ConcreteIntegrator(info);}
223 >    IntegratorBuilder(const string& ident) : IntegratorCreator(ident) {}
224 >    virtual  Integrator* create(SimInfo* info) const {
225 >      return new ConcreteIntegrator(info);
226 >    }
227    };
228   \end{lstlisting}
229  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines