Xyce  6.1
N_ANP_Factory.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // Copyright Notice
3 //
4 // Copyright 2002 Sandia Corporation. Under the terms
5 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
6 // Government retains certain rights in this software.
7 //
8 // Xyce(TM) Parallel Electrical Simulator
9 // Copyright (C) 2002-2015 Sandia Corporation
10 //
11 // This program is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 //-----------------------------------------------------------------------------
24 
25 //-----------------------------------------------------------------------------
26 // Filename : $RCSfile: N_ANP_Factory.h,v $
27 //
28 // Purpose :
29 //
30 // Special Notes :
31 //
32 // Creator : Richard Schiek, SNL, Electrical and Microsystem Modeling
33 //
34 // Creation Date : 01/24/08
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.6.2.1 $
40 //
41 // Revision Date : $Date: 2015/04/02 18:20:06 $
42 //
43 // Current Owner : $Author: tvrusso $
44 //-----------------------------------------------------------------------------
45 
46 ///
47 /// @file N_ANP_Factory.h
48 /// @author David G. Baur Raytheon Sandia National Laboratories 1355 <dgbaur@sandia.gov>
49 /// @date Thu Jan 29 12:51:28 2015
50 ///
51 /// @brief Factory for creating analysis objects
52 ///
53 ///
54 #ifndef Xyce_N_ANP_Factory_h
55 #define Xyce_N_ANP_Factory_h
56 
57 #include <typeinfo>
58 
59 #include <N_LAS_fwd.h>
60 
61 namespace Xyce {
62 namespace Analysis {
63 
64 template<class T>
65 class Factory;
66 
67 //-----------------------------------------------------------------------------
68 // Template : Factory
69 // Purpose :
70 // Special Notes :
71 // Scope : public
72 // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
73 // Creation Date : Thu Jan 29 12:40:53 2015
74 //-----------------------------------------------------------------------------
75 ///
76 /// The analysis factory template defines an interface for analysis type testing and
77 /// analysis creation.
78 ///
79 template<>
80 class Factory<void>
81 {
82 public:
83  //-----------------------------------------------------------------------------
84  // Function : Factory
85  // Purpose :
86  // Special Notes :
87  // Scope : public
88  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
89  // Creation Date : Thu Jan 29 12:41:54 2015
90  //-----------------------------------------------------------------------------
91  ///
92  /// Constructor
93  ///
95  {}
96 
97  //-----------------------------------------------------------------------------
98  // Function : ~Factory
99  // Purpose :
100  // Special Notes :
101  // Scope : public
102  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
103  // Creation Date : Thu Jan 29 12:43:11 2015
104  //-----------------------------------------------------------------------------
105  ///
106  /// Destructor
107  ///
108  virtual ~Factory()
109  {}
110 
111  //-----------------------------------------------------------------------------
112  // Function : type
113  // Purpose :
114  // Special Notes :
115  // Scope : public
116  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
117  // Creation Date : Thu Jan 29 12:43:43 2015
118  //-----------------------------------------------------------------------------
119  ///
120  /// Defines the interface to get the type info of the analysis created by the factory.
121  ///
122  /// @return type info of the analysis that would be created.
123  ///
124  ///
125  virtual const std::type_info &type() const = 0;
126 
127  //-----------------------------------------------------------------------------
128  // Function : isType
129  // Purpose :
130  // Special Notes :
131  // Scope : public
132  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
133  // Creation Date : Thu Jan 29 12:45:04 2015
134  //-----------------------------------------------------------------------------
135  ///
136  /// Returns true if the analysis type of the factory matches class U
137  ///
138  /// @param U Analysis class type to test
139  ///
140  /// @return true if the analysis type of the factory matches class U
141  ///
142  ///
143  template <class U>
144  bool isType() const {
145  return type() == typeid(U);
146  }
147 
148 private:
149  Factory(const Factory &); ///< not copyable
150  Factory &operator=(const Factory &); ///< not assignable
151 
152 public:
153  //-----------------------------------------------------------------------------
154  // Function : create
155  // Purpose :
156  // Special Notes :
157  // Scope : public
158  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
159  // Creation Date : Thu Jan 29 12:47:13 2015
160  //-----------------------------------------------------------------------------
161  ///
162  /// Creates the analysis object.
163  ///
164  /// @return the new analysis object
165  ///
166  ///
167  virtual AnalysisBase *create() const = 0;
168 };
169 
170 //-----------------------------------------------------------------------------
171 // Template : Factory
172 // Purpose :
173 // Special Notes :
174 // Scope : public
175 // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
176 // Creation Date : Thu Jan 29 12:40:53 2015
177 //-----------------------------------------------------------------------------
178 ///
179 /// The analysis factory template defines an interface for analysis type testing and
180 /// analysis creation. This template implements the type checking.
181 ///
182 /// @param T analysis type to be created
183 ///
184 template<class T>
185 class Factory : public Factory<void>
186 {
187 public:
188  //-----------------------------------------------------------------------------
189  // Function : Factory
190  // Purpose :
191  // Special Notes :
192  // Scope : public
193  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
194  // Creation Date : Thu Jan 29 12:49:44 2015
195  //-----------------------------------------------------------------------------
196  ///
197  /// Constructor
198  ///
200  : Factory<void>()
201  {}
202 
203  //-----------------------------------------------------------------------------
204  // Function : ~Factory
205  // Purpose :
206  // Special Notes :
207  // Scope : public
208  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
209  // Creation Date : Thu Jan 29 12:50:03 2015
210  //-----------------------------------------------------------------------------
211  ///
212  /// Destructor
213  ///
214  virtual ~Factory()
215  {}
216 
217  //-----------------------------------------------------------------------------
218  // Function : type
219  // Purpose :
220  // Special Notes :
221  // Scope : public
222  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
223  // Creation Date : Thu Jan 29 12:50:21 2015
224  //-----------------------------------------------------------------------------
225  ///
226  /// Returns the type info the analysis type.
227  ///
228  /// @return the type info the analysis type.
229  ///
230  virtual const std::type_info &type() const {
231  return typeid(T);
232  }
233 };
234 
235 typedef std::vector<Factory<void> *> Registry; ///< Registry of factories
236 
237 } // namespace Analysis
238 } // namespace Xyce
239 
240 #endif // Xyce_N_ANP_Factory_h
Pure virtual class to augment a linear system.
Factory()
Constructor.
bool isType() const
Returns true if the analysis type of the factory matches class U.
virtual ~Factory()
Destructor.
virtual ~Factory()
Destructor.
TimeIntegrationMethod *(* Factory)(const TIAParams &tia_params, StepErrorControl &step_error_control, DataStore &data_store)
The analysis factory template defines an interface for analysis type testing and analysis creation...
Definition: N_ANP_Factory.h:65
virtual const std::type_info & type() const
Returns the type info the analysis type.
std::vector< Factory< void > * > Registry
Registry of factories.