Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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-2014 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.30 $
40 //
41 // Revision Date : $Date: 2014/02/24 23:49:15 $
42 //
43 // Current Owner : $Author: tvrusso $
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 namespace Device {
56 
57 //-----------------------------------------------------------------------------
58 // Function : packedByteCount
59 // Purpose :
60 // Special Notes :
61 // Scope : Public
62 // Creator : Rob Hoekstra, SNL
63 // Creation Date : 5/15/01
64 //-----------------------------------------------------------------------------
66 {
67  // Util::Param info
68  int byteCount = Util::Param::packedByteCount();
69 
70  // given & default
71  byteCount += sizeof(int);
72 
73  return byteCount;
74 
75 }
76 
77 //-----------------------------------------------------------------------------
78 // Function : pack
79 // Purpose :
80 // Special Notes :
81 // Scope : Public
82 // Creator : Rob Hoekstra, SNL
83 // Creation Date : 5/15/01
84 //-----------------------------------------------------------------------------
85 void Param::pack( char * buf, const int bsize, int & pos,
86  N_PDS_Comm * comm ) const
87 {
88 #ifdef Xyce_COUNT_PACKED_BYTES
89  int predictedPos = pos+packedByteCount();
90 #endif
91 
92  Util::Param::pack( buf, bsize, pos, comm );
93 
94  //pack given_
95  int dg = (isGiven_?1:0) + 2*(isDefault_?1:0);
96  comm->pack( &dg, 1, buf, bsize, pos );
97 
98 #ifdef Xyce_COUNT_PACKED_BYTES
99  if (pos != predictedPos)
100  {
101  DevelFatal(*this, "Param::pack") << "Predicted pos does not match actual pos";
102  }
103 #endif
104 }
105 
106 //-----------------------------------------------------------------------------
107 // Function : unpack
108 // Purpose :
109 // Special Notes :
110 // Scope : Public
111 // Creator : Rob Hoekstra, SNL
112 // Creation Date : 5/15/01
113 //-----------------------------------------------------------------------------
114 void Param::unpack( char * pB, int bsize, int & pos, N_PDS_Comm * comm )
115 {
116  Util::Param::unpack( pB, bsize, pos, comm );
117 
118  //unpack given_
119  int dg;
120  comm->unpack( pB, bsize, pos, &dg, 1 );
121  isGiven_ = ( dg%2 != 0 );
122  isDefault_ = ( dg >= 2 );
123 }
124 
125 } // namespace Device
126 } // namespace Xyce