Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_DEV_DeviceMaster.C
Go to the documentation of this file.
1 // Copyright Notice
2 //
3 // Copyright 2002 Sandia Corporation. Under the terms
4 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
5 // Government retains certain rights in this software.
6 //
7 // Xyce(TM) Parallel Electrical Simulator
8 // Copyright (C) 2002-2014 Sandia Corporation
9 //
10 // This program is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // This program is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with this program. If not, see <http://www.gnu.org/licenses/>.
22 //-----------------------------------------------------------------------------
23 
24 //-------------------------------------------------------------------------
25 // Filename : $RCSfile: N_DEV_DeviceMaster.C,v $
26 //
27 // Purpose : Provides templated versions of some boilerplate functions
28 // that are device-specific (so they can't easily be included
29 // in the base device, instance, or model classes).
30 //
31 // Special Notes : Much of the functionality of the device classes, like
32 // N_DEV_Capacitor, is simply to manage STL containers
33 // of model and instance pointers. That management is pretty
34 // generic, so templating that functionality makes sense.
35 //
36 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
37 //
38 // Creation Date : 01/31/06
39 //
40 // Revision Information:
41 // ---------------------
42 //
43 // Revision Number: $Revision: 1.7 $
44 //
45 // Revision Date : $Date: 2014/05/20 19:32:33 $
46 //
47 // Current Owner : $Author: dgbaur $
48 //-------------------------------------------------------------------------
49 
50 #include <Xyce_config.h>
51 
52 #include <N_DEV_DeviceMaster.h>
53 #include <N_DEV_Message.h>
54 #include <N_DEV_DeviceInstance.h>
55 
56 namespace Xyce {
57 namespace Device {
58 
59 //-----------------------------------------------------------------------------
60 // Function : instance_must_reference_model_error
61 // Purpose :
62 // Special Notes :
63 // Scope : public
64 // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
65 // Creation Date : Tue Feb 4 10:16:23 2014
66 //-----------------------------------------------------------------------------
67 ///
68 /// reports that the type of instance requires that a model be specified
69 ///
70 /// @param device const reference to the device
71 /// @param model_name const reference to the model name
72 /// @param netlist_path const reference to the netlist path
73 /// @param line_number line number in the netlist path
74 ///
75 void instance_must_reference_model_error(const Device &device, const std::string &model_name, const NetlistLocation &netlist_location)
76 {
77  UserError(device).at(netlist_location) << model_name << " instance must reference a model";
78 }
79 
80 //-----------------------------------------------------------------------------
81 // Function : could_not_find_model_error
82 // Purpose :
83 // Special Notes :
84 // Scope : public
85 // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
86 // Creation Date : Tue Feb 4 10:18:05 2014
87 //-----------------------------------------------------------------------------
88 ///
89 /// reports that the model name is note defined
90 ///
91 /// @param device const reference to the device
92 /// @param model_name const reference to the model name
93 /// @param instance_name const reference to the instance name
94 /// @param netlist_path const reference to the netlist path
95 /// @param line_number line number in the netlist path
96 ///
97 void could_not_find_model_error(const Device &device, const std::string &model_name, const std::string &instance_name, const NetlistLocation &netlist_location)
98 {
99  UserError(device).at(netlist_location) << "Could not find model " << model_name << " which is referenced by instance " << instance_name;
100 }
101 
102 //-----------------------------------------------------------------------------
103 // Function : duplicate_model_warning
104 // Purpose :
105 // Special Notes :
106 // Scope : public
107 // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
108 // Creation Date : Tue Feb 4 10:18:41 2014
109 //-----------------------------------------------------------------------------
110 ///
111 /// duplicate_model_warning reports that the model name is duplicated.
112 ///
113 ///
114 /// @param device const reference to the device
115 /// @param model_name const reference to the model name
116 /// @param netlist_path const reference to the netlist path
117 /// @param line_number line number in the netlist path
118 ///
119 void duplicate_model_warning(const Device &device, const DeviceModel &model, const NetlistLocation &netlist_location)
120 {
121  UserWarning message(device);
122  message.at(netlist_location) << "Attempted to add model ";
123  model.printName(message.os());
124  message << " that already exists, ignoring all but the first definition";
125 }
126 
127 
128 //-----------------------------------------------------------------------------
129 // Function : duplicate_instance_warninga
130 // Purpose :
131 // Special Notes :
132 // Scope : public
133 // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
134 // Creation Date : Tue Feb 4 10:12:14 2014
135 //-----------------------------------------------------------------------------
136 ///
137 /// duplicate_instance_warning reports a duplication of instance names.
138 ///
139 /// Currently models and devices can share a name and the current implementation of instanceMap_ results in lost
140 /// information.
141 ///
142 /// @param instance const reference to the instance that is being added
143 ///
144 void duplicate_instance_warning(const Device &device, const DeviceInstance &instance, const NetlistLocation &netlist_location)
145 {
146  UserWarning message(device);
147  message.at(netlist_location) << "Attempted to add instance ";
148  instance.printName(message.os());
149  message << " that already exists, ignoring all but the first definition";
150 }
151 
152 
153 //-----------------------------------------------------------------------------
154 // Function : duplicate_entity_warninga
155 // Purpose :
156 // Special Notes :
157 // Scope : public
158 // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
159 // Creation Date : Tue Feb 4 10:12:14 2014
160 //-----------------------------------------------------------------------------
161 ///
162 /// duplicate_entity_warning reports a duplication of entity names.
163 ///
164 /// Currently models and devices can share a name and the current implementation of entityMap_ results in lost
165 /// information.
166 ///
167 /// @param entity const reference to the entity that is being added
168 ///
169 void duplicate_entity_warning(const Device &device, const DeviceEntity &entity, const NetlistLocation &netlist_location)
170 {
171  UserWarning message(device);
172  message.at(netlist_location) << "Duplicated model and device name ";
173  entity.printName(message.os());
174 }
175 
176 } // namespace Device
177 } // namespace Xyce