Xyce  6.1
N_DEV_Param.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // Copyright Notice
3 //
4 // Copyright 2002 Sandia Corporation. Under the terms
5 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
6 // Government retains certain rights in this software.
7 //
8 // Xyce(TM) Parallel Electrical Simulator
9 // Copyright (C) 2002-2015 Sandia Corporation
10 //
11 // This program is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 //-----------------------------------------------------------------------------
24 
25 //-------------------------------------------------------------------------
26 // Filename : $RCSfile: N_DEV_Param.h,v $
27 //
28 // Purpose :
29 //
30 // Special Notes :
31 //
32 // Creator : Eric Keiter
33 //
34 // Creation Date : 5/22/00
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.34.2.1 $
40 //
41 // Revision Date : $Date: 2015/04/02 18:20:09 $
42 //
43 // Current Owner : $Author: tvrusso $
44 //-------------------------------------------------------------------------
45 
46 #ifndef N_DEV_PARAM_H
47 #define N_DEV_PARAM_H
48 
49 #include <iosfwd>
50 #include <string>
51 #include <vector>
52 #include <map>
53 
54 #include <N_DEV_fwd.h>
55 #include <N_UTL_NoCase.h>
56 #include <N_UTL_Param.h>
57 
58 namespace Xyce {
59 namespace Device {
60 
61 //-----------------------------------------------------------------------------
62 // Class : N_DEV_Param
63 // Purpose :
64 // Special Notes :
65 // Creator : Rob Hoekstra, SNL, Parallel Computational Sciences
66 // Creation Date : 5/10/01
67 //-----------------------------------------------------------------------------
68 class Param : public Util::Param
69 {
70 public:
72  : Util::Param(),
73  isGiven_(false),
74  isDefault_(false)
75  {}
76 
77  template <class T>
78  Param(const std::string &tag, const T &value, bool is_given = false)
79  : Util::Param(tag, value),
80  isGiven_(is_given),
81  isDefault_(false)
82  {}
83 
84  Param(const Param &rhsParam)
85  : Util::Param(rhsParam),
86  isGiven_(rhsParam.isGiven_),
87  isDefault_(rhsParam.isDefault_)
88  {}
89 
90  Param &operator=(const Param &rhsParam)
91  {
92  Util::Param::operator=(rhsParam);
93  isGiven_ = rhsParam.isGiven_;
94  isDefault_ = rhsParam.isDefault_;
95 
96  return *this;
97  }
98 
99  virtual ~Param()
100  {}
101 
102  void setGiven(bool is_given)
103  {
104  isGiven_ = is_given;
105  }
106 
107  void setDefault(bool is_default)
108  {
109  isDefault_ = is_default;
110  }
111 
112  bool given() const
113  {
114  return isGiven_;
115  }
116 
117  bool default_val() const
118  {
119  return isDefault_;
120  }
121 
122 
123  virtual Packable * instance() const /* override */
124  {
125  return new Param();
126  }
127 
128  virtual int packedByteCount() const /* override */ ;
129  virtual void pack( char * buf, int bsize, int & pos, N_PDS_Comm * comm ) const /* override */ ;
130  virtual void unpack( char * pB, int bsize, int & pos, N_PDS_Comm * comm ) /* override */ ;
131 
132 private:
133  bool isGiven_;
135 };
136 
137 inline void setParamValue(Param &param, const Param &from_param)
138 {
139  param.setVal(static_cast<const Util::Param &>(from_param));
140 }
141 
142 inline void setParam(Param &param, const std::string &tag, const Param &from_param)
143 {
144  param.set(tag, static_cast<const Util::Param &>(from_param));
145 }
146 
147 } // namespace Device
148 } // namespace Xyce
149 
150 #endif
Param(const Param &rhsParam)
Definition: N_DEV_Param.h:84
Pure virtual class to augment a linear system.
virtual void unpack(char *pB, int bsize, int &pos, N_PDS_Comm *comm)
Definition: N_DEV_Param.C:114
virtual int packedByteCount() const
Definition: N_DEV_Param.C:65
void setParam(Param &param, const std::string &tag, const Param &from_param)
Definition: N_DEV_Param.h:142
const T & value(const ParameterBase &entity, const Descriptor &descriptor)
Returns the value of the parameter for the entity.
Definition: N_DEV_Pars.h:1224
void setDefault(bool is_default)
Definition: N_DEV_Param.h:107
bool given() const
Definition: N_DEV_Param.h:112
virtual void pack(char *buf, int bsize, int &pos, N_PDS_Comm *comm) const
Definition: N_DEV_Param.C:85
void setGiven(bool is_given)
Definition: N_DEV_Param.h:102
Param(const std::string &tag, const T &value, bool is_given=false)
Definition: N_DEV_Param.h:78
virtual Packable * instance() const
Definition: N_DEV_Param.h:123
Param & operator=(const Param &rhsParam)
Definition: N_DEV_Param.h:90
void setParamValue(Param &param, const Param &from_param)
Definition: N_DEV_Param.h:137
bool default_val() const
Definition: N_DEV_Param.h:117