Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_DEV_Configuration.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-2011 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_DEV_Configuration.h,v $
27 //
28 // Purpose : Holds device configuration information
29 //
30 // Special Notes :
31 //
32 // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
33 //
34 // Creation Date : 2013/04/18 18:01:27
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.22 $
40 //
41 // Revision Date : $Date: 2014/05/21 21:53:12 $
42 //
43 // Current Owner : $Author: tvrusso $
44 //-------------------------------------------------------------------------
45 
46 #ifndef Xyce_N_DEV_Configuration_h
47 #define Xyce_N_DEV_Configuration_h
48 
49 #include <map>
50 #include <string>
51 #include <vector>
52 
53 #include <N_DEV_fwd.h>
54 #include <N_IO_fwd.h>
55 #include <N_DEV_Pars.h>
56 
57 namespace Xyce {
58 namespace Device {
59 
61 {};
62 
63 template<class M, class G>
65 {
66  typedef typename G::ModelType GroupType_;
67 };
68 
69 template<class M>
71 {
72  typedef M GroupType_;
73 };
74 
75 //-----------------------------------------------------------------------------
76 // Class : DeviceTraits
77 // Purpose : Defines the device configuration data and grouping
78 // Special Notes :
79 // Scope : public
80 // Creator : Dave Baur, Raytheon
81 // Creation Date : 1/27/2014
82 //-----------------------------------------------------------------------------
83 ///
84 /// The DeviceTraits template describes the configuration of a device.
85 ///
86 /// Generally a device uses a typedef to define its traits:
87 ///
88 /// typedef DeviceTraits<Instance, Model> Traits; ///< Device traits for a group device
89 ///
90 /// or
91 ///
92 /// typedef DeviceTraits<Instance, Model, Resistor::Traits> Traits ///< Device is part of the Resistor device group
93 ///
94 /// Every device has an Instance class, a Model class and a ModelGroup class. An Instance is created for every device in
95 /// the netlist. A Model class is created for each unique model definition in the net list. The ModelGroup serves as a
96 /// device type grouping mechanism and is generally the level 1 device of a model with the other models having higher
97 /// level values.
98 ///
99 /// The EntityTypeId, ModelTypeId and InstanceTypeId are all descriptive typedefs for Util::type_index. These model
100 /// type identifiers and instance type identifiers are uniquely defined for each instance and model. The model type
101 /// identifier also serves as the model group identifier. The model groups are identified when the model traits is
102 /// ModeGroupLeadTraits which is the case for the two parameter DeviceTraits trait.
103 ///
104 /// Every device also has or may have nodes, optional nodes, fill nodes, a model required flags, a primary parameter, a
105 /// linear device flags and PDE device flag. These values are all provided via static traits functions, most of which
106 /// have default implementations.
107 ///
108 /// Every device must specify not only the device relationships above as template parameters, but must also define the
109 /// numNodes() and isLinearDevice() functions as providing a default value was too error prone.
110 ///
111 ///
112 /// DEVICE REGISTRATION:
113 /// Each device calls registerDevice() to register the device with the configuration. Each device must also call
114 /// registerModelType() for each model type to be defined.
115 ///
116 /// registerDevice()
117 /// - adds to the configurationMap_: (device_name, device_level) -> configuration
118 /// - adds to the modelTypeConfigurationMap_: model_type_id -> configuration
119 ///
120 /// registerModel()
121 /// - if model_type_id == model_group_id, adds to the modelTypeNameModelGroupMap_: model_name -> model_group_id
122 /// - adds to the modelTypeNameLevelModelTypeMap_: (model_name, level) -> model_type_id
123 /// - adds the model_name to the modelTypeNames list of device configuration
124 ///
125 /// THE CONFIGURATION IS CURRENTLY STORED IN A SINGLETON. This may not be as issue in that the configuration is
126 /// constructed exactly once via device registration and plugin loading at Xyce startup.
127 ///
128 /// The default parameter for a device is the parameter that will be used
129 /// if a single untagged parameter value is given on an instance line. For
130 /// example, the resistor's default parameter is R, and on the
131 /// line
132 /// @code
133 /// R1 A B 5k
134 /// @endcode
135 /// the untagged value (5k) will be assigned to the resistor's
136 /// R parameter.
137 ///
138 /// A primary parameter is the parameter that will be changed by a
139 /// .STEP loop or natural parameter homotopy when only the device name
140 /// is given. In the resistor, the primary parameter is also "R", and
141 /// so
142 /// @code
143 /// .STEP R1 1 10 1
144 /// @endcode
145 /// will step R1's R parameter from 1 to 10. In
146 /// most existing devices the primary parameter is the same as the
147 /// default parameter, but it is not required that this be the
148 /// case.
149 ///
150 /// Optional nodes are nodes that may be specified on the instance line, and
151 /// if not specified are internal nodes instead of external. Fill nodes are
152 /// like optional nodes, but if not specified they are connected to ground.
153 /// Examples of optional nodes include the internal and external body contacts
154 /// in the BSIM3 SOI model. Examples of fill nodes include the substrate
155 /// node of the level 1 BJT model.
156 template <class M, class I, class G>
158 {
159 public:
160  typedef I InstanceType; ///< Make instance template parameter available
161  typedef M ModelType; ///< Make model template parameter available
162  typedef G ModelGroupTraits; ///< Make model group traits template parameter available
163  typedef typename ModelGroupType_<M, G>::GroupType_ ModelGroupType; ///< Make model group template parameter available
164 
165  //-----------------------------------------------------------------------------
166  // Function : instanceType
167  // Purpose :
168  // Special Notes :
169  // Scope : public
170  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
171  // Creation Date : Fri Mar 14 13:00:58 2014
172  //-----------------------------------------------------------------------------
173  ///
174  /// Returns the instance type identifier
175  ///
176  /// @return the typeid wrapper for the instance type identifier
177  ///
179  {
180  return EntityTypeId(typeid(InstanceType));
181  }
182 
183  //-----------------------------------------------------------------------------
184  // Function : modelType
185  // Purpose :
186  // Special Notes :
187  // Scope : public
188  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
189  // Creation Date : Wed Feb 5 10:41:46 2014
190  //-----------------------------------------------------------------------------
191  ///
192  /// Returns the model type identifier
193  ///
194  /// @return the typeid wrapper for the model type identifier
195  ///
196  static const ModelTypeId modelType()
197  {
198  return EntityTypeId(typeid(ModelType));
199  }
200 
201  //-----------------------------------------------------------------------------
202  // Function : modelGroupType
203  // Purpose :
204  // Special Notes :
205  // Scope : public
206  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
207  // Creation Date : Wed Feb 5 10:42:39 2014
208  //-----------------------------------------------------------------------------
209  ///
210  /// Returns the model group identifier
211  ///
212  /// @return the typeid wrapper for the model group identifier
213  ///
214  static const ModelTypeId modelGroup()
215  {
216  return EntityTypeId(typeid(ModelGroupType));
217  }
218 
219  //-----------------------------------------------------------------------------
220  // Function : factory
221  // Purpose :
222  // Special Notes :
223  // Scope : public
224  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
225  // Creation Date : Thu Feb 6 10:20:07 2014
226  //-----------------------------------------------------------------------------
227  ///
228  /// Creates a device via the device template
229  ///
230  /// Generally implemented as:
231  ///
232  /// @code
233  /// static Device *factory(const Configuration &configuration, const FactoryBlock &factory_block)
234  /// {
235  /// return new DeviceMaster<Traits>(configuration, factory_block, factory_block.solverState_, factory_block.deviceOptions_);
236  /// }
237  /// @endcode
238  ///
239  /// or
240  ///
241  /// @code
242  /// static Device *factory(const Configuration &configuration, const FactoryBlock &factory_block)
243  /// {
244  /// return new Master(configuration, factory_block, factory_block.solverState_, factory_block.deviceOptions_);
245  /// }
246  /// @endcode
247  ///
248  /// when Master extends DeviceMaster.
249  ///
250  /// @param configuration const reference to the device configuration
251  /// @param factory_block const reference to the factory parameters
252  ///
253  /// @return pointer to the newly created device
254  ///
255  static Device *factory(const Configuration &configuration, const FactoryBlock &factory_block);
256 
257  static int numNodes(); ///< Number of nodes must be provided in the deriving class
258  static int numOptionalNodes() {return 0;} ///< Default number of optional nodes
259  static int numFillNodes() {return 0;} ///< Default number of fill nodes
260  static bool modelRequired() {return false;} ///< By default, model is not required
261  static const char *primaryParameter() {return "";} ///< By default, there is no primary parameter
262  static const char *instanceDefaultParameter() {return "";} ///< By default, there is no instance default parameter
263  static bool isLinearDevice(); ///< Linear device flag must be provided in the deriving class
264  static bool isPDEDevice() {return false;} ///< By default, device is not a PDE device
265 };
266 
267 //-----------------------------------------------------------------------------
268 // Class : FactoryBlock
269 // Purpose :
270 // Special Notes :
271 // Scope : public
272 // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
273 // Creation Date : Mon Jan 27 14:49:12 2014
274 //-----------------------------------------------------------------------------
275 ///
276 /// The FactoryBlock contains parameters needed by the device,
277 /// instance and model creation functions. This allows additional
278 /// parameter to be added without the need to change the interface.
279 ///
280 /// The DeviceMgr class generally calls the factory functions and owns
281 /// these objects, however this is by no means a requirement.
282 ///
284 {
285  //-----------------------------------------------------------------------------
286  // Function : FactoryBlock
287  // Purpose :
288  // Special Notes :
289  // Scope : public
290  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
291  // Creation Date : Fri Mar 14 13:05:27 2014
292  //-----------------------------------------------------------------------------
293  ///
294  /// The FactoryBlock constructs serves to pass data to the device factory functions
295  ///
296  /// @invariant These references must exist through the execution of Xyce
297  ///
298  /// @param device_options
299  /// @param solver_state
300  /// @param matrix_load_data
301  /// @param extern_data
302  /// @param command_line
303  ///
305  const DeviceOptions & device_options,
306  const SolverState & solver_state,
307  MatrixLoadData & matrix_load_data,
308  const ExternData & extern_data,
309  const IO::CmdParse & command_line)
310  : deviceOptions_(device_options),
311  solverState_(solver_state),
312  matrixLoadData_(matrix_load_data),
313  externData_(extern_data),
314  commandLine_(command_line)
315  {}
316 
321  const IO::CmdParse & commandLine_;
322 };
323 
324 /// Class Configuration contains device configuration data.
325 ///
326 /// The DeviceTraits template describes the device and configuration is an object that holds the data obtained via the
327 /// traits.
328 ///
329 /// The configuration also maintains several containers that allow device, instance and model data and creation functions
330 /// to be located by name and level.
331 ///
333 {
334  public:
335  typedef std::map<NameLevelKey, Configuration *, NameLevelLess> ConfigurationMap;
336 
337  //-----------------------------------------------------------------------------
338  // Function : getConfigurationMap
339  // Purpose : Return the configuration map
340  // Special Notes :
341  // Scope : public
342  // Creator : Dave Baur, Raytheon
343  // Creation Date : 2/5/2014
344  //-----------------------------------------------------------------------------
345  ///
346  /// Returns the configuration map of the system
347  ///
348  /// The configuration map maps the device name and level pair to its configuration.
349  ///
350  /// @return const reference to the device configuration map.
351  static const ConfigurationMap &getConfigurationMap();
352 
353  //-----------------------------------------------------------------------------
354  // Function : findConfiguration
355  // Purpose :
356  // Special Notes :
357  // Scope : public
358  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
359  // Creation Date : Wed Feb 5 10:54:24 2014
360  //-----------------------------------------------------------------------------
361  ///
362  /// Returns the configuration associated with the device name and level or 0 if not found
363  ///
364  /// @param device_name const reference to the device name
365  /// @param level device level
366  ///
367  /// @return const pointer to the specified device's configuration
368  ///
369  static const Configuration *findConfiguration(ModelTypeId model_type_id);
370 
371  //-----------------------------------------------------------------------------
372  // Function : findConfiguration
373  // Purpose :
374  // Special Notes :
375  // Scope : public
376  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
377  // Creation Date : Wed Feb 5 10:54:24 2014
378  //-----------------------------------------------------------------------------
379  ///
380  /// Returns the configuration associated with the device name and level or 0 if not found
381  ///
382  /// @param device_name const reference to the device name
383  /// @param level device level
384  ///
385  /// @return const pointer to the specified device's configuration
386  ///
387  static const Configuration *findConfiguration(const std::string &device_name, const int level);
388 
389  //-----------------------------------------------------------------------------
390  // Function : getModelType
391  // Purpose :
392  // Special Notes :
393  // Scope : public
394  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
395  // Creation Date : Wed Feb 5 10:54:24 2014
396  //-----------------------------------------------------------------------------
397  ///
398  /// Returns the model type identifier for the specified device, if
399  /// the model type and level is not found, return an invalid type.
400  ///
401  /// @param model_name const reference to the model name
402  /// @param level device level
403  ///
404  /// @return the model type identifier for the specified device model
405  ///
406  static ModelTypeId getModelType(const std::string &model_name, const int level);
407 
408  //-----------------------------------------------------------------------------
409  // Function : getModelGroup
410  // Purpose :
411  // Special Notes :
412  // Scope : public
413  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
414  // Creation Date : Wed Feb 5 10:54:24 2014
415  //-----------------------------------------------------------------------------
416  ///
417  /// Returns the model group of the device name
418  ///
419  /// A device is registered as the model group when its model type identifier equals its model group identifier.
420  ///
421  /// @param device_name const reference to the device name
422  ///
423  /// @return model group identifier for the specified device
424  ///
425  static ModelTypeId getModelGroup(const std::string &device_name);
426 
427  protected:
428  //-----------------------------------------------------------------------------
429  // Function : Configuration
430  // Purpose :
431  // Special Notes :
432  // Scope : protected
433  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
434  // Creation Date : Mon Jan 27 15:06:50 2014
435  //-----------------------------------------------------------------------------
436  ///
437  /// Populates the device configuration object.
438  ///
439  /// Note that the instanceParameters_ and modelParameters_ each reference the instanceParameters__ and
440  /// modelParameters__ object of the derived Config<Traits> class. This really just keeps that casting down and could
441  /// be implemented as ParametricData<void> objects here.
442  ///
443  /// @param instance_parameters
444  /// @param model_parameters
445  /// @param name
446  /// @param device_type_name
447  /// @param num_nodes
448  /// @param num_optional_nodes
449  /// @param num_fill_nodes
450  /// @param model_required
451  /// @param primary_parameter
452  ///
454  ParametricData<void> & instance_parameters,
455  ParametricData<void> & model_parameters,
456  const char * name,
457  const char * device_type_name,
458  const char * instance_default_parameter_name,
459  int num_nodes,
460  int num_optional_nodes,
461  int num_fill_nodes,
462  bool model_required,
463  bool linear_device,
464  bool pde_device,
465  const char * primary_parameter)
466  : instanceParameters_(instance_parameters),
467  modelParameters_(model_parameters),
468  name_(name),
469  deviceTypeName_(device_type_name),
470  instanceDefaultParameterName_(instance_default_parameter_name),
471  numNodes_(num_nodes),
472  numOptionalNodes_(num_optional_nodes),
473  numFillNodes_(num_fill_nodes),
474  modelRequired_(model_required),
475  linearDevice_(linear_device),
476  pdeDevice_(pde_device),
477  primaryParameter_(primary_parameter),
479  {}
480 
481  public:
482  virtual ~Configuration()
483  {}
484 
485  private:
486  Configuration(const Configuration &); ///< No copies allowed
487  Configuration &operator=(const Configuration &); ///< No assignment allowed
488 
489  public:
490  /// Returns the instance parameter descriptions
491  ///
492  /// @return reference to the instance parameter descriptions
493  ///
495  {
496  return instanceParameters_;
497  }
498 
499  /// Returns the model parameter descriptions
500  ///
501  /// @return reference to the model parameter descriptions
502  ///
504  {
505  return modelParameters_;
506  }
507 
508  /// Returns the device name
509  ///
510  /// @return const reference to the device name
511  ///
512  const std::string &getName() const
513  {
514  return name_;
515  }
516 
517  /// Returns the device type name
518  ///
519  /// @return const reference to the device type name
520  ///
521  const std::string &getDeviceTypeName() const
522  {
523  return deviceTypeName_;
524  }
525 
526  /// Returns the instance default parameter name
527  ///
528  /// @return const reference to the instance default parameter name
529  ///
530  const std::string &getInstanceDefaultParameterName() const
531  {
533  }
534 
535  ///
536  /// Returns the number of nodes of this device
537  ///
538  /// @return number of nodes of this device
539  ///
540  int getNumNodes() const
541  {
542  return numNodes_;
543  }
544 
545  ///
546  /// Returns the number of optional nodes of this device
547  ///
548  /// @return number of optional nodes of this device
549  ///
551  {
552  return numOptionalNodes_;
553  }
554 
555  ///
556  /// Returns the number of fill nodes of this device
557  ///
558  /// @return number of fill nodes of this device
559  ///
560  int getNumFillNodes() const
561  {
562  return numFillNodes_;
563  }
564 
565  /// Returns true of the model must be specified when defining an instance of this device
566  ///
567  /// @return true if the model must be specified
568  ///
569  bool getModelRequired() const
570  {
571  return modelRequired_;
572  }
573 
574  /// Returns true of the model is a linear device
575  ///
576  /// @return true if the model is a linear deive
577  ///
578  bool getLinearDevice() const
579  {
580  return linearDevice_;
581  }
582 
583  /// Returns true of the model is a PDE device
584  ///
585  /// @return true if the model is a PDE device
586  ///
587  bool getPDEDevice() const
588  {
589  return pdeDevice_;
590  }
591 
592  /// Returns the default primary parameter of this device or the empty string if there is no primary parameter
593  ///
594  /// @return primary parameter for this device.
595  ///
596  const std::string &getPrimaryParameter() const
597  {
598  return primaryParameter_;
599  }
600 
601  /// Returns a vector of strings that name all the model types defined of this model
602  ///
603  /// @return const reference to the vector of string names of defined model types
604  ///
605  const std::vector<std::string> &getModelTypeNames() const
606  {
607  return modelTypeNames_;
608  }
609 
610  //-----------------------------------------------------------------------------
611  // Function : findConfiguration
612  // Purpose :
613  // Special Notes :
614  // Scope : public
615  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
616  // Creation Date : Wed Feb 5 10:54:24 2014
617  //-----------------------------------------------------------------------------
618  ///
619  /// Creates the specified device
620  ///
621  /// @param model_type model type of the device to create
622  /// @param factory_block parameters provided to the factory function
623  ///
624  /// @return
625  ///
626  Device *createDevice(const FactoryBlock &factory_block) const;
627 
628  //-----------------------------------------------------------------------------
629  // Function : factory
630  // Purpose :
631  // Special Notes :
632  // Scope : protected
633  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
634  // Creation Date : Mon Jan 27 15:06:50 2014
635  //-----------------------------------------------------------------------------
636  ///
637  /// Overriding function creates an instance this device
638  ///
639  /// Ownership of this object is passed to the caller which is responsible to destory the created object.
640  ///
641  /// @param factory_block reference to the parameter block
642  ///
643  /// @return pointer to the newly created device.
644  ///
645  virtual Device *factory(const FactoryBlock &factory_block) const = 0;
646 
647  //-----------------------------------------------------------------------------
648  // Function : instancetype
649  // Purpose :
650  // Special Notes :
651  // Scope : protected
652  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
653  // Creation Date : Mon Jan 27 15:06:50 2014
654  //-----------------------------------------------------------------------------
655  ///
656  /// Returns the instance type identifier
657  ///
658  /// @return the instance type identifier
659  ///
660  virtual InstanceTypeId instanceType() const = 0;
661 
662  //-----------------------------------------------------------------------------
663  // Function : modelType
664  // Purpose :
665  // Special Notes :
666  // Scope : protected
667  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
668  // Creation Date : Mon Jan 27 15:06:50 2014
669  //-----------------------------------------------------------------------------
670  ///
671  /// Returns the model type identifier
672  ///
673  /// @return the model type identifier
674  ///
675  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
676  /// @date Wed Feb 5 10:08:52 2014
677  ///
678  virtual ModelTypeId modelType() const = 0;
679 
680  //-----------------------------------------------------------------------------
681  // Function : modelGroup
682  // Purpose :
683  // Special Notes :
684  // Scope : protected
685  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
686  // Creation Date : Mon Jan 27 15:06:50 2014
687  //-----------------------------------------------------------------------------
688  ///
689  /// Returns the model group identifier
690  ///
691  /// @return the model group identifier
692  ///
693  virtual ModelTypeId modelGroup() const = 0;
694 
695  protected:
696  //-----------------------------------------------------------------------------
697  // Function : addDevice
698  // Purpose :
699  // Special Notes :
700  // Scope : protected
701  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
702  // Creation Date : Mon Jan 27 15:06:50 2014
703  //-----------------------------------------------------------------------------
704  ///
705  /// Adds the device to the configuration
706  ///
707  /// @invariant only one device can designate itself as the group lead
708  /// @invariant device and level must be unique
709  ///
710  /// @param device_name const character pointer to the device name
711  /// @param device_level device level
712  /// @param model_type_id model type identifier of the device
713  ///
714  void addDevice(const char *model_name, const int model_level, ModelTypeId model_type_id, ModelTypeId model_group_id, int model_type_nodes, int model_group_nodes);
715 
716  //-----------------------------------------------------------------------------
717  // Function : addModel
718  // Purpose :
719  // Special Notes :
720  // Scope : protected
721  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
722  // Creation Date : Mon Jan 27 15:06:50 2014
723  //-----------------------------------------------------------------------------
724  ///
725  /// Adds a model name for the device to the configuration
726  ///
727  /// @invariant only one device can designate itself as the group lead
728  /// @invariant model names must be unique within a device configuration
729  ///
730  /// @param model_name const character pointer to the model name
731  /// @param level model level of this model of the device
732  /// @param model_type_id model type identifier
733  /// @param model_group_id mode group identifier
734  ///
735  void addModel(const char *model_name, const int level, ModelTypeId model_type_id, ModelTypeId model_group_id);
736 
737  private:
738  ParametricData<void> & instanceParameters_; ///< Reference to the Instance specific parameter map
739  ParametricData<void> & modelParameters_; ///< Reference to the Model specific parameter map
740  const std::string name_; ///< Name of the devive
741  const std::string deviceTypeName_; ///< Type name of the device
742  const std::string instanceDefaultParameterName_; ///< Default parameter name for the device instance
743  int numNodes_; ///< Number of nodes of this device
744  int numOptionalNodes_; ///< Number of optional nodes of this device
745  int numFillNodes_; ///< Number of fill nodes of this device
746  bool modelRequired_; ///< True if model is required
747  bool linearDevice_; ///< True if model is a linear device
748  bool pdeDevice_; ///< True if model is a PDE device
749  std::string primaryParameter_; ///< Primary parameter name or the empty string if none
750  std::vector<std::string> modelTypeNames_; ///< Vector of defined model type of this device's model
751 };
752 
753 template<class T, class G>
755 {
756  typedef G GroupTraits_;
757 };
758 
759 template<class T>
761 {
762  typedef T GroupTraits_;
763 };
764 
765 //-----------------------------------------------------------------------------
766 // Class : Config
767 // Purpose :
768 // Special Notes :
769 // Scope : protected
770 // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
771 // Creation Date : Mon Jan 27 15:06:50 2014
772 //-----------------------------------------------------------------------------
773 ///
774 /// Config template derives from the Configuration class and provides the instance and model parameter decriptions.
775 ///
776 template <class T>
777 class Config : public Configuration
778 {
779  public:
780  typedef T ModelTraits;
782 
783  /// Adds the device to the Xyce device configuration
784  ///
785  /// @return reference to newly created configuration
786  ///
787  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
788  /// @date Thu Feb 6 07:15:11 2014
789  ///
791  {
792  return *(new Config<T>());
793  }
794 
795  private:
796  /// Creates the configuration object, populating the instance and model parameter definitions from the Traits
797  ///
798  /// The registerDevice() and registerModelType() functions are used by the device registration function to name the
799  /// device and device levels.
800  ///
801  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
802  /// @date Mon Jan 27 15:28:59 2014
803  ///
805  : Configuration(instanceParameters__, modelParameters__, ModelTraits::name(), ModelTraits::deviceTypeName(), ModelTraits::instanceDefaultParameter(),
806  ModelTraits::numNodes(), ModelTraits::numOptionalNodes(), ModelTraits::numFillNodes(), ModelTraits::modelRequired(),
807  ModelTraits::isLinearDevice(), ModelTraits::isPDEDevice(), ModelTraits::primaryParameter()),
810  {
811  ModelTraits::loadInstanceParameters(instanceParameters__); /// loadInstanceParameters() is called populate the instance parameter desciptions
812  ModelTraits::loadModelParameters(modelParameters__); /// loadModelParameters() is called to populate the model parameter desciptions
813  }
814 
815  //-----------------------------------------------------------------------------
816  // Function : ~Config
817  // Purpose :
818  // Special Notes :
819  // Scope : public
820  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
821  // Creation Date : Fri Mar 14 13:19:39 2014
822  //-----------------------------------------------------------------------------
823  ///
824  /// Destroys the Config
825  ///
826  virtual ~Config()
827  {}
828 
829  Config(const Config<T> &); ///< No copying
830  Config &operator=(const Config<T> &); ///< No assignment
831 
832  public:
833  //-----------------------------------------------------------------------------
834  // Function : registerDevice
835  // Purpose :
836  // Special Notes :
837  // Scope : public
838  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
839  // Creation Date : Mon Jan 27 15:31:43 2014
840  //-----------------------------------------------------------------------------
841  ///
842  /// Adds the device into the device registry giving it the specified device name and level
843  ///
844  /// Registering a device maps the model type to the device name level key.
845  ///
846  /// @param device_name const character pointer name of the device
847  /// @param level level of the device
848  ///
849  Config<T> &registerDevice(const char *device_name, const int level)
850  {
851  addDevice(device_name, level, ModelTraits::modelType(), ModelTraits::modelGroup(), ModelTraits::numNodes(), ModelGroupTraits::numNodes());
852 
853  return *this;
854  }
855 
856  //-----------------------------------------------------------------------------
857  // Function : registerModelType
858  // Purpose :
859  // Special Notes :
860  // Scope : public
861  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
862  // Creation Date : Mon Jan 27 15:31:43 2014
863  //-----------------------------------------------------------------------------
864  ///
865  /// Adds a model type name and level to the device model type list
866  ///
867  /// @param model_name const character pointer model name
868  /// @param level model level of the model
869  ///
870  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
871  /// @date Mon Jan 27 15:32:50 2014
872  ///
873  Config<T> &registerModelType(const char *model_name, const int level)
874  {
875  addModel(model_name, level, ModelTraits::modelType(), ModelTraits::modelGroup());
876 
877  return *this;
878  }
879 
880  //-----------------------------------------------------------------------------
881  // Function : instanceType
882  // Purpose :
883  // Special Notes :
884  // Scope : public
885  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
886  // Creation Date : Mon Jan 27 15:31:43 2014
887  //-----------------------------------------------------------------------------
888  ///
889  /// Returns the instance type identifier
890  ///
891  /// @return the instance type identifier
892  ///
893  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
894  /// @date Wed Feb 5 10:08:52 2014
895  ///
896  virtual InstanceTypeId instanceType() const /* override */
897  {
898  return ModelTraits::instanceType();
899  }
900 
901  //-----------------------------------------------------------------------------
902  // Function : modelType
903  // Purpose :
904  // Special Notes :
905  // Scope : public
906  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
907  // Creation Date : Mon Jan 27 15:31:43 2014
908  //-----------------------------------------------------------------------------
909  ///
910  /// Returns the model type identifier
911  ///
912  /// @return the model type identifier
913  ///
914  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
915  /// @date Wed Feb 5 10:08:52 2014
916  ///
917  virtual ModelTypeId modelType() const /* override */
918  {
919  return ModelTraits::modelType();
920  }
921 
922  //-----------------------------------------------------------------------------
923  // Function : modelGroup
924  // Purpose :
925  // Special Notes :
926  // Scope : public
927  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
928  // Creation Date : Mon Jan 27 15:31:43 2014
929  //-----------------------------------------------------------------------------
930  ///
931  /// Returns the model group identifier
932  ///
933  /// @return the model group identifier
934  ///
935  virtual ModelTypeId modelGroup() const /* override */
936  {
937  return ModelTraits::modelGroup();
938  }
939 
940  //-----------------------------------------------------------------------------
941  // Function : factory
942  // Purpose :
943  // Special Notes :
944  // Scope : public
945  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
946  // Creation Date : Mon Jan 27 15:31:43 2014
947  //-----------------------------------------------------------------------------
948  ///
949  /// Calls the device creation function
950  ///
951  /// @param factory_block factory parameters
952  ///
953  /// @return pointer to the new device
954  ///
955  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
956  /// @date Mon Jan 27 15:35:19 2014
957  ///
958  Device *factory(const FactoryBlock &factory_block) const /* override */
959  {
960  return ModelTraits::factory(*this, factory_block);
961  }
962 
963  private:
966 };
967 
968 } // namespace Device
969 } // namespace Xyce
970 
971 #endif // Xyce_N_DEV_Configuration_h