Xyce  6.1
N_ANP_RegisterAnalysis.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_RegisterAnalysis.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 $
40 //
41 // Revision Date : $Date: 2015/10/27 19:24:39 $
42 //
43 // Current Owner : $Author: tvrusso $
44 //-----------------------------------------------------------------------------
45 
46 #ifndef Xyce_N_ANP_RegisterAnalysis_h
47 #define Xyce_N_ANP_RegisterAnalysis_h
48 
49 #include <N_ANP_fwd.h>
50 #include <N_DEV_fwd.h>
51 #include <N_IO_fwd.h>
52 #include <N_LAS_fwd.h>
53 #include <N_LOA_fwd.h>
54 #include <N_NLS_fwd.h>
55 #include <N_TOP_fwd.h>
56 #include <N_UTL_fwd.h>
57 
58 #include <N_UTL_Factory.h>
59 
60 namespace Xyce {
61 namespace Analysis {
62 
64 private:
65  typedef Util::Factory<AnalysisBase, void> Factory;
66  typedef std::vector<Factory *> Registry;
67 
68 public:
70  {
71  for (Registry::iterator it = registry_.begin(), end = registry_.end(); it != end; ++it)
72  delete (*it);
73  }
74 
75  void add(Factory *factory)
76  {
77  registry_.push_back(factory);
78  }
79 
80  Registry::const_iterator begin() const
81  {
82  return registry_.begin();
83  }
84 
85  Registry::const_iterator end() const
86  {
87  return registry_.end();
88  }
89 
90 private:
91  Registry registry_;
92 };
93 
95 {
96 private:
97  typedef Util::Factory<ProcessorBase, void> Factory;
98  typedef std::vector<Factory *> Registry;
99 
100 public:
102  {
103  for (Registry::iterator it = registry_.begin(), end = registry_.end(); it != end; ++it)
104  delete (*it);
105  }
106 
107  void add(Factory *factory)
108  {
109  registry_.push_back(factory);
110  }
111 
112  Registry::const_iterator begin() const
113  {
114  return registry_.begin();
115  }
116 
117  Registry::const_iterator end() const
118  {
119  return registry_.end();
120  }
121 
122 private:
123  Registry registry_;
124 };
125 
126 
127 //-----------------------------------------------------------------------------
128 // Class : FactoryBlock
129 // Purpose :
130 // Special Notes :
131 // Scope : public
132 // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
133 // Creation Date : Mon Jan 27 14:49:12 2014
134 //-----------------------------------------------------------------------------
135 ///
136 /// The FactoryBlock contains parameters needed by the analysis creation functions. This allows additional parameter to
137 /// be added without the need to change the interface.
138 ///
140 {
141  //-----------------------------------------------------------------------------
142  // Function : FactoryBlock
143  // Purpose :
144  // Special Notes :
145  // Scope : public
146  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
147  // Creation Date : Fri Mar 14 13:05:27 2014
148  //-----------------------------------------------------------------------------
149  ///
150  /// The FactoryBlock constructs serves to pass data to the device factory functions
151  ///
152  /// @invariant These references must exist through the execution of Xyce
153  ///
155  AnalysisCreatorRegistry & analysis_registry,
156  ProcessorCreatorRegistry & processor_registry,
157  IO::PkgOptionsMgr & options_manager,
158  AnalysisManager & analysis_manager,
159  IO::OutputMgr & output_manager,
160  Linear::System & linear_system,
161  Nonlinear::Manager & nonlinear_manager,
162  Loader::Loader & loader,
163  Device::DeviceMgr & device_manager,
164  Linear::Builder & builder,
165  Topo::Topology & topology,
166  IO::InitialConditionsManager & initial_conditions_manager,
167  IO::RestartMgr & restart_manager)
168  : analysisRegistry_(analysis_registry),
169  processorRegistry_(processor_registry),
170  optionsManager_(options_manager),
171  analysisManager_(analysis_manager),
172  outputManager_(output_manager),
173  linearSystem_(linear_system),
174  nonlinearManager_(nonlinear_manager),
175  loader_(loader),
176  deviceManager_(device_manager),
177  builder_(builder),
178  topology_(topology),
179  initialConditionsManager_(initial_conditions_manager),
180  restartManager_(restart_manager)
181  {}
182 
185  IO::PkgOptionsMgr & optionsManager_;
187  IO::OutputMgr & outputManager_;
188  Linear::System & linearSystem_;
192  Linear::Builder & builder_;
193  Topo::Topology & topology_;
194  IO::InitialConditionsManager & initialConditionsManager_;
195  IO::RestartMgr & restartManager_;
196 };
197 
198 void registerAnalysisFactory(FactoryBlock &factory_block);
199 
200 inline void addAnalysisFactory(FactoryBlock &factory_block, Util::Factory<AnalysisBase, void> *factory)
201 {
202  factory_block.analysisRegistry_.add(factory);
203 }
204 
205 inline void addProcessorFactory(FactoryBlock &factory_block, Util::Factory<ProcessorBase, void> *factory)
206 {
207  factory_block.processorRegistry_.add(factory);
208 }
209 
210 } // namespace Analysis
211 } // namespace Xyce
212 
213 #endif // Xyce_N_ANP_RegisterAnalysis_h
Registry::const_iterator begin() const
void addProcessorFactory(FactoryBlock &factory_block, Util::Factory< ProcessorBase, void > *factory)
Pure virtual class to augment a linear system.
Registry::const_iterator end() const
ProcessorCreatorRegistry & processorRegistry_
Registry::const_iterator begin() const
FactoryBlock(AnalysisCreatorRegistry &analysis_registry, ProcessorCreatorRegistry &processor_registry, IO::PkgOptionsMgr &options_manager, AnalysisManager &analysis_manager, IO::OutputMgr &output_manager, Linear::System &linear_system, Nonlinear::Manager &nonlinear_manager, Loader::Loader &loader, Device::DeviceMgr &device_manager, Linear::Builder &builder, Topo::Topology &topology, IO::InitialConditionsManager &initial_conditions_manager, IO::RestartMgr &restart_manager)
The FactoryBlock constructs serves to pass data to the device factory functions.
void registerAnalysisFactory(FactoryBlock &factory_block)
Registers the analysis factories.
The FactoryBlock contains parameters needed by the analysis creation functions.
IO::InitialConditionsManager & initialConditionsManager_
AnalysisCreatorRegistry & analysisRegistry_
Util::Factory< ProcessorBase, void > Factory
Nonlinear::Manager & nonlinearManager_
void addAnalysisFactory(FactoryBlock &factory_block, Util::Factory< AnalysisBase, void > *factory)
Util::Factory< AnalysisBase, void > Factory
Registry::const_iterator end() const