ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-4/src/UseTheForce/ForceFieldFactory.hpp
(Generate patch)

Comparing branches/new_design/OOPSE-4/src/UseTheForce/ForceFieldFactory.hpp (file contents):
Revision 1783 by tim, Wed Nov 24 21:33:00 2004 UTC vs.
Revision 1837 by tim, Thu Dec 2 22:15:31 2004 UTC

# Line 40 | Line 40 | class ForceField;
40  
41   //forward declaration
42   class ForceField;
43 <
43 > class ForceFieldCreator;
44   /**
45   * @class ForceFieldFactory ForceFieldFactory.hpp "UseTheForce/ForceFieldFactory.hpp"
46   * Factory pattern and Singleton Pattern are used to define an interface for creating an ForceField.
47   */
48   class ForceFieldFactory {
49      public:
50 <
51 <        /** a function pointer which has not parameter and return a pointer pointer to a ForceField instance*/
52 <        typedef ForceField* (*ForceFieldCreatorType)();        
53 <        
54 <        typedef std::map<std::string, ForceFieldCreatorType> CreatorMapType;
50 >                
51 >        typedef std::map<std::string, ForceFieldCreator*> CreatorMapType;
52          typedef std::vector<std::string> IdentVectorType;
53          typedef std::vector<std::string>::iterator IdentVectorIterator;
54                      
# Line 59 | Line 56 | class ForceFieldFactory {
56           * Returns an instance of ForceField factory
57           * @return an instance of ForceField factory
58           */        
59 <        static ForceFieldFactory* getInstance();
59 >        static ForceFieldFactory* getInstance() {
60  
61 +            if (instance_ == NULL) {
62 +                instance_ = new ForceFieldFactory();
63 +            }
64 +            return instance_;
65 +            
66 +        }
67 +
68          /**
69           * Registers a creator with a type identifier
70           * @return true if registration is succeed, otherwise return false
71           * @id the identification of the concrete object
72           * @creator the object responsible to create the concrete object
73           */
74 <        bool registerForceField(const std::string& id, ForceFieldCreatorType creator);
74 >        bool registerForceField(ForceFieldCreator* creator);
75  
76          /**
77           * Unregisters the creator for the given type identifier. If the type identifier

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines