Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_DEV_Dump.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-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_Dump.C,v $
27 //
28 // Purpose :
29 //
30 // Special Notes :
31 //
32 // Creator : David Baur
33 //
34 // Creation Date : 04/18/2013
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.1 $
40 //
41 // Revision Date : $Date: 2014/02/12 19:17:28 $
42 //
43 // Current Owner : $Author: dgbaur $
44 //-------------------------------------------------------------------------
45 
46 #include <Xyce_config.h>
47 
48 #include <algorithm>
49 #include <iomanip>
50 #include <ostream>
51 #include <stdexcept>
52 
53 #include <N_DEV_Dump.h>
54 #include <N_DEV_Configuration.h>
55 #include <N_UTL_IndentStreamBuf.h>
56 #include <N_UTL_Demangle.h>
57 
58 namespace Xyce {
59 namespace Device {
60 
62 {
63  bool operator()(const std::type_info *t0, const std::type_info *t1)
64  {
65  return t0->before(*t1);
66  }
67 };
68 
69 std::map<const std::type_info *, std::string, type_compare_less> s_typeInfoNameMap;
70 
71 std::ostream &printTypeName(std::ostream &os, const std::type_info &type)
72 {
73  if (s_typeInfoNameMap.empty()) {
74  s_typeInfoNameMap[&typeid(bool)] = "boolean";
75  s_typeInfoNameMap[&typeid(double)] = "double";
76  s_typeInfoNameMap[&typeid(int)] = "int";
77  s_typeInfoNameMap[&typeid(std::string)] = "string";
78  s_typeInfoNameMap[&typeid(std::vector<double>)] = "double vector";
79  s_typeInfoNameMap[&typeid(std::vector<int>)] = "int vector";
80  s_typeInfoNameMap[&typeid(std::vector<std::string>)] = "string vector";
81  }
82 
83  if (s_typeInfoNameMap[&type].empty())
84  os << "composite"; // demangle(type.name());
85  else
86  os << s_typeInfoNameMap[&type];
87 
88  return os;
89 }
90 
91 std::ostream &outputParameterMap(std::ostream &os, const ParameterMap &parameter_map);
92 
93 std::ostream &outputDescriptor(std::ostream &os, const Descriptor &descriptor)
94 {
95  if (&descriptor.getEntry()) {
96  printTypeName(os, descriptor.getEntry().type());
97  }
98 
99  if (!descriptor.getCompositeParametricData<void>()) {
100  os << ", default ";
101  descriptor.getEntry().print(os);
102  if (descriptor.hasOriginalValueStored())
103  os << ", original value managed, scaling enabled";
104  }
105  else {
106  const ParametricData<void> &composite_parametric_data = *descriptor.getCompositeParametricData<void>();
107  os << Util::push << std::endl;
108  outputParameterMap(os, composite_parametric_data.getMap());
109  os << Util::pop;
110  }
111 
112  os << std::endl;
113 
114  return os;
115 }
116 
117 std::ostream &outputParameterMap(std::ostream &os, const ParameterMap &parameter_map)
118 {
119  for (ParameterMap::const_iterator it = parameter_map.begin(); it != parameter_map.end(); ++it) {
120  os << (*it).first << ", ";
121 
122  outputDescriptor(os, *(*it).second);
123  }
124 
125  return os;
126 }
127 
128 std::ostream &operator<<(std::ostream &os, const Configuration &configuration)
129 {
130  ParametricData<void> &instance_parameters = configuration.getInstanceParameters();
131  ParametricData<void> &model_parameters = configuration.getModelParameters();
132 
133  os << "Configuration" << Xyce::Util::push << std::endl
134  << "Name: " << configuration.getName() << std::endl
135  << "Device Type: " << configuration.getDeviceTypeName() << std::endl
136  << "Nodes: " << configuration.getNumNodes() << std::endl
137  << "Optional Nodes: " << configuration.getNumOptionalNodes() << std::endl
138  << "Fill Nodes: " << configuration.getNumFillNodes() << std::endl
139  << "Model Required: " << (configuration.getModelRequired() ? "yes" : "no") << std::endl
140  << "Linear Device: " << (configuration.getLinearDevice() ? "yes" : "no") << std::endl
141  << "PDE Device: " << (configuration.getPDEDevice() ? "yes" : "no") << std::endl
142  << "Primary Parameter: " << (configuration.getPrimaryParameter().empty() ? "<none>" : configuration.getPrimaryParameter()) << std::endl
143  << "Instance Default Parameter: " << (configuration.getInstanceDefaultParameterName().empty() ? "<none>" : configuration.getInstanceDefaultParameterName()) << std::endl;
144 
145  os << "Model Types: ";
146  for (std::vector<std::string>::const_iterator it = configuration.getModelTypeNames().begin(); it != configuration.getModelTypeNames().end(); ++it) {
147  if (it != configuration.getModelTypeNames().begin())
148  os << ", ";
149  os << *it;
150  }
151  os << Xyce::Util::pop << std::endl
152  << "Model Parameters" << Xyce::Util::push << std::endl;
153  outputParameterMap(os, model_parameters.getMap());
154  os << Xyce::Util::pop << std::endl
155  << "Instance Parameters" << Xyce::Util::push << std::endl;
156  outputParameterMap(os, instance_parameters.getMap());
157 
158  os << Xyce::Util::pop << std::endl
159  << Xyce::Util::pop << std::endl;
160 
161  return os;
162 }
163 
164 } // namespace Device
165 } // namespace Xyce