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.18.2.3 $
40 //
41 // Revision Date : $Date: 2014/03/14 19:48:40 $
42 //
43 // Current Owner : $Author: dgbaur $
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 const int numNodes(); ///< Number of nodes must be provided in the deriving class
258  static const int numOptionalNodes() {return 0;} ///< Default number of optional nodes
259  static const int numFillNodes() {return 0;} ///< Default number of fill nodes
260  static const 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 const bool isLinearDevice(); ///< Linear device flag must be provided in the deriving class
264  static const 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(const std::string &device_name, const int level);
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  /// Creates the specified device
381  ///
382  /// @param model_type model type of the device to create
383  /// @param factory_block parameters provided to the factory function
384  ///
385  /// @return
386  ///
387  static Device *createDevice(ModelTypeId model_type_id, const FactoryBlock &factory_block);
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 : factory
612  // Purpose :
613  // Special Notes :
614  // Scope : protected
615  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
616  // Creation Date : Mon Jan 27 15:06:50 2014
617  //-----------------------------------------------------------------------------
618  ///
619  /// Overriding function creates an instance this device
620  ///
621  /// Ownership of this object is passed to the caller which is responsible to destory the created object.
622  ///
623  /// @param factory_block reference to the parameter block
624  ///
625  /// @return pointer to the newly created device.
626  ///
627  virtual Device *factory(const FactoryBlock &factory_block) = 0;
628 
629  //-----------------------------------------------------------------------------
630  // Function : instancetype
631  // Purpose :
632  // Special Notes :
633  // Scope : protected
634  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
635  // Creation Date : Mon Jan 27 15:06:50 2014
636  //-----------------------------------------------------------------------------
637  ///
638  /// Returns the instance type identifier
639  ///
640  /// @return the instance type identifier
641  ///
642  virtual InstanceTypeId instanceType() const = 0;
643 
644  //-----------------------------------------------------------------------------
645  // Function : modelType
646  // Purpose :
647  // Special Notes :
648  // Scope : protected
649  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
650  // Creation Date : Mon Jan 27 15:06:50 2014
651  //-----------------------------------------------------------------------------
652  ///
653  /// Returns the model type identifier
654  ///
655  /// @return the model type identifier
656  ///
657  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
658  /// @date Wed Feb 5 10:08:52 2014
659  ///
660  virtual ModelTypeId modelType() const = 0;
661 
662  //-----------------------------------------------------------------------------
663  // Function : modelGroup
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 group identifier
672  ///
673  /// @return the model group identifier
674  ///
675  virtual ModelTypeId modelGroup() const = 0;
676 
677  protected:
678  //-----------------------------------------------------------------------------
679  // Function : addDevice
680  // Purpose :
681  // Special Notes :
682  // Scope : protected
683  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
684  // Creation Date : Mon Jan 27 15:06:50 2014
685  //-----------------------------------------------------------------------------
686  ///
687  /// Adds the device to the configuration
688  ///
689  /// @invariant only one device can designate itself as the group lead
690  /// @invariant device and level must be unique
691  ///
692  /// @param device_name const character pointer to the device name
693  /// @param device_level device level
694  /// @param model_type_id model type identifier of the device
695  ///
696  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);
697 
698  //-----------------------------------------------------------------------------
699  // Function : addModel
700  // Purpose :
701  // Special Notes :
702  // Scope : protected
703  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
704  // Creation Date : Mon Jan 27 15:06:50 2014
705  //-----------------------------------------------------------------------------
706  ///
707  /// Adds a model name for the device to the configuration
708  ///
709  /// @invariant only one device can designate itself as the group lead
710  /// @invariant model names must be unique within a device configuration
711  ///
712  /// @param model_name const character pointer to the model name
713  /// @param level model level of this model of the device
714  /// @param model_type_id model type identifier
715  /// @param model_group_id mode group identifier
716  ///
717  void addModel(const char *model_name, const int level, ModelTypeId model_type_id, ModelTypeId model_group_id);
718 
719  private:
720  ParametricData<void> & instanceParameters_; ///< Reference to the Instance specific parameter map
721  ParametricData<void> & modelParameters_; ///< Reference to the Model specific parameter map
722  const std::string name_; ///< Name of the devive
723  const std::string deviceTypeName_; ///< Type name of the device
724  const std::string instanceDefaultParameterName_; ///< Default parameter name for the device instance
725  int numNodes_; ///< Number of nodes of this device
726  int numOptionalNodes_; ///< Number of optional nodes of this device
727  int numFillNodes_; ///< Number of fill nodes of this device
728  bool modelRequired_; ///< True if model is required
729  bool linearDevice_; ///< True if model is a linear device
730  bool pdeDevice_; ///< True if model is a PDE device
731  std::string primaryParameter_; ///< Primary parameter name or the empty string if none
732  std::vector<std::string> modelTypeNames_; ///< Vector of defined model type of this device's model
733 };
734 
735 template<class T, class G>
737 {
738  typedef G GroupTraits_;
739 };
740 
741 template<class T>
743 {
744  typedef T GroupTraits_;
745 };
746 
747 //-----------------------------------------------------------------------------
748 // Class : Config
749 // Purpose :
750 // Special Notes :
751 // Scope : protected
752 // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
753 // Creation Date : Mon Jan 27 15:06:50 2014
754 //-----------------------------------------------------------------------------
755 ///
756 /// Config template derives from the Configuration class and provides the instance and model parameter decriptions.
757 ///
758 template <class T>
759 class Config : public Configuration
760 {
761  public:
762  typedef T ModelTraits;
764 
765  /// Adds the device to the Xyce device configuration
766  ///
767  /// @return reference to newly created configuration
768  ///
769  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
770  /// @date Thu Feb 6 07:15:11 2014
771  ///
773  {
774  return *(new Config<T>());
775  }
776 
777  private:
778  /// Creates the configuration object, populating the instance and model parameter definitions from the Traits
779  ///
780  /// The registerDevice() and registerModelType() functions are used by the device registration function to name the
781  /// device and device levels.
782  ///
783  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
784  /// @date Mon Jan 27 15:28:59 2014
785  ///
787  : Configuration(instanceParameters__, modelParameters__, ModelTraits::name(), ModelTraits::deviceTypeName(), ModelTraits::instanceDefaultParameter(),
788  ModelTraits::numNodes(), ModelTraits::numOptionalNodes(), ModelTraits::numFillNodes(), ModelTraits::modelRequired(),
789  ModelTraits::isLinearDevice(), ModelTraits::isPDEDevice(), ModelTraits::primaryParameter()),
792  {
793  ModelTraits::loadInstanceParameters(instanceParameters__); /// loadInstanceParameters() is called populate the instance parameter desciptions
794  ModelTraits::loadModelParameters(modelParameters__); /// loadModelParameters() is called to populate the model parameter desciptions
795  }
796 
797  //-----------------------------------------------------------------------------
798  // Function : ~Config
799  // Purpose :
800  // Special Notes :
801  // Scope : public
802  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
803  // Creation Date : Fri Mar 14 13:19:39 2014
804  //-----------------------------------------------------------------------------
805  ///
806  /// Destroys the Config
807  ///
808  virtual ~Config()
809  {}
810 
811  Config(const Config<T> &); ///< No copying
812  Config &operator=(const Config<T> &); ///< No assignment
813 
814  public:
815  //-----------------------------------------------------------------------------
816  // Function : registerDevice
817  // Purpose :
818  // Special Notes :
819  // Scope : public
820  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
821  // Creation Date : Mon Jan 27 15:31:43 2014
822  //-----------------------------------------------------------------------------
823  ///
824  /// Adds the device into the device registry giving it the specified device name and level
825  ///
826  /// Registering a device maps the model type to the device name level key.
827  ///
828  /// @param device_name const character pointer name of the device
829  /// @param level level of the device
830  ///
831  Config<T> &registerDevice(const char *device_name, const int level)
832  {
833  addDevice(device_name, level, ModelTraits::modelType(), ModelTraits::modelGroup(), ModelTraits::numNodes(), ModelGroupTraits::numNodes());
834 
835  return *this;
836  }
837 
838  //-----------------------------------------------------------------------------
839  // Function : registerModelType
840  // Purpose :
841  // Special Notes :
842  // Scope : public
843  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
844  // Creation Date : Mon Jan 27 15:31:43 2014
845  //-----------------------------------------------------------------------------
846  ///
847  /// Adds a model type name and level to the device model type list
848  ///
849  /// @param model_name const character pointer model name
850  /// @param level model level of the model
851  ///
852  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
853  /// @date Mon Jan 27 15:32:50 2014
854  ///
855  Config<T> &registerModelType(const char *model_name, const int level)
856  {
857  addModel(model_name, level, ModelTraits::modelType(), ModelTraits::modelGroup());
858 
859  return *this;
860  }
861 
862  //-----------------------------------------------------------------------------
863  // Function : instanceType
864  // Purpose :
865  // Special Notes :
866  // Scope : public
867  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
868  // Creation Date : Mon Jan 27 15:31:43 2014
869  //-----------------------------------------------------------------------------
870  ///
871  /// Returns the instance type identifier
872  ///
873  /// @return the instance type identifier
874  ///
875  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
876  /// @date Wed Feb 5 10:08:52 2014
877  ///
878  virtual InstanceTypeId instanceType() const /* override */
879  {
880  return ModelTraits::instanceType();
881  }
882 
883  //-----------------------------------------------------------------------------
884  // Function : modelType
885  // Purpose :
886  // Special Notes :
887  // Scope : public
888  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
889  // Creation Date : Mon Jan 27 15:31:43 2014
890  //-----------------------------------------------------------------------------
891  ///
892  /// Returns the model type identifier
893  ///
894  /// @return the model type identifier
895  ///
896  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
897  /// @date Wed Feb 5 10:08:52 2014
898  ///
899  virtual ModelTypeId modelType() const /* override */
900  {
901  return ModelTraits::modelType();
902  }
903 
904  //-----------------------------------------------------------------------------
905  // Function : modelGroup
906  // Purpose :
907  // Special Notes :
908  // Scope : public
909  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
910  // Creation Date : Mon Jan 27 15:31:43 2014
911  //-----------------------------------------------------------------------------
912  ///
913  /// Returns the model group identifier
914  ///
915  /// @return the model group identifier
916  ///
917  virtual ModelTypeId modelGroup() const /* override */
918  {
919  return ModelTraits::modelGroup();
920  }
921 
922  //-----------------------------------------------------------------------------
923  // Function : factory
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  /// Calls the device creation function
932  ///
933  /// @param factory_block factory parameters
934  ///
935  /// @return pointer to the new device
936  ///
937  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
938  /// @date Mon Jan 27 15:35:19 2014
939  ///
940  Device *factory(const FactoryBlock &factory_block) /* override */
941  {
942  return ModelTraits::factory(*this, factory_block);
943  }
944 
945  private:
948 };
949 
950 } // namespace Device
951 } // namespace Xyce
952 
953 #endif // Xyce_N_DEV_Configuration_h