Xyce  6.1
N_DEV_DeviceBlock.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_DeviceBlock.h,v $
27 //
28 // Purpose :
29 //
30 // Special Notes :
31 //
32 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
33 //
34 // Creation Date : 02/28/00
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.37.2.1 $
40 //
41 // Revision Date : $Date: 2015/04/02 18:20:09 $
42 //
43 // Current Owner : $Author: tvrusso $
44 //-----------------------------------------------------------------------------
45 
46 
47 #ifndef Xyce_N_DEV_DeviceBlock_h
48 #define Xyce_N_DEV_DeviceBlock_h
49 
50 #include <string>
51 #include <vector>
52 #include <iosfwd>
53 
54 #include <N_DEV_Param.h>
55 #include <N_DEV_InstanceName.h>
56 #include <N_UTL_NetlistLocation.h>
57 #include <N_UTL_Packable.h>
58 
59 namespace Xyce {
60 namespace Device {
61 
62 //-----------------------------------------------------------------------------
63 // Class : ModelBlock
64 // Purpose :
65 // Special Notes :
66 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
67 // Creation Date : 3/31/00
68 //-----------------------------------------------------------------------------
69 ///
70 /// ModelBlock represents a .MODEL line from the netlist.
71 ///
72 class ModelBlock : public Packable
73 {
74  friend std::ostream& operator<<(std::ostream& os, const ModelBlock & mb);
75 
76 public:
77  ModelBlock(const std::string &name = "", const std::string &type = "", int level = 1);
78 
79  ModelBlock(const ModelBlock & right);
80  ModelBlock &operator=(const ModelBlock & right);
81 
82  ~ModelBlock();
83 
84  const ModelName &getName() const
85  {
86  return name_;
87  }
88 
89  void setName(const ModelName &name)
90  {
91  name_ = name;
92  }
93 
94  const std::string &getType() const
95  {
96  return type_;
97  }
98 
99  void setType(const std::string &type)
100  {
101  type_ = type;
102  }
103 
104  int getLevel() const
105  {
106  return level_;
107  }
108 
109  void setLevel(int level)
110  {
111  level_ = level;
112  }
113 
114  const NetlistLocation &getNetlistLocation() const
115  {
116  return netlistLocation_;
117  }
118 
119  void setNetlistLocation(const NetlistLocation &netlist_location)
120  {
121  netlistLocation_ = netlist_location;
122  }
123 
124  bool operator==(const ModelBlock &right) const
125  {
126  return equal_nocase(name_, right.name_);
127  }
128 
129  bool operator!=(const ModelBlock &right) const
130  {
131  return !equal_nocase(name_, right.name_);
132  }
133 
134  void clear();
135 
136  // Packing Utils
137  Packable * instance() const;
138  int packedByteCount() const;
139 
140  void pack( char * buf, int bsize, int & pos, N_PDS_Comm * comm ) const;
141  void unpack( char * pB, int bsize, int & pos, N_PDS_Comm * comm );
142 
143 private:
144  ModelName name_; ///< Model name
145  std::string type_; ///< Model type
146  int level_; ///< Device level
147  NetlistLocation netlistLocation_; ///< Path and line number of .MODEL command
148 
149 public:
150  std::vector<Param> params; ///< Parameters from the line
151 };
152 
153 //-----------------------------------------------------------------------------
154 // Class : InstanceBlock
155 // Purpose :
156 // Special Notes :
157 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
158 // Creation Date : 3/31/00
159 //-----------------------------------------------------------------------------
160 ///
161 /// InstanceBlock represent a device instance line from the netlist.
162 ///
163 class InstanceBlock : public Packable
164 {
165  friend std::ostream& operator<<(std::ostream& os, const InstanceBlock & ib);
166 
167 public:
168  InstanceBlock(const std::string &name = std::string());
169 
170  InstanceBlock(const InstanceBlock &right);
171  InstanceBlock &operator=(const InstanceBlock &right);
172 
173  ~InstanceBlock();
174 
176  {
177  return name_;
178  }
179 
180  void setInstanceName(const InstanceName &name)
181  {
182  name_ = name;
183  }
184 
185  const ModelName &getModelName() const
186  {
187  return modelName_;
188  }
189 
190  void setModelName(const ModelName &modelName)
191  {
192  modelName_ = modelName;
193  }
194 
195  const NetlistLocation &getNetlistLocation() const {
196  return netlistLocation_;
197  }
198 
199  void setNetlistLocation(const NetlistLocation &netlist_location)
200  {
201  netlistLocation_ = netlist_location;
202  }
203 
204  bool operator==(const InstanceBlock &right) const
205  {
206  return equal_nocase(name_.getEncodedName(), right.name_.getEncodedName());
207  }
208 
209  bool operator!=(const InstanceBlock &right) const
210  {
211  return !equal_nocase(name_.getEncodedName(), right.name_.getEncodedName());
212  }
213 
214  void clear ();
215 
216  //Packing Utils
217  Packable * instance() const;
218  int packedByteCount() const;
219 
220  void pack( char * buf, int bsize, int & pos, N_PDS_Comm * comm ) const;
221  void unpack( char * pB, int bsize, int & pos, N_PDS_Comm * comm );
222 
223 private:
224  InstanceName name_; ///< Device instance name
225  ModelName modelName_; ///< Model name if provided
226  NetlistLocation netlistLocation_; ///< Path and line number of .MODEL command
227 
228 public:
229  std::vector<Param> params;
230 
235 
236  bool modelFlag;
239  bool offFlag;
240  bool off;
241 };
242 
243 } // namespace Device
244 } // namespace Xyce
245 
246 #endif
bool operator==(const ModelBlock &right) const
const ModelName & getName() const
void setNetlistLocation(const NetlistLocation &netlist_location)
ModelBlock(const std::string &name="", const std::string &type="", int level=1)
void unpack(char *pB, int bsize, int &pos, N_PDS_Comm *comm)
friend std::ostream & operator<<(std::ostream &os, const ModelBlock &mb)
Pure virtual class to augment a linear system.
Devices and models are each named.
const std::string & getEncodedName() const
Return the instance name encoded as: [s:]*xname [s:]*Ytype!name [s:]*Utype!name!count.
void unpack(char *pB, int bsize, int &pos, N_PDS_Comm *comm)
void setNetlistLocation(const NetlistLocation &netlist_location)
bool operator!=(const InstanceBlock &right) const
NetlistLocation netlistLocation_
Path and line number of .MODEL command.
ModelName name_
Model name.
bool operator!=(const ModelBlock &right) const
bool operator==(const InstanceBlock &right) const
std::vector< Param > params
Parameters from the line.
InstanceBlock(const std::string &name=std::string())
Packable * instance() const
void setName(const ModelName &name)
Packable * instance() const
void setType(const std::string &type)
ModelBlock & operator=(const ModelBlock &right)
void pack(char *buf, int bsize, int &pos, N_PDS_Comm *comm) const
std::string type_
Model type.
const std::string & getType() const
const ModelName & getModelName() const
const InstanceName & getInstanceName() const
const NetlistLocation & getNetlistLocation() const
void setInstanceName(const InstanceName &name)
InstanceName name_
Device instance name.
const NetlistLocation & getNetlistLocation() const
InstanceBlock & operator=(const InstanceBlock &right)
void pack(char *buf, int bsize, int &pos, N_PDS_Comm *comm) const
friend std::ostream & operator<<(std::ostream &os, const InstanceBlock &ib)
ModelBlock represents a .MODEL line from the netlist.
NetlistLocation netlistLocation_
Path and line number of .MODEL command.
std::string ModelName
Definition: N_DEV_fwd.h:157
InstanceBlock represent a device instance line from the netlist.
std::vector< Param > params
void setModelName(const ModelName &modelName)
ModelName modelName_
Model name if provided.