fix 2 compiler warnings in modelgen
[gnucap-felix.git] / lib / e_adplist.cc
blob987b848e9e3ea963cc5663c43b00c84ee3e9b8be
1 /*$Id: e_adplist.cc,v 1.10 2010-09-20 08:21:54 felix Exp $ -*- C++ -*-
2 * vim:sw=2:ts=8:et:
3 * Copyright (C) 2001 Albert Davis
4 * Author: Albert Davis <aldavis@gnu.org>
6 * This file is part of "Gnucap", the Gnu Circuit Analysis Package
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3, or (at your option)
11 * any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 * 02110-1301, USA.
22 *------------------------------------------------------------------
23 * Base class for "adp" in the circuit description file
24 * This file contains functions that process a list of adp
26 //testing=script 2006.07.10
27 #include "e_node.h"
28 #include "u_nodemap.h"
29 #include "e_model.h"
30 #include "e_adplist.h"
31 #include "e_adp.h"
32 #include "u_opt.h"
33 #include "u_time_pair.h"
34 #include "omp.h"
35 /*--------------------------------------------------------------------------*/
36 ADP_NODE_LIST::ADP_NODE_LIST()
37 :_parent(NULL),
38 _nm(new NODE_MAP),
39 _params(NULL),
40 _language(NULL)
43 /*--------------------------------------------------------------------------*/
44 ADP_NODE_LIST::~ADP_NODE_LIST()
47 /*--------------------------------------------------------------------------*/
48 ADP_NODE_LIST& ADP_NODE_LIST::erase(ADP_NODE* c)
50 delete c;
51 _al.remove(c);
52 return *this;
54 /*--------------------------------------------------------------------------*/
55 PARAM_LIST* ADP_NODE_LIST::params()
57 if (!_params) {
58 assert(!_parent);
59 _params = new PARAM_LIST;
60 }else{
62 return _params;
64 /*--------------------------------------------------------------------------*/
65 PARAM_LIST* ADP_NODE_LIST::params()const
67 if (_params) {
68 return _params;
69 }else{ //BUG//const
70 static PARAM_LIST empty_params;
71 return &empty_params;
74 /*--------------------------------------------------------------------------*/
75 //ADP_NODE_LIST::iterator ADP_NODE_LIST::find_again(const std::string& short_name,
76 // ADP_NODE_LIST::iterator Begin)
77 //{
78 // return notstd::find_ptr(Begin, end(), short_name);
79 //}
80 ///*--------------------------------------------------------------------------*/
81 //ADP_NODE_LIST::const_iterator ADP_NODE_LIST::find_again(const std::string& short_name,
82 // ADP_NODE_LIST::const_iterator Begin)const
83 //{
84 // return notstd::find_ptr(Begin, end(), short_name);
85 //}
86 /*--------------------------------------------------------------------------*/
87 /* erase_all: empty the list, destroy contents
88 * Beware: something else may be pointing to them, leaving dangling ptr.
90 ADP_NODE_LIST& ADP_NODE_LIST::erase_all()
92 while (!_al.empty()) {
93 delete _al.back();
94 _al.pop_back();
96 return *this;
98 /* tr_iwant_matrix: allocate solution matrix
99 * also sets some flags for mixed-mode
101 /*--------------------------------------------------------------------------*/
102 /* apply things to all cards */
103 ADP_NODE_LIST& ADP_NODE_LIST::do_forall( void (ADP_NODE::*thing)( ) )
105 // #pragma omp parallel for
106 for (iterator ci=begin(); ci!=end(); ++ci) {
107 ((*ci)->*thing)( );
109 return *this;
111 /*--------------------------------------------------------------------------*/
112 /* tr_accept: final acceptance of a time step, before moving on
113 * (ab) used to collect stress...
115 ADP_LIST& ADP_LIST::tr_accept()
117 for (iterator ci=begin(); ci!=end(); ++ci) {
118 // trace_func_comp();
119 (**ci).tr_accept();
121 return *this;
123 /*--------------------------------------------------------------------------*/
124 TIME_PAIR ADP_NODE_LIST::tt_review()
127 //incomplete();
128 trace0(("ADP_NODE_LIST::tt_review\n"));
129 // put review into DEVICE?
131 TIME_PAIR time_by;
132 ADP_NODE* minnode=NULL;
133 double event = 0;
134 for (iterator ci=begin(); ci!=end(); ++ci) {
136 TIME_PAIR tmp = (*ci)->tt_review();
137 trace1(("ADP_NODE_LIST::tt_review at " + (*ci)->short_label()).c_str(), tmp._event );
138 if (tmp<time_by){
139 minnode = *ci;
140 event = tmp._event;
141 trace1(("ADP_NODE_LIST::tt_review min at" +minnode->short_label()).c_str(), tmp._event );
144 time_by.min(tmp);
148 if(minnode){
149 if (OPT::tracewdtt){
150 std::cout << "* wdT min by " << minnode->short_label() << ": " <<
151 event << " gain " << event/CKT_BASE::_sim->_dTmin << "\n";
155 return time_by;
157 /*--------------------------------------------------------------------------*/
158 TIME_PAIR ADP_NODE_LIST::tt_preview()
160 TIME_PAIR time_by;
161 for (iterator ci=begin(); ci!=end(); ++ci) {
162 //time_by.min((**ci).tt_preview());
164 return time_by;
167 /*--------------------------------------------------------------------------*/
168 /*--------------------------------------------------------------------------*/
169 /*--------------------------------------------------------------------------*/
170 ADP_LIST::ADP_LIST()
171 :_parent(NULL),
172 _nm(new NODE_MAP),
173 _params(NULL),
174 _language(NULL)
177 /*--------------------------------------------------------------------------*/
178 ADP_LIST::~ADP_LIST()
181 /*--------------------------------------------------------------------------*/
182 PARAM_LIST* ADP_LIST::params()
184 if (!_params) {
185 assert(!_parent);
186 _params = new PARAM_LIST;
187 }else{
189 return _params;
191 /*--------------------------------------------------------------------------*/
192 PARAM_LIST* ADP_LIST::params()const
194 if (_params) {
195 return _params;
196 }else{ //BUG//const
197 static PARAM_LIST empty_params;
198 return &empty_params;
201 /*--------------------------------------------------------------------------*/
202 //ADP_LIST::iterator ADP_LIST::find_again(const std::string& short_name,
203 // ADP_LIST::iterator Begin)
205 // return notstd::find_ptr(Begin, end(), short_name);
207 ///*--------------------------------------------------------------------------*/
208 //ADP_LIST::const_iterator ADP_LIST::find_again(const std::string& short_name,
209 // ADP_LIST::const_iterator Begin)const
211 // return notstd::find_ptr(Begin, end(), short_name);
213 /*--------------------------------------------------------------------------*/
214 /* erase_all: empty the list, destroy contents
215 * Beware: something else may be pointing to them, leaving dangling ptr.
217 ADP_LIST& ADP_LIST::erase_all()
219 while (!_al.empty()) {
220 delete _al.back();
221 _al.pop_back();
223 return *this;
225 /* tr_iwant_matrix: allocate solution matrix
226 * also sets some flags for mixed-mode
228 /*--------------------------------------------------------------------------*/
229 /* apply things to all cards
231 ADP_LIST& ADP_LIST::do_forall( void (ADP_CARD::*thing)( ) )
233 for (iterator ci=begin(); ci!=end(); ++ci) {
234 ((*ci)->*thing)( );
236 return *this;
238 /*--------------------------------------------------------------------------*/
239 TIME_PAIR ADP_LIST::tt_review() const
241 TIME_PAIR time_by;
242 for (const_iterator ci=begin(); ci!=end(); ++ci) {
243 TIME_PAIR buf=(**ci).tt_review();
244 time_by.min(buf);
245 if (buf._event<=0){
246 std::cerr << "ADP_LIST::tt_review 0 -- not implemented?\n";
250 return time_by;
252 /*--------------------------------------------------------------------------*/
253 TIME_PAIR ADP_LIST::tt_preview()
255 TIME_PAIR time_by;
256 for (iterator ci=begin(); ci!=end(); ++ci) {
257 time_by.min((**ci).tt_preview());
259 return time_by;
261 /*--------------------------------------------------------------------------*/