ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-3.0/src/applications/nanoRodBuilder/GeometryFactory.hpp
Revision: 2239
Committed: Sun May 22 21:36:21 2005 UTC (19 years, 1 month ago) by chuckv
File size: 4918 byte(s)
Log Message:
Fix to print pressure tensor.

File Contents

# User Rev Content
1 chuckv 2219 /*
2     * GeometryFactory.hpp
3     * OOPSE-2.0
4     *
5     * Created by Charles F. Vardeman II on 5/3/05.
6     * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
7     *
8     * The University of Notre Dame grants you ("Licensee") a
9     * non-exclusive, royalty free, license to use, modify and
10     * redistribute this software in source and binary code form, provided
11     * that the following conditions are met:
12     *
13     * 1. Acknowledgement of the program authors must be made in any
14     * publication of scientific results based in part on use of the
15     * program. An acceptable form of acknowledgement is citation of
16     * the article in which the program was described (Matthew
17     * A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
18     * J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
19     * Parallel Simulation Engine for Molecular Dynamics,"
20     * J. Comput. Chem. 26, pp. 252-271 (2005))
21     *
22     * 2. Redistributions of source code must retain the above copyright
23     * notice, this list of conditions and the following disclaimer.
24     *
25     * 3. Redistributions in binary form must reproduce the above copyright
26     * notice, this list of conditions and the following disclaimer in the
27     * documentation and/or other materials provided with the
28     * distribution.
29     *
30     * This software is provided "AS IS," without a warranty of any
31     * kind. All express or implied conditions, representations and
32     * warranties, including any implied warranty of merchantability,
33     * fitness for a particular purpose or non-infringement, are hereby
34     * excluded. The University of Notre Dame and its licensors shall not
35     * be liable for any damages suffered by licensee as a result of
36     * using, modifying or distributing the software or its
37     * derivatives. In no event will the University of Notre Dame or its
38     * licensors be liable for any lost revenue, profit or data, or for
39     * direct, indirect, special, consequential, incidental or punitive
40     * damages, however caused and regardless of the theory of liability,
41     * arising out of the use of or inability to use software, even if the
42     * University of Notre Dame has been advised of the possibility of
43     * such damages.
44     */
45     #ifndef NANORODBUILDER_GEOMETRYFACTORY_HPP
46     #define NANORODBUILDER_GEOMETRYFACTORY_HPP
47     #include <cassert>
48     #include <map>
49     #include <string>
50     #include <vector>
51     #include <iostream>
52     namespace oopse {
53    
54     //forward declaration
55     class Geometry;
56     class GeometryCreator;
57     /**
58     * @class GeometryFactory GeometryFactory.hpp
59     * Factory pattern and Singleton Pattern are used to define an interface for creating an Lattice.
60     */
61     class GeometryFactory {
62     public:
63    
64 chuckv 2239 typedef std::map<std::string, GeometryCreator*> CreatorMapType;
65 chuckv 2219 typedef std::vector<std::string> IdentVectorType;
66     typedef std::vector<std::string>::iterator IdentVectorIterator;
67    
68     ~GeometryFactory();
69    
70     /**
71     * Returns an instance of Geometry factory
72     * @return an instance of Geometry factory
73     */
74     static GeometryFactory* getInstance() {
75    
76     if (instance_ == NULL) {
77     instance_ = new GeometryFactory();
78     }
79     return instance_;
80    
81     }
82    
83     /**
84     * Registers a creator with a type identifier
85     * @return true if registration is succeed, otherwise return false
86     * @id the identification of the concrete object
87     * @creator the object responsible to create the concrete object
88     */
89     bool registerGeometry(GeometryCreator* creator);
90    
91     /**
92     * Unregisters the creator for the given type identifier. If the type identifier
93     * was previously registered, the function returns true.
94     * @return truethe type identifier was previously registered and the creator is removed,
95     * otherwise return false
96     * @id the identification of the concrete object
97     */
98     bool unregisterGeometry(const std::string& id);
99     /**
100     * Looks up the type identifier in the internal map. If it is found, it invokes the
101     * corresponding creator for the type identifier and returns its result.
102     * @return a pointer of the concrete object, return NULL if no creator is registed for
103     * creating this concrete object
104     * @param id the identification of the concrete object
105     */
106 chuckv 2239 Geometry* createGeometry(const std::string& id);
107 chuckv 2219
108     /**
109     * Returns all of the registed type identifiers
110     * @return all of the registed type identifiers
111     */
112     IdentVectorType getIdents();
113    
114     private:
115     GeometryFactory() {}
116    
117     static GeometryFactory* instance_;
118     CreatorMapType creatorMap_;
119     };
120    
121     /** write out all of the type identifiers to an output stream */
122     std::ostream& operator <<(std::ostream& o, GeometryFactory& factory);
123    
124     }//namespace oopse
125     #endif //NANORODBUILDER_GEOMETRYFACTORY_HPP