Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_DEV_Pars.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_Pars.h,v $
27 //
28 // Purpose :
29 //
30 // Special Notes :
31 //
32 // Creator : Netlist device and model parameter management
33 //
34 // Creation Date : 2013/04/18 18:01:27
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.21.2.4 $
40 //
41 // Revision Date : $Date: 2014/03/10 16:15:20 $
42 //
43 // Current Owner : $Author: dgbaur $
44 //-------------------------------------------------------------------------
45 
46 #ifndef Xyce_N_DEV_Pars_h
47 #define Xyce_N_DEV_Pars_h
48 
49 #include <algorithm>
50 #include <map>
51 #include <set>
52 #include <sstream>
53 #include <string>
54 #include <vector>
55 
56 #include <N_DEV_fwd.h>
57 #include <N_DEV_Units.h>
58 
59 /**
60  * ParameterType::ExprAccess is enumeration of parameter usage types and masks
61  */
62 namespace ParameterType {
64  {
65  NO_DEP = 0x0, ///< Parameter can only be set to a constant from netlist
66  TIME_DEP = 0x1, ///< Parameter may be specified as time dependent expression from netlist
67  SOLN_DEP = 0x2, ///< Parameter may be specified as a solution dependent expression from netlist
68  LOG_T_DEP = 0x8, ///< Parameter uses temperature interpolation based on log of value
69  MIN_RES = 0x10, ///< Parameter is subject to being set to minimum lead resistance
70  MIN_CAP = 0x20, ///< Parameter is subject to being set to minimum junction capacitance
71  NO_DOC = 0x40 ///< Parameter is not to be documented
72  };
73 };
74 
75 using namespace ParameterType;
76 
77 
78 namespace Xyce {
79 namespace Device {
80 
81 /**
82  * @addtogroup xyce_device_parameters_detail
83  *
84  * @brief
85  *
86  * Device models, device instances and composite parameters are collectively called an
87  * <b>entity</b>, which are all derived from the ParameterBase tag class, and manage the mapping
88  * from a parameter's string name to a member variable in each created entity object. The mapping
89  * is refered to as parameter binding and the object's bound member variable is refered to as the
90  * parameter member variable. The object may have an additional member variable for each binding
91  * that indicates if the value was specified in the netlist device and is known as the given member
92  * variable.
93  *
94  * Each class of entity has a ParametricData<T> class, where T is the entity class, and a singleton
95  * object of that class. This singleton manages the parameter binding. A parameter descriptor,
96  * Descriptor, has the parameter member variable pointer for entity object of type T that sets and
97  * retrieves the current value of an entity's member variable using the parameters string name.
98  *
99  * The Descriptor maintains other information about the parameter. It has a serial number for each
100  * parameter and a boolean member variable pointer that determines if the parameter has been given
101  * in the netlist. The given value map, GivenValueMap, is a mapping from entity object pointer and
102  * serial number to a boolean given member varaible indicating if the parameter was provided by the
103  * netlist.
104  *
105  * Any entity may also wish to restore a parameter member variable value to the value originally set
106  * during initialization. The Descriptor maintains an index into an original value map to store and
107  * retrieve the parameters original value. The original value map, OriginalValueMap, is a mapping
108  * from entity object pointer and original value index to the parameter's origin value. If the
109  * original value index is -1, then no original value information is maintained.
110  *
111  * A parameter may also be vectorized, allowing it to maintain a vector values. The Descriptor
112  * maintains that vector length.
113  *
114  * A parameter has specific usages as described by the ParameterType::ExprAccess enumeration.
115  *
116  * A parameter may also serves as an aggregation of parametric values which is stored as a composite
117  * parameter, CompositeParam, entity.
118  *
119  * And a parameter has units, a documentation category and a documentation description.
120  *
121  * @todo Replace the s_originalValueMap and s_givenValueMap with a non-static implementation.
122  *
123  * Entity - DeviceModel, DeviceInstance or CompositeParam
124  *
125  * Given - flag and possibly and entity member variable that indicates if a parameter was given in
126  * the netlist.
127  *
128  * OriginalValue - parameters value after initialization
129  *
130  */
131 
132 typedef std::map<std::string, CompositeParam *> CompositeMap;
133 typedef std::map<int, double> OriginalValueMap;
134 typedef std::set<int> GivenValueSet;
135 
136 class Descriptor;
137 
138 typedef std::map<std::string, Descriptor *, LessNoCase> ParameterMap;
139 
140 /**
141  * Base class for all parameters
142  */
144 {
145 public:
147  : originalValueMap_(),
148  givenValueSet_()
149  {}
150 
151 private:
152  ParameterBase(const ParameterBase &);
153  ParameterBase &operator=(const ParameterBase &);
154 
155 public:
156  double getOriginalValue(int serial_number)
157  {
158  return originalValueMap_[serial_number];
159  }
160 
161  void setOriginalValue(int serial_number, double value)
162  {
163  originalValueMap_[serial_number] = value;
164  }
165 
166  bool wasValueGiven(int serial_number) const
167  {
168  return givenValueSet_.find(serial_number) != givenValueSet_.end();
169  }
170 
171  void setValueGiven(int serial_number, bool value)
172  {
173  if (value)
174  givenValueSet_.insert(serial_number);
175  else
176  givenValueSet_.erase(serial_number);
177  }
178 
179 private:
180  OriginalValueMap originalValueMap_; ///< Map from device entity and original value index to original value
181  GivenValueSet givenValueSet_; ///< Map from device entity and serial number to value given flag
182 };
183 
184 template<class C>
186 
187 template<class T>
188 class Entry;
189 
190 template <class T>
191 inline std::ostream &printEntry(std::ostream &os, const Entry<T> &entry);
192 
193 template <class T>
194 inline std::ostream &printEntry(std::ostream &os, const Entry<std::vector<T> > &entry);
195 
196 template <>
197 inline std::ostream &printEntry(std::ostream &os, const Entry<std::string> &entry);
198 
199 template <>
200 inline std::ostream &printEntry(std::ostream &os, const Entry<bool> &entry);
201 
202 template <>
203 inline std::ostream &printEntry(std::ostream &os, const Entry<CompositeMap> &entry);
204 
205 void typeMismatch(const std::type_info &from_type, const std::type_info &to_type);
206 void nonexistentParameter(const std::string &name, const std::type_info &entity_type);
207 
208 /**
209  * Class Entry<void> defines the parameter binding value entry interface.
210  *
211  * This defines the interface to check the data type of an Entry<T> object and to print the value.
212  * Type specific Entry classes inherit from this class. The entry_cast<T>() function is used to
213  * cast an object of this type to the derived Entry<T> class safely.
214  *
215  */
216 template<>
217 class Entry<void>
218 {
219 protected:
220  /**
221  * Constructs the Entry base class
222  *
223  * @note The construct is protected so it may only be constructed by Entry<T> classes.
224  *
225  * @author David G. Baur Raytheon Sandia National Laboratories 1355
226  * @date Fri Aug 9 08:32:36 2013
227  */
229  {}
230 
231 public:
232  /**
233  * Destroys Entry
234  *
235  * @author David G. Baur Raytheon Sandia National Laboratories 1355
236  * @date Fri Aug 9 08:34:16 2013
237  */
238  virtual ~Entry()
239  {}
240 
241 private:
242  Entry(const Entry &);
243  Entry &operator=(const Entry &);
244 
245 public:
246  /**
247  * Returns the type_info of the data type being stored in the entry.
248  *
249  * @return const reference to the type_info of the data type being stored in the entry.
250  */
251  virtual const std::type_info &type() const = 0;
252 
253  /**
254  * Prints the value of the entry to the output stream
255  *
256  * @param os output stream to write to
257  *
258  * @return reference to the output stream
259  *
260  * @author David G. Baur Raytheon Sandia National Laboratories 1355
261  * @date Wed Aug 7 11:28:02 2013
262  */
263  std::ostream &print(std::ostream &os) const
264  {
265  doPrint(os);
266 
267  return os;
268  }
269 
270 private:
271  /**
272  * Prints the value of the entry to the output stream
273  *
274  * @param os output stream to write to
275  *
276  * @return reference to the output stream
277  *
278  * @author David G. Baur Raytheon Sandia National Laboratories 1355
279  * @date Wed Aug 7 11:29:29 2013
280  */
281  virtual std::ostream &doPrint(std::ostream &os) const = 0;
282 };
283 
284 /**
285  * Class Entry<T> defines the parameter member variable access for parameter member variable of type T
286  *
287  * The pointer to the parameter member variable and the default value to set are contained in this
288  * class.
289  */
290 template<class T>
291 class Entry : public Entry<void>
292 {
293 public:
294  /**
295  * Constructs an Entry.
296  *
297  * Initializes the parameter member variable pointer of type T. Note the member variable
298  * pointer are actually offsets into an object where the data for the member exists. So, by
299  * storing this pointer the value of any object of type can be retrieved.
300  *
301  * The default value ot type T is also contained here.
302  *
303  * @param member_value_ptr parameter member variable pointer
304  * @param default_value Default value of parameter
305  */
306  Entry(T ParameterBase::*member_value_ptr, const T &default_value = T())
307  : memberValuePtr_(member_value_ptr),
308  defaultValue_(default_value)
309  {}
310 
311  /**
312  * Destroys the entry
313  *
314  * @author David G. Baur Raytheon Sandia National Laboratories 1355
315  * @date Wed Aug 7 11:30:29 2013
316  */
317  virtual ~Entry()
318  {}
319 
320 private:
321  Entry(const Entry &); ///< No copying
322  Entry &operator=(const Entry &); ///< No assignment
323 
324 public:
325  /**
326  * Returns type_info of this entry.
327  *
328  * @return const reference to type_info of this entry
329  */
330  virtual const std::type_info &type() const
331  {
332  return typeid(T);
333  }
334 
335 private:
336  /**
337  * Prints the value of the entry to the output stream
338  *
339  * @param os output stream to write to
340  *
341  * @return reference to the output stream
342  *
343  * @author David G. Baur Raytheon Sandia National Laboratories 1355
344  * @date Wed Aug 7 11:29:29 2013
345  */
346  virtual std::ostream &doPrint(std::ostream &os) const
347  {
348  return printEntry(os, *this);
349  }
350 
351 public:
352  /**
353  * Return the member pointer to the data member variable that holds the value associated with
354  * this parameter
355  *
356  * @return member pointer to the data member variable
357  *
358  * @author David G. Baur Raytheon Sandia National Laboratories 1355
359  * @date Wed Aug 7 11:31:21 2013
360  */
361  T ParameterBase::*getMemberPtr() const
362  {
363  return memberValuePtr_;
364  }
365 
366  /**
367  * Return the value of the entity's parameter
368  *
369  * @param entity device class or device instance
370  *
371  * @return const reference to the value of the entity's parameter
372  *
373  * @author David G. Baur Raytheon Sandia National Laboratories 1355
374  * @date Wed Aug 7 11:32:58 2013
375  */
376  const T &getValue(const ParameterBase &entity) const
377  {
378  return entity.*memberValuePtr_;
379  }
380 
381  /**
382  * Return the value of the entity's parameter
383  *
384  * @param entity device class or device instance
385  *
386  * @return reference to the value of the entity's parameter
387  *
388  * @author David G. Baur Raytheon Sandia National Laboratories 1355
389  * @date Wed Aug 7 11:32:58 2013
390  */
391  T &getValue(ParameterBase &entity) const
392  {
393  return entity.*memberValuePtr_;
394  }
395 
396  /**
397  * Sets the value of the entity's parameter
398  *
399  * @param entity device class or device instance
400  * @param value value to set the entity's parameter to
401  *
402  * @author David G. Baur Raytheon Sandia National Laboratories 1355
403  * @date Wed Aug 7 11:32:58 2013
404  */
405  void setValue(ParameterBase &entity, const T &value) const
406  {
407  entity.*memberValuePtr_ = value;
408  }
409 
410  /**
411  * Return the default value of the parameter
412  *
413  * All parameters provide a default value when created. The parameter is set to this value and
414  * the given flag is cleared on construction. If the value is provided by the net list, the
415  * parameter's value is set accordingly and given flag is set to true.
416  *
417  * @return const reference to the parameter's default value
418  *
419  * @author David G. Baur Raytheon Sandia National Laboratories 1355
420  * @date Wed Aug 7 11:35:18 2013
421  */
422  const T &getDefaultValue() const
423  {
424  return defaultValue_;
425  }
426 
427  /**
428  * Sets the parameter's default value
429  *
430  * All parameters provide a default value when created. The parameter is set to this value and
431  * the given flag is cleared on construction. If the value is provided by the net list, the
432  * parameter's value is set accordingly and given flag is set to true.
433  *
434  * @param value default value of the parameter
435  *
436  * @author David G. Baur Raytheon Sandia National Laboratories 1355
437  * @date Wed Aug 7 11:37:50 2013
438  */
439  void setDefaultValue(const T &value)
440  {
441  defaultValue_ = value;
442  }
443 
444 private:
445  T defaultValue_; ///< Default value of parameter
446  T ParameterBase::* memberValuePtr_; ///< Member pointer containing value
447 };
448 
449 /**
450  * Casts the entry to type T
451  *
452  * If the entry if not of the specified type, typeMismatch() is called to emit a fatal error.
453  *
454  * @tparam T type to cast to
455  * @param entry entry to cast
456  *
457  * @return const reference to Entry<T>
458  *
459  * @author David G. Baur Raytheon Sandia National Laboratories 1355
460  * @date Thu Jul 25 13:21:09 2013
461  */
462 template<class T>
463 const Entry<T> &entry_cast(const Entry<void> &entry)
464 {
465  if (entry.type() != typeid(T))
466  typeMismatch(entry.type(), typeid(T));
467 
468  return static_cast<const Entry<T> &>(entry);
469 }
470 
471 /**
472  * Casts the entry to type T
473  *
474  * If the entry if not of the specified type, typeMismatch() is called to emit a fatal error.
475  *
476  * @tparam T type to cast to
477  * @param entry entry to cast
478  *
479  * @return reference to Entry<T>
480  *
481  * @author David G. Baur Raytheon Sandia National Laboratories 1355
482  * @date Thu Jul 25 13:21:09 2013
483  */
484 template<class T>
486 {
487  if (entry.type() != typeid(T))
488  typeMismatch(entry.type(), typeid(T));
489 
490  return static_cast<Entry<T> &>(entry);
491 }
492 
493 /**
494  * Class Descriptor describes the parameters stored in the ParametricData parameter map.
495  *
496  * The descriptor contains the Entry for the parameter member variable. Each parameter is assigned
497  * a serialNumber_ when it is created and is used by manage the given value map. The parameter may
498  * have a given member variable as well. The parameter can be marked to store its original
499  * initialized value and the serialNumber_ is used to store this value in the s_originalValueMap.
500  *
501  * If the parameter is vectorized, the index to this parameter is in vec_.
502  *
503  * The expressionAccess_ is used to indicate the parameter's usage.
504  *
505  * The Descriptor also contains the units, catagory and description for documentation generation.
506  * serial number, its original value index if the initiazes value needs to be restored, its usage
507  * (ExprAccess), units,
508  */
510 {
511 public:
512  /**
513  * Constructs Descriptor
514  *
515  * @param entry the parameter member variable pointer, type and default value
516  *
517  * @author David G. Baur Raytheon Sandia National Laboratories 1355
518  * @date Wed Aug 7 11:38:43 2013
519  */
520  Descriptor(Entry<void> *const entry)
521  : serialNumber_(0),
522  originalValueFlag_(false),
523  vec_(0),
524  expressionAccess_(ParameterType::NO_DEP),
525  entry_(entry),
526  unit_(U_NONE),
527  category_(CAT_NONE),
528  description_(""),
529  compositeParametricData_(0),
530  given_(static_cast<bool ParameterBase::*>(0))
531  {}
532 
533  /**
534  * Destroy Descriptor
535  *
536  * @author David G. Baur Raytheon Sandia National Laboratories 1355
537  * @date Wed Aug 7 15:42:55 2013
538  */
539  virtual ~Descriptor()
540  {
541  delete entry_;
542  }
543 
544 private:
545  Descriptor(const Descriptor &descriptor);
546  Descriptor &operator=(const Descriptor &descriptor);
547 
548 public:
549  /**
550  * Tests entry data type
551  *
552  * @return true if entry is of type T
553  *
554  * @date Wed Aug 7 10:31:04 2013
555  * @author David G. Baur Raytheon Sandia National Laboratories 1355
556  */
557  template <class T>
558  bool isType() const
559  {
560  if (entry_)
561  return entry_->type() == typeid(T);
562 
563  return typeid(T) == typeid(int);
564  }
565 
566  bool isComposite() const
567  {
568  return compositeParametricData_ != 0;
569  }
570 
571  /**
572  * Sets a boolean marking an original value having been stored.
573  *
574  * @param original_value_flag
575  *
576  * @author David G. Baur Raytheon Sandia National Laboratories 1355
577  * @date Fri Aug 9 14:37:03 2013
578  */
579  Descriptor &setOriginalValueStored(bool original_value_flag)
580  {
581  originalValueFlag_ = original_value_flag;
582  return *this;
583  }
584 
585  /**
586  * Returns whether an original value has been stored
587  *
588  * @return True if original value has been stored. False otherwise.
589  *
590  * @author David G. Baur Raytheon Sandia National Laboratories 1355
591  * @date Fri Aug 9 14:19:59 2013
592  */
593  bool hasOriginalValueStored() const
594  {
595  return originalValueFlag_;
596  }
597 
598  /**
599  * Sets the expression access which describe the usage of the parameter
600  *
601  * @param expression_access usage of the paraemeter
602  *
603  * @author David G. Baur Raytheon Sandia National Laboratories 1355
604  * @date Fri Aug 9 14:41:56 2013
605  */
606  Descriptor &setExpressionAccess(ExprAccess expression_access)
607  {
608  expressionAccess_ = expression_access;
609  return *this;
610  }
611 
612  /**
613  * Gets the expression access which describes the usage of the paramter
614  *
615  * @return usage of the parameter
616  *
617  * @author David G. Baur Raytheon Sandia National Laboratories 1355
618  * @date Fri Aug 9 14:41:26 2013
619  */
620  ExprAccess getExpressionAccess() const
621  {
622  return expressionAccess_;
623  }
624 
625  /**
626  * Sets the units of the parameter, only used to document the parameter
627  *
628  * @param unit units of the parameter
629  *
630  * @author David G. Baur Raytheon Sandia National Laboratories 1355
631  * @date Fri Aug 9 14:43:32 2013
632  */
633  Descriptor &setUnit(ParameterUnit unit)
634  {
635  unit_ = unit;
636  return *this;
637  }
638 
639  /**
640  * Gets the units of the parameter, only used to document the parameter
641  *
642  * @return units of the parameter
643  *
644  * @author David G. Baur Raytheon Sandia National Laboratories 1355
645  * @date Fri Aug 9 14:44:16 2013
646  */
647  ParameterUnit getUnit() const
648  {
649  return unit_;
650  }
651 
652  /**
653  * Sets the category of the parameter, only used to document the parameter
654  *
655  * @param category category of the parameter
656  *
657  * @author David G. Baur Raytheon Sandia National Laboratories 1355
658  * @date Fri Aug 9 14:45:09 2013
659  */
660  Descriptor &setCategory(ParameterCategory category)
661  {
662  category_ = category;
663  return *this;
664  }
665 
666  /**
667  * Gets the category of the parameter, only used to document the parameter
668  *
669  * @return categort of the parameter
670  *
671  * @author David G. Baur Raytheon Sandia National Laboratories 1355
672  * @date Fri Aug 9 14:45:40 2013
673  */
674  ParameterCategory getCategory() const
675  {
676  return category_;
677  }
678 
679  /**
680  * Sets the description of the parameter, only used to document the parameter
681  *
682  * @param description description of the parameter
683  *
684  * @author David G. Baur Raytheon Sandia National Laboratories 1355
685  * @date Fri Aug 9 14:46:21 2013
686  */
687  Descriptor &setDescription(const std::string &description)
688  {
689  description_ = description;
690  return *this;
691  }
692 
693  /**
694  * Gets the description of the parameter, only used to document the parameter
695  *
696  * @return description of the parameter
697  *
698  * @author David G. Baur Raytheon Sandia National Laboratories 1355
699  * @date Fri Aug 9 14:46:46 2013
700  */
701  const std::string &getDescription() const
702  {
703  return description_;
704  }
705 
706  /**
707  * Sets the composite parametric
708  *
709  * A composite parameter is a named aggregation of parameters
710  *
711  * @param composite_parametric_data composite parameter
712  *
713  * @author David G. Baur Raytheon Sandia National Laboratories 1355
714  * @date Fri Aug 9 14:47:19 2013
715  */
716  Descriptor &setCompositeParametricData(const ParametricData<void> *composite_parametric_data)
717  {
718  compositeParametricData_ = composite_parametric_data;
719  return *this;
720  }
721 
722  /**
723  * Return the composite parameter
724  *
725  * A composite parameter is a named aggregation of parameters
726  *
727  * @return const pointer to the composite parameter
728  *
729  * @note I think the template parameter is really only ever CompositeParam, though sometimes its
730  * currently void.
731  *
732  * @author David G. Baur Raytheon Sandia National Laboratories 1355
733  * @date Fri Aug 9 14:09:01 2013
734  */
735  template <class U>
736  const ParametricData<U> *getCompositeParametricData() const
737  {
738  return static_cast<const ParametricData<U> *>(compositeParametricData_);
739  }
740 
741  /**
742  * sets the vector length of an vectorized parameter
743  *
744  * @param index
745  *
746  * @author David G. Baur Raytheon Sandia National Laboratories 1355
747  * @date Fri Aug 9 14:50:05 2013
748  */
749  Descriptor &setVec(int index)
750  {
751  vec_ = index;
752  return *this;
753  }
754 
755  /**
756  * Gets the vector length of a vectorized parameter
757  *
758  * @return length of the vectorized parameter
759  *
760  * @author David G. Baur Raytheon Sandia National Laboratories 1355
761  * @date Fri Aug 9 14:51:10 2013
762  */
763  int getVec() const
764  {
765  return vec_;
766  }
767 
768  /**
769  * Gets the entry object of the parameter
770  *
771  * @return const reference to the Entry<void>
772  *
773  * @author David G. Baur Raytheon Sandia National Laboratories 1355
774  * @date Fri Aug 9 15:29:16 2013
775  */
776  const Entry<void> &getEntry() const
777  {
778  return *entry_;
779  }
780 
781  /**
782  * Gets the entry object of the parameter
783  *
784  * @return reference to the Entry<void>
785  *
786  * @author David G. Baur Raytheon Sandia National Laboratories 1355
787  * @date Fri Aug 9 15:29:16 2013
788  */
789  Entry<void> &getEntry()
790  {
791  return *entry_;
792  }
793 
794  /**
795  * Sets the serial number used to store and retrieve given boolean from the GivenValueMap
796  *
797  * @param serial_number serial number of the parameter in the GivenValueMap
798  *
799  * @author David G. Baur Raytheon Sandia National Laboratories 1355
800  * @date Fri Aug 9 14:38:18 2013
801  */
802  Descriptor &setSerialNumber(int serial_number)
803  {
804  serialNumber_ = serial_number;
805  return *this;
806  }
807 
808  /**
809  * Gets the serial number used to store and retireve given boolean fromt he GivenValueMap
810  *
811  * @return parameter serial number
812  *
813  * @author David G. Baur Raytheon Sandia National Laboratories 1355
814  * @date Fri Aug 9 14:40:30 2013
815  */
816  int getSerialNumber() const
817  {
818  return serialNumber_;
819  }
820 
821 public:
822  /**
823  * Returns the value of the parameter for the entity
824  *
825  * @param entity device class or device instance
826  *
827  * @return reference to the value of the parameter for the entity
828  *
829  * @date Wed Aug 7 10:36:10 2013
830  * @author David G. Baur Raytheon Sandia National Laboratories 1355
831  */
832  template <class T>
833  const T &value(const ParameterBase &entity) const
834  {
835  const Entry<T> &entry = entry_cast<T>(*entry_);
836 
837  return entry.getValue(entity);
838  }
839 
840  /**
841  * Returns the value of the parameter for the entity
842  *
843  * @param entity device class or device instance
844  *
845  * @return reference to the value of the parameter for the entity
846  *
847  * @date Wed Aug 7 10:36:10 2013
848  * @author David G. Baur Raytheon Sandia National Laboratories 1355
849  */
850  template <class T>
851  T &value(ParameterBase &entity) const
852  {
853  const Entry<T> &entry = entry_cast<T>(*entry_);
854 
855  return entry.getValue(entity);
856  }
857 
858  /**
859  * Returns the parameter member variable pointer of the enrtry
860  *
861  * @return parameter member pointer of type T
862  *
863  * @date Wed Aug 7 10:54:58 2013
864  * @author David G. Baur Raytheon Sandia National Laboratories 1355
865  */
866  template <class T>
867  T ParameterBase::*getMemberPtr() const
868  {
869  const Entry<T> &entry = entry_cast<T>(*entry_);
870 
871  return entry.getMemberPtr();
872  }
873 
874  /**
875  * Tests if parameter has a given data member
876  *
877  * Parameters may provide a boolean member variable that is set true if the netlist provides
878  * the value.
879  *
880  * @return true if the parameter has a boolean member variable to set if it is provided by the netlist
881  *
882  * @author David G. Baur Raytheon Sandia National Laboratories 1355
883  * @date Wed Aug 7 11:03:55 2013
884  */
885  bool hasGivenMember() const
886  {
887  return given_ != static_cast<bool ParameterBase::*>(0);
888  }
889 
890  /**
891  * Sets the boolean member variable to set if the netlist provides the value.
892  *
893  * Parameters may provide a boolean member variable that is set true if the netlist provides
894  * the value.
895  *
896  * @param given boolean member variable to be set
897  *
898  * @date Wed Aug 7 11:02:38 2013
899  * @author David G. Baur Raytheon Sandia National Laboratories 1355
900  */
901  template<class U>
902  Descriptor &setGivenMember(bool U::*given)
903  {
904  given_ = static_cast<bool ParameterBase::*>(given);
905  return *this;
906  }
907 
908  /**
909  * Tests if the parameter has been given by the netlist.
910  *
911  * @return true if the parameter was given by the netline
912  *
913  * @date Wed Aug 7 11:01:42 2013
914  * @author David G. Baur Raytheon Sandia National Laboratories 1355
915  */
916  bool getGiven(ParameterBase &entity) const
917  {
918  if (hasGivenMember())
919  {
920  return entity.*given_;
921  }
922 
923  return false;
924  }
925 
926  /**
927  * Sets the given state of the parameter to value
928  *
929  * The parameter's boolean member variable that is set true if exists and the netlist provides
930  * the value.
931  *
932  * @param entity device class or device instance
933  * @param value true if provided by netlist
934  *
935  * @author David G. Baur Raytheon Sandia National Laboratories 1355
936  * @date Wed Aug 7 11:09:00 2013
937  */
938  void setGiven(ParameterBase &entity, bool value) const
939  {
940  if (hasGivenMember())
941  {
942  entity.*given_ = value;
943  }
944  }
945 
946 private:
947  int serialNumber_; ///< Unique identifier of descriptor
948  bool originalValueFlag_; ///< Flag indicating original value was stored
949  int vec_; ///< If > 0 specifies a vector of params.(eg: if = 3 then IC becomes IC1, IC2, IC3)
950  ExprAccess expressionAccess_; ///< Flags for parameter attributes, such as whether can be input by user, may depend on time, etc.
951 
952  Entry<void> * const entry_; ///< Pointer to entry which contains the value
954  ParameterUnit unit_; ///< Unit designator for documentation
955  ParameterCategory category_; ///< Category designator for documentation
956  std::string description_; ///< Description of parameter for documentation
958 
959  bool ParameterBase::* given_; ///< Pointer to given bool, usually 0
960 };
961 
962 
963 /**
964  * Prints the entry default value to the output stream
965  *
966  * @param os output stream
967  * @param entry entry to print
968  *
969  * @return reference to the output stream
970  *
971  * @author David G. Baur Raytheon Sandia National Laboratories 1355
972  * @date Fri Aug 9 15:32:26 2013
973  */
974 template <class T>
975 inline std::ostream &printEntry(std::ostream &os, const Entry<T> &entry)
976 {
977  os << entry.getDefaultValue();
978 
979  return os;
980 }
981 
982 /**
983  * Prints the entry default values of a vectorized parameter
984  *
985  * @param os output stream
986  * @param entry entry to print
987  *
988  * @return reference to the output stream
989  *
990  * @author David G. Baur Raytheon Sandia National Laboratories 1355
991  * @date Fri Aug 9 15:33:24 2013
992  */
993 template <class T>
994 inline std::ostream &printEntry(std::ostream &os, const Entry<std::vector<T> > &entry)
995 {
996  for (typename std::vector<T>::const_iterator it = entry.getDefaultValue().begin(); it != entry.getDefaultValue().end(); ++it)
997  os << (*it) << std::endl;
998 
999  return os;
1000 }
1001 
1002 /**
1003  * Prints the entry default values of a map parameter
1004  *
1005  * @param os output stream
1006  * @param entry entry to print
1007  *
1008  * @return reference to the output stream
1009  *
1010  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1011  * @date Thu Feb 6 16:37:16 2014
1012  */
1013 template <class T>
1014 inline std::ostream &printEntry(std::ostream &os, const Entry<std::map<std::string, T> > &entry)
1015 {
1016  for (typename std::map<std::string, T>::const_iterator it = entry.getDefaultValue().begin(); it != entry.getDefaultValue().end(); ++it)
1017  os << (*it).first << std::endl;
1018 
1019  return os;
1020 }
1021 
1022 /**
1023  * Prints the entry default string value, within single quotes
1024  *
1025  * @param os output stream
1026  * @param entry entry to print
1027  *
1028  * @return reference to the output stream
1029  *
1030  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1031  * @date Fri Aug 9 15:34:18 2013
1032  */
1033 template <>
1034 inline std::ostream &printEntry(std::ostream &os, const Entry<std::string> &entry)
1035 {
1036  os << "'" << entry.getDefaultValue() << "'";
1037 
1038  return os;
1039 }
1040 
1041 /**
1042  * Prints the entry default boolean value, printed as true or false
1043  *
1044  * @param os output stream
1045  * @param entry entry to print
1046  *
1047  * @return reference to the output stream
1048  *
1049  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1050  * @date Fri Aug 9 15:34:18 2013
1051  */
1052 template <>
1053 inline std::ostream &printEntry(std::ostream &os, const Entry<bool> &entry)
1054 {
1055  os << (entry.getDefaultValue() ? "true" : "false");
1056 
1057  return os;
1058 }
1059 
1060 /**
1061  * Prints the entry composite value as newline terminated list of colon separated name, value pairs
1062  *
1063  * @param os output stream
1064  * @param entry entry to print
1065  *
1066  * @return reference to the output stream
1067  *
1068  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1069  * @date Fri Aug 9 15:34:18 2013
1070  */
1071 template <>
1072 inline std::ostream &printEntry(std::ostream &os, const Entry<CompositeMap> &entry)
1073 {
1074  for (CompositeMap::const_iterator it = entry.getDefaultValue().begin(); it != entry.getDefaultValue().end(); ++it)
1075  os << (*it).first << ": " << (*it).second << std::endl;
1076 
1077  return os;
1078 }
1079 
1080 /**
1081  * Gets the default value of the parameter
1082  *
1083  * @param descriptor descriptor of the parameter
1084  *
1085  * @return const reference to the default value of the entry of the descriptor
1086  *
1087  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1088  * @date Fri Aug 9 15:37:33 2013
1089  */
1090 template <class T>
1091 inline const T &getDefaultValue(const Descriptor &descriptor)
1092 {
1093  const Entry<T> &entry = entry_cast<T>(descriptor.getEntry());
1094 
1095  return entry.getDefaultValue();
1096 }
1097 
1098 /**
1099  * Sets the default value of the parameter
1100  *
1101  * @param descriptor descriptor of the parameter
1102  * @param t default value
1103  *
1104  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1105  * @date Fri Aug 9 15:38:49 2013
1106  */
1107 template <class T>
1108 inline void setDefaultValue(Descriptor &descriptor, const T &t)
1109 {
1110  Entry<T> &entry = entry_cast<T>(descriptor.getEntry());
1111 
1112  entry.setDefaultValue(t);
1113 }
1114 
1115 /**
1116  * Returns the value of the parameter for the entity
1117  *
1118  * @param entity device class or device instance
1119  * @param descriptor descriptor of the parameter
1120  *
1121  * @return const reference to the value of the entry of the descriptor
1122  *
1123  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1124  * @date Fri Aug 9 15:39:40 2013
1125  */
1126 template <class T>
1127 inline const T &value(const ParameterBase &entity, const Descriptor &descriptor)
1128 {
1129  const Entry<T> &entry = entry_cast<T>(descriptor.getEntry());
1130 
1131  return entry.getValue(entity);
1132 }
1133 
1134 /**
1135  * Returns the value of the parameter for the entity
1136  *
1137  * @param entity device class or device instance
1138  * @param descriptor descriptor of the parameter
1139  *
1140  * @return reference to the value of the entry of the descriptor
1141  *
1142  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1143  * @date Fri Aug 9 15:39:40 2013
1144  */
1145 template <class T>
1146 inline T &value(ParameterBase &entity, const Descriptor &descriptor)
1147 {
1148  const Entry<T> &entry = entry_cast<T>(descriptor.getEntry());
1149 
1150  return entry.getValue(entity);
1151 }
1152 
1153 
1154 /**
1155  * Gets the value of the parameter for the entity
1156  *
1157  * @param entity device class or device instance
1158  * @param descriptor descriptor of the parameter
1159  *
1160  * @return const reference to the value of the entry of the descriptor
1161  *
1162  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1163  * @date Fri Aug 9 15:39:40 2013
1164  */
1165 template <class T, class U>
1166 inline const T &getValue(const ParameterBase &entity, const Descriptor &descriptor)
1167 {
1168  const Entry<T> &entry = entry_cast<T>(descriptor.getEntry());
1169 
1170  return entry.getValue(entity);
1171 }
1172 
1173 /**
1174  * Sets the value of the parameter
1175  *
1176  * @param entity device class or device instance
1177  * @param descriptor descriptor of the parameter
1178  * @param value value
1179  *
1180  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1181  * @date Fri Aug 9 15:42:13 2013
1182  */
1183 template <class T, class U>
1184 inline void setValue(ParameterBase &entity, const Descriptor &descriptor, const T &value)
1185 {
1186  const Entry<T> &entry = entry_cast<T>(descriptor.getEntry());
1187 
1188  entry.setValue(entity, value);
1189 }
1190 
1191 /**
1192  * Class ParametricData<void> manages the configuration information and the parameter binding map
1193  *
1194  * Parametric data associated with a device instance, device model or composite parameter
1195  *
1196  * The Parametric data class manages the mapping of parameter string names to descriptors and the
1197  * general configuration information associated with a device model.
1198  *
1199  * To restore original values during perturbation, the originalValueCount_ and serialNumber_ members
1200  * maintain counts of original values to be stored and of parameters declared.
1201  *
1202  * @date Tue Aug 6 13:10:21 2013
1203  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1204  */
1205 template<>
1206 class ParametricData<void>
1207 {
1208 public:
1209  /**
1210  * Constructs a ParametricData object
1211  *
1212  * @date Tue Aug 6 13:10:21 2013
1213  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1214  */
1216  : map_()
1217  {}
1218 
1219  /**
1220  * Destroys a ParametricData object
1221  *
1222  * @date Tue Aug 6 13:13:47 2013
1223  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1224  */
1225  virtual ~ParametricData()
1226  {
1227  for (ParameterMap::iterator it = map_.begin(); it != map_.end(); ++it)
1228  delete (*it).second;
1229  }
1230 
1231 private:
1232  ParametricData(const ParametricData &parametric_data); ///< No copying
1233  ParametricData &operator=(const ParametricData &parametric_data); ///< No assignment
1234 
1235 public:
1236  /**
1237  * Gets the parameter binding map map
1238  *
1239  * @return reference to the parameter binding map
1240  *
1241  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1242  * @date Fri Aug 9 15:50:06 2013
1243  */
1244  ParameterMap &getMap()
1245  {
1246  return map_;
1247  }
1248 
1249  /**
1250  * Returns the parameter binding map
1251  *
1252  * @return const reference to the parameter binding map
1253  *
1254  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1255  * @date Fri Aug 9 15:50:06 2013
1256  */
1257  const ParameterMap &getMap() const
1258  {
1259  return map_;
1260  }
1261 
1262 protected:
1263  /**
1264  * Adds the parameter to the parameter binding map
1265  *
1266  * @param name parameter name
1267  * @param descriptor descriptor created for the parameter
1268  * @param parameter_data_class typeinfo to get the class name for diagnostics
1269  *
1270  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1271  * @date Fri Aug 9 16:23:45 2013
1272  */
1273  void addDescriptor(const std::string &name, Descriptor *descriptor, const std::type_info &parameter_data_class);
1274 
1275 protected:
1276  ParameterMap map_; ///< Mapping from parameter name to descriptor
1277 };
1278 
1279 void checkExprAccess(const std::string &name, ParameterType::ExprAccess &expr_access, const std::type_info &parameter_data_class);
1280 
1281 /**
1282  * Manages parameter binding for class C.
1283  *
1284  */
1285 template<class C>
1286 class ParametricData : public ParametricData<void>
1287 {
1288 public:
1289  /**
1290  * Constructs the parameter data map
1291  *
1292  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1293  * @date Thu Feb 6 16:39:06 2014
1294  */
1296  : ParametricData<void>()
1297  {}
1298 
1299  /**
1300  * Destroys the parameter data map
1301  *
1302  *
1303  *
1304  * @return
1305  *
1306  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1307  * @date Thu Feb 6 16:39:34 2014
1308  */
1309  virtual ~ParametricData()
1310  {}
1311 
1312 private:
1313  ParametricData(const ParametricData &parametric_data); ///< No copying
1314  ParametricData &operator=(const ParametricData &parametric_data); ///< No assignment
1315 
1316 public:
1317  /**
1318  * Adds the parameter description to the parameter map
1319  *
1320  * @tparam T data type of the parameter
1321  * @tparam U class containing the member data storing the parameter's value
1322  * @param parName const pointer to the parameter name
1323  * @param default_value default value
1324  * @param varPtr member pointer to the parameter's value
1325  *
1326  * @return
1327  *
1328  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1329  * @date Thu Feb 6 16:33:48 2014
1330  */
1331  template<class T, class U>
1332  Descriptor &addPar(const char *parName, T default_value, T U::*varPtr)
1333  {
1334  Descriptor *descriptor = new Descriptor(new Entry<T>(static_cast<T ParameterBase::*>(varPtr), default_value));
1335 
1336  addDescriptor(parName, descriptor, typeid(C));
1337 
1338  return *descriptor;
1339  }
1340 
1341  /**
1342  * Adds the parameter description to the parameter map
1343  *
1344  * This is specialization to allow const char * (quoted strings) to create a std::string type parameter.
1345  *
1346  * @tparam U class containing the member data storing the parameter's value
1347  * @param parName const pointer to the parameter name
1348  * @param default_value default value
1349  * @param varPtr member pointer to the parameter's value
1350  *
1351  * @return
1352  *
1353  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1354  * @date Thu Feb 6 16:33:48 2014
1355  */
1356  template<class U>
1357  Descriptor &addPar(const char *parName, const char *default_value, std::string U::*varPtr)
1358  {
1359  Descriptor *descriptor = new Descriptor(new Entry<std::string>(static_cast<std::string ParameterBase::*>(varPtr), default_value));
1360 
1361  addDescriptor(parName, descriptor, typeid(C));
1362 
1363  return *descriptor;
1364  }
1365 
1366 
1367  /**
1368  * Adds the parameter description to the parameter map
1369  *
1370  * TODO: [DGB] This function should be eliminated and the addPar(const char *parName, T default_value, T U::*varPtr) used exclusively
1371  *
1372  * @tparam T data type of the parameter
1373  * @tparam U class containing the member data storing the parameter's value
1374  * @param parName const pointer to the parameter name
1375  * @param def default value
1376  * @param orig true if the original value is no be stored
1377  * @param depend the dependency type of this parameter
1378  * @param varPtr member pointer to the parameter's value
1379  * @param givenPtr member pointer to the parameter's given boolean
1380  * @param unit parameter's measurement units
1381  * @param category parameter documentation category
1382  * @param description documentation description
1383  *
1384  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1385  * @date Thu Feb 6 16:43:30 2014
1386  */
1387  template<class T, class U>
1388  void addPar(const char *parName, T def, bool orig, ParameterType::ExprAccess depend, T U::*varPtr, bool U::*givenPtr, ParameterUnit unit, ParameterCategory category, const char *description)
1389  {
1390  Descriptor *descriptor = new Descriptor(new Entry<T>(static_cast<T ParameterBase::*>(varPtr), def));
1391 
1392  checkExprAccess(parName, depend, typeid(C));
1393 
1394  descriptor->setExpressionAccess(depend);
1395  descriptor->setOriginalValueStored(orig);
1396  descriptor->setGivenMember(givenPtr);
1397  descriptor->setUnit(unit);
1398  descriptor->setCategory(category);
1399  descriptor->setDescription(description);
1400 
1401  addDescriptor(parName, descriptor, typeid(C));
1402  }
1403 
1404  /**
1405  * Adds the parameter description to the parameter map
1406  *
1407  * This is specialization to allow const char * (quoted strings) to create a std::string type parameter.
1408  *
1409  * TODO: [DGB] This function should be eliminated and the addPar(const char *parName, T default_value, T U::*varPtr) used exclusively
1410  *
1411  * @tparam T data type of the parameter
1412  * @tparam U class containing the member data storing the parameter's value
1413  * @param parName const pointer to the parameter name
1414  * @param def default value
1415  * @param orig true if the original value is no be stored
1416  * @param depend the dependency type of this parameter
1417  * @param varPtr member pointer to the parameter's value
1418  * @param givenPtr member pointer to the parameter's given boolean
1419  * @param unit parameter's measurement units
1420  * @param category parameter documentation category
1421  * @param description documentation description
1422  *
1423  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1424  * @date Thu Feb 6 16:43:30 2014
1425  */
1426  template<class U>
1427  void addPar(const char *parName, const char *def, bool orig, ParameterType::ExprAccess depend, std::string U::*varPtr, bool U::*givenPtr, ParameterUnit unit, ParameterCategory category, const char *description)
1428  {
1429  Descriptor *descriptor = new Descriptor(new Entry<std::string>(static_cast<std::string ParameterBase::*>(varPtr), def));
1430 
1431  checkExprAccess(parName, depend, typeid(C));
1432 
1433  descriptor->setExpressionAccess(depend);
1434  descriptor->setOriginalValueStored(orig);
1435  descriptor->setGivenMember(givenPtr);
1436  descriptor->setUnit(unit);
1437  descriptor->setCategory(category);
1438  descriptor->setDescription(description);
1439 
1440  addDescriptor(parName, descriptor, typeid(C));
1441  }
1442 
1443  /**
1444  * Adds the parameter description to the parameter map
1445  *
1446  * This is specialization to allow 0 to be passed as given member pointer
1447  *
1448  * TODO: [DGB] This function should be eliminated and the addPar(const char *parName, T default_value, T U::*varPtr) used exclusively
1449  *
1450  * @tparam T data type of the parameter
1451  * @tparam U class containing the member data storing the parameter's value
1452  * @param parName const pointer to the parameter name
1453  * @param def default value
1454  * @param orig true if the original value is no be stored
1455  * @param depend the dependency type of this parameter
1456  * @param varPtr member pointer to the parameter's value
1457  * @param noGivenPtr always 0
1458  * @param unit parameter's measurement units
1459  * @param category parameter documentation category
1460  * @param description documentation description
1461  *
1462  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1463  * @date Thu Feb 6 16:43:30 2014
1464  */
1465  template<class T, class U>
1466  void addPar(const char *parName, T def, bool orig, ParameterType::ExprAccess depend, T U::*varPtr, void *noGivenPtr, ParameterUnit unit, ParameterCategory category, const char *description)
1467  {
1468  Descriptor *descriptor = new Descriptor(new Entry<T>(static_cast<T ParameterBase::*>(varPtr), def));
1469 
1470  checkExprAccess(parName, depend, typeid(C));
1471 
1472  descriptor->setExpressionAccess(depend);
1473  descriptor->setOriginalValueStored(orig);
1474  descriptor->setUnit(unit);
1475  descriptor->setCategory(category);
1476  descriptor->setDescription(description);
1477 
1478  addDescriptor(parName, descriptor, typeid(C));
1479  }
1480 
1481  /**
1482  * Adds a composite parameter to the parameter map
1483  *
1484  *
1485  * @param comp_name
1486  * @param composite_pars
1487  * @param composite_map
1488  *
1489  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1490  * @date Thu Feb 6 16:47:59 2014
1491  */
1492  template<class U, class V>
1493  void addComposite(const char *comp_name, const ParametricData<U> &composite_pars, std::map<std::string, U *> V::*composite_map)
1494  {
1495  Descriptor *descriptor = new Descriptor(new Entry<std::map<std::string, U *> >(static_cast<std::map<std::string, U *> ParameterBase::*>(composite_map)));
1496 
1497  descriptor->setUnit(U_INVALID);
1498  descriptor->setCategory(CAT_INVALID);
1499  descriptor->setCompositeParametricData(&composite_pars);
1500 
1501  addDescriptor(comp_name, descriptor, typeid(C));
1502  }
1503 
1504  /**
1505  * Adds a composite vector parameter to the parameter map
1506  *
1507  *
1508  * @param comp_name
1509  * @param composite_pars
1510  * @param composite_vector
1511  *
1512  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1513  * @date Thu Feb 6 16:47:59 2014
1514  */
1515  template<class U, class V>
1516  void addComposite(const char *comp_name, const ParametricData<U> &composite_pars, std::vector<U *> V::*composite_vector)
1517  {
1518  Descriptor *descriptor = new Descriptor(new Entry<std::vector<U *> >(static_cast<std::vector<U *> ParameterBase::*>(composite_vector)));
1519 
1520  descriptor->setUnit(U_INVALID);
1521  descriptor->setCategory(CAT_INVALID);
1522  descriptor->setCompositeParametricData(&composite_pars);
1523  addDescriptor(comp_name, descriptor, typeid(C));
1524  }
1525 
1526  /**
1527  * Allows the parameter to be specified as a vector
1528  *
1529  *
1530  * @param cname
1531  * @param len
1532  *
1533  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1534  * @date Thu Feb 6 16:50:29 2014
1535  */
1536  void makeVector(const std::string &cname, int len)
1537  {
1538  for (int i = 1; i <= len; ++i)
1539  {
1540  std::ostringstream oss;
1541  oss << cname << i;
1542  std::string param = oss.str();
1543 
1544  ParameterMap::iterator it = map_.find(param);
1545  if (it == map_.end())
1546  nonexistentParameter(param, typeid(C));
1547 
1548  Descriptor &descriptor = *(*it).second;
1549  descriptor.setVec(i);
1550  }
1551  }
1552 };
1553 
1554 /**
1555  * Set the default values for the parameter.
1556  *
1557  * Note that any values provided in the objects constructor that are defined as parameters have their initialized value
1558  * replaced with the default value given in the addPar() call
1559  *
1560  * @param parameter_base
1561  * @param begin
1562  * @param end
1563  * @param device_options
1564  *
1565  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1566  * @date Thu Feb 6 16:51:00 2014
1567  */
1568 void setDefaultParameters(ParameterBase &parameter_base, ParameterMap::const_iterator begin, ParameterMap::const_iterator end, const DeviceOptions &device_options);
1569 
1570 /**
1571  * Retrieve a parameter's original value
1572  *
1573  * @param parameter_base device entity holding parameter
1574  * @param serial_number entity's serial number
1575  *
1576  * @return original value of the parameter
1577  *
1578  * @date Tue Aug 6 13:51:16 2013
1579  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1580  */
1581 inline double getOriginalValue(ParameterBase &parameter_base, int serial_number)
1582 {
1583  return parameter_base.getOriginalValue(serial_number);
1584 }
1585 
1586 /**
1587  * Set a parameter's original value
1588  *
1589  * @param parameter_base device entity or composite holding parameter
1590  * @param serial_number entity's serial number
1591  * @param value value to be stored
1592  *
1593  * @date Tue Aug 6 13:53:29 2013
1594  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1595  */
1596 inline void setOriginalValue(ParameterBase &parameter_base, int serial_number, double value)
1597 {
1598  parameter_base.setOriginalValue(serial_number, value);
1599 }
1600 
1601 
1602 /**
1603  * Return true if a value was provided for the device
1604  *
1605  * @param parameter_base device entity or composite holding parameter
1606  * @param serial_number serial number of parameter
1607  *
1608  * @return true if a value was provided for the device
1609  *
1610  * @date Tue Aug 6 13:54:25 2013
1611  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1612  */
1613 inline bool wasValueGiven(const ParameterBase &parameter_base, int serial_number)
1614 {
1615  return parameter_base.wasValueGiven(serial_number);
1616 }
1617 
1618 
1619 /**
1620  * Set the given value state of a parameter
1621  *
1622  * @param parameter_base device entity or composite holding parameter
1623  * @param serial_number serial number of parameter
1624  * @param value true if the value was given
1625  *
1626  * @date Tue Aug 6 13:55:34 2013
1627  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1628  */
1629 inline void setValueGiven(ParameterBase &parameter_base, int serial_number, bool value)
1630 {
1631  parameter_base.setValueGiven(serial_number, value);
1632 }
1633 
1634 /**
1635  * Returns true if the name is TNOM or TEMP
1636  *
1637  * @param name parameter name
1638  *
1639  * @return true if the name is TNOM or TEMP
1640  *
1641  * @author David G. Baur Raytheon Sandia National Laboratories 1355
1642  * @date Thu Feb 6 16:52:26 2014
1643  */
1644 inline bool isTempParam(const std::string &name)
1645 {
1646  return equal_nocase(name, "TNOM") || equal_nocase(name, "TEMP");
1647 }
1648 
1649 } // namespace Device
1650 } // namespace Xyce
1651 
1652 #endif // Xyce_N_DEV_Pars_h