1 /*$Id: e_cardlist.h,v 26.138 2013/04/24 02:32:27 al Exp $ -*- C++ -*-
2 * Copyright (C) 2001 Albert Davis
3 * Author: Albert Davis <aldavis@gnu.org>
5 * This file is part of "Gnucap", the Gnu Circuit Analysis Package
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 *------------------------------------------------------------------
22 * "card" container -- list of circuit elements
24 //testing=script,complete 2006.07.11
28 /*--------------------------------------------------------------------------*/
31 /*--------------------------------------------------------------------------*/
38 /*--------------------------------------------------------------------------*/
39 class INTERFACE CARD_LIST
{
41 const CARD_LIST
* _parent
;
42 mutable NODE_MAP
* _nm
;
43 mutable PARAM_LIST
* _params
;
47 typedef std::list
<CARD
*>::iterator iterator
;
48 typedef std::list
<CARD
*>::const_iterator const_iterator
;
54 explicit fat_iterator() {unreachable();}
56 fat_iterator(const fat_iterator
& p
)
57 : _list(p
._list
), _iter(p
._iter
) {}
58 explicit fat_iterator(CARD_LIST
* l
, iterator i
)
59 : _list(l
), _iter(i
) {}
60 bool is_end()const {return _iter
== _list
->end();}
61 CARD
* operator*() {return (is_end()) ? NULL
: *_iter
;}
62 fat_iterator
& operator++() {assert(!is_end()); ++_iter
; return *this;}
63 fat_iterator
operator++(int)
64 {assert(!is_end()); fat_iterator
t(*this); ++_iter
; return t
;}
65 bool operator==(const fat_iterator
& x
)const
66 {unreachable(); assert(_list
==x
._list
); return (_iter
==x
._iter
);}
67 bool operator!=(const fat_iterator
& x
)const
68 {assert(_list
==x
._list
); return (_iter
!=x
._iter
);}
69 iterator
iter()const {return _iter
;}
70 CARD_LIST
* list()const {return _list
;}
71 fat_iterator
end()const {return fat_iterator(_list
, _list
->end());}
73 void insert(CARD
* c
) {list()->insert(iter(),c
);}
77 bool is_empty()const {return _cl
.empty();}
78 const CARD_LIST
* parent()const {return _parent
;}
81 iterator
begin() {return _cl
.begin();}
82 iterator
end() {return _cl
.end();}
83 iterator
find_again(const std::string
& short_name
, iterator
);
84 iterator
find_(const std::string
& short_name
)
85 {return find_again(short_name
, begin());}
87 // return a const_iterator
88 const_iterator
begin()const {return _cl
.begin();}
89 const_iterator
end()const {return _cl
.end();}
90 const_iterator
find_again(const std::string
& short_name
, const_iterator
)const;
91 const_iterator
find_(const std::string
& short_name
)const
92 {return find_again(short_name
, begin());}
95 CARD_LIST
& push_front(CARD
* c
) {_cl
.push_front(c
); return *this;}
96 CARD_LIST
& push_back(CARD
* c
) {_cl
.push_back(c
); return *this;}
97 CARD_LIST
& insert(CARD_LIST::iterator i
, CARD
* c
)
98 {_cl
.insert(i
, c
); return *this;}
101 CARD_LIST
& erase(iterator i
);
102 CARD_LIST
& erase(CARD
* c
);
103 CARD_LIST
& erase_all();
105 // operations on the whole list
106 CARD_LIST
& set_owner(CARD
* owner
);
107 CARD_LIST
& set_slave();
108 CARD_LIST
& precalc_first();
110 CARD_LIST
& precalc_last();
111 CARD_LIST
& map_nodes();
112 CARD_LIST
& tr_iwant_matrix();
113 CARD_LIST
& tr_begin();
114 CARD_LIST
& tr_restore();
115 CARD_LIST
& dc_advance();
116 CARD_LIST
& tr_advance();
117 CARD_LIST
& tr_regress();
118 bool tr_needs_eval()const;
119 CARD_LIST
& tr_queue_eval();
121 CARD_LIST
& tr_load();
122 TIME_PAIR
tr_review();
123 CARD_LIST
& tr_accept();
124 CARD_LIST
& tr_unload();
125 CARD_LIST
& ac_iwant_matrix();
126 CARD_LIST
& ac_begin();
128 CARD_LIST
& ac_load();
130 NODE_MAP
* nodes()const {assert(_nm
); return _nm
;}
131 PARAM_LIST
* params();
132 PARAM_LIST
* params()const;
134 // more complex stuff
135 void attach_params(PARAM_LIST
* p
, const CARD_LIST
* scope
);
136 void shallow_copy(const CARD_LIST
*);
137 void map_subckt_nodes(const CARD
* model
, const CARD
* owner
);
139 explicit CARD_LIST();
140 CARD_LIST(const CARD
* model
, CARD
* owner
, const CARD_LIST
* scope
,
144 explicit CARD_LIST(const CARD_LIST
&) {unreachable(); incomplete();}
146 static CARD_LIST card_list
; // in globals.cc
148 /*--------------------------------------------------------------------------*/
149 INTERFACE
CARD_LIST::fat_iterator
findbranch(CS
&,CARD_LIST::fat_iterator
);
150 /*--------------------------------------------------------------------------*/
151 inline CARD_LIST::fat_iterator
findbranch(CS
& cmd
, CARD_LIST
* cl
)
154 return findbranch(cmd
, CARD_LIST::fat_iterator(cl
, cl
->begin()));
156 /*--------------------------------------------------------------------------*/
157 /*--------------------------------------------------------------------------*/
159 // vim:ts=8:sw=2:noet: