Xyce  6.1
N_DEV_Param.C
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.C,v $
27 //
28 // Purpose :
29 //
30 // Special Notes :
31 //
32 // Creator : Robert Hoekstra, SNL
33 //
34 // Creation Date : 5/15/01
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.32 $
40 //
41 // Revision Date : $Date: 2015/05/13 22:28:56 $
42 //
43 // Current Owner : $Author: dgbaur $
44 //-------------------------------------------------------------------------
45 
46 #include <Xyce_config.h>
47 
48 #include <iostream>
49 
50 #include <N_DEV_Param.h>
51 #include <N_PDS_Comm.h>
52 #include <N_ERH_ErrorMgr.h>
53 
54 namespace Xyce {
55 
56 //-----------------------------------------------------------------------------
57 // Function : packedByteCount
58 // Purpose :
59 // Special Notes :
60 // Scope : Public
61 // Creator : Rob Hoekstra, SNL
62 // Creation Date : 5/15/01
63 //-----------------------------------------------------------------------------
64 template<>
65 int
66 Pack<Device::Param>::packedByteCount(
67  const Device::Param & param)
68 {
69  // Util::Param info
70  int byteCount = Xyce::packedByteCount(static_cast<const Util::Param &>(param));
71 
72  // given & default
73  byteCount += sizeof(int);
74 
75  return byteCount;
76 
77 }
78 
79 //-----------------------------------------------------------------------------
80 // Function : pack
81 // Purpose :
82 // Special Notes :
83 // Scope : Public
84 // Creator : Rob Hoekstra, SNL
85 // Creation Date : 5/15/01
86 //-----------------------------------------------------------------------------
87 template<>
88 void
89 Pack<Device::Param>::pack(
90  const Device::Param & param,
91  char * buf,
92  const int bsize,
93  int & pos,
94  N_PDS_Comm * comm )
95 {
96 #ifdef Xyce_COUNT_PACKED_BYTES
97  int predictedPos = pos + Xyce::packedByteCount(param);
98 #endif
99 
100  Xyce::pack(static_cast<const Util::Param &>(param), buf, bsize, pos, comm );
101 
102  //pack given_
103  int dg = (param.isGiven_?1:0) + 2*(param.isDefault_ ? 1 : 0);
104  comm->pack( &dg, 1, buf, bsize, pos );
105 
106 #ifdef Xyce_COUNT_PACKED_BYTES
107  if (pos != predictedPos)
108  {
109  DevelFatal(*this, "Param::pack") << "Predicted pos does not match actual pos";
110  }
111 #endif
112 }
113 
114 //-----------------------------------------------------------------------------
115 // Function : unpack
116 // Purpose :
117 // Special Notes :
118 // Scope : Public
119 // Creator : Rob Hoekstra, SNL
120 // Creation Date : 5/15/01
121 //-----------------------------------------------------------------------------
122 template <>
123 void
124 Pack<Device::Param>::unpack(Device::Param &param, char * pB, int bsize, int & pos, N_PDS_Comm * comm )
125 {
126  Xyce::unpack(static_cast<Util::Param &>(param), pB, bsize, pos, comm );
127 
128  //unpack given_
129  int dg;
130  comm->unpack( pB, bsize, pos, &dg, 1 );
131  param.isGiven_ = ( dg%2 != 0 );
132  param.isDefault_ = ( dg >= 2 );
133 }
134 
135 } // namespace Xyce
Pure virtual class to augment a linear system.