testing
[gnucap-felix.git] / src / e_adplist.h
blob51a4a2d4404d4bdbea0bccd9703ccdc716e70f40
1 /* vim:ts=8:sw=2:et:
2 * "adp" container -- list of aging parms
3 */
4 #ifndef E_ADPLIST_H
5 #define E_ADPLIST_H
6 #include "md.h"
7 //#include "e_adp.h"
8 /*--------------------------------------------------------------------------*/
9 // defined here
10 class ADP_NODE_LIST;
11 class ADP_NODE;
12 class ADP_LIST;
13 class ADP_CARD;
14 /*--------------------------------------------------------------------------*/
15 // external
16 class PARAM_LIST;
17 class NODE_MAP;
18 class LANGUAGE;
19 struct TIME_PAIR;
20 /*--------------------------------------------------------------------------*/
21 class INTERFACE ADP_LIST { // cardlist, needed?
22 private:
23 const ADP_LIST* _parent;
24 mutable NODE_MAP* _nm;
25 mutable PARAM_LIST* _params;
26 LANGUAGE* _language;
27 std::list<ADP_CARD*> _al;
28 public:
29 // internal types
30 typedef std::list<ADP_CARD*>::iterator iterator;
31 typedef std::list<ADP_CARD*>::const_iterator const_iterator;
32 class fat_iterator {
33 private:
34 ADP_LIST* _list;
35 iterator _iter;
36 private:
37 explicit fat_iterator() {unreachable();}
38 public:
39 fat_iterator(const fat_iterator& p)
40 : _list(p._list), _iter(p._iter) {}
41 explicit fat_iterator(ADP_LIST* l, iterator i)
42 : _list(l), _iter(i) {}
43 bool is_end()const {return _iter == _list->end();}
44 ADP_CARD* operator*() {return (is_end()) ? NULL : *_iter;}
45 fat_iterator& operator++() {assert(!is_end()); ++_iter; return *this;}
46 fat_iterator operator++(int)
47 {assert(!is_end()); fat_iterator t(*this); ++_iter; return t;}
48 bool operator==(const fat_iterator& x)const
49 {unreachable(); assert(_list==x._list); return (_iter==x._iter);}
50 bool operator!=(const fat_iterator& x)const
51 {assert(_list==x._list); return (_iter!=x._iter);}
52 iterator iter()const {return _iter;}
53 ADP_LIST* list()const {return _list;}
54 fat_iterator end()const {return fat_iterator(_list, _list->end());}
56 //void insert(ADP_CARD* c) {list()->insert(iter(),c);}
59 // status queries
60 bool is_empty()const {return _al.empty();}
61 const ADP_LIST* parent()const {return _parent;}
62 const LANGUAGE* language()const {untested(); return _language;}
64 // return an iterator
65 iterator begin() {return _al.begin();}
66 iterator end() {return _al.end();}
67 iterator find_again(const std::string& short_name, iterator);
68 iterator find_(const std::string& short_name)
69 {return find_again(short_name, begin());}
71 ADP_LIST& erase(iterator i);
72 ADP_LIST& erase(ADP_CARD* c);
73 ADP_LIST& erase_all();
74 ADP_LIST& expand();
75 ADP_LIST& do_forall( void (ADP_CARD::*thing)( void ) );
78 // return a const_iterator
79 const_iterator begin()const {return _al.begin();}
80 const_iterator end()const {return _al.end();}
81 const_iterator find_again(const std::string& short_name, const_iterator)const;
82 const_iterator find_(const std::string& short_name)const
83 {return find_again(short_name, begin());}
85 // add to it
86 void print();
89 ADP_LIST& push_front(ADP_CARD* c) {_al.push_front(c); return *this;}
90 ADP_LIST& push_back(ADP_CARD* c) {_al.push_back(c); return *this;}
93 TIME_PAIR tt_review() const;
94 ADP_LIST& tr_accept();
96 TIME_PAIR tt_preview();
98 ADP_LIST& save();
100 NODE_MAP* nodes()const {assert(_nm); return _nm;}
101 PARAM_LIST* params();
102 PARAM_LIST* params()const;
104 // more complex stuff
105 void attach_params(PARAM_LIST* p, const ADP_LIST* scope);
106 void shallow_copy(const ADP_LIST*);
107 void map_subckt_nodes(const ADP_CARD* model, const ADP_CARD* owner);
109 explicit ADP_LIST();
110 ADP_LIST(const ADP_CARD* model, ADP_CARD* owner, const ADP_LIST* scope,
111 PARAM_LIST* p);
112 ~ADP_LIST();
113 private:
114 explicit ADP_LIST(const ADP_LIST&) {unreachable(); incomplete();}
115 public:
116 static ADP_LIST adp_list; // in globals.cc
118 /*--------------------------------------------------------------------------*/
119 /*--------------------------------------------------------------------------*/
120 /*--------------------------------------------------------------------------*/
121 class INTERFACE ADP_NODE_LIST {
122 private:
123 const ADP_NODE_LIST* _parent;
124 mutable NODE_MAP* _nm;
125 mutable PARAM_LIST* _params;
126 LANGUAGE* _language;
127 std::list<ADP_NODE*> _al;
128 public:
129 // internal types
130 typedef std::list<ADP_NODE*>::iterator iterator;
131 typedef std::list<ADP_NODE*>::const_iterator const_iterator;
132 class fat_iterator {
133 private:
134 ADP_NODE_LIST* _list;
135 iterator _iter;
136 private:
137 explicit fat_iterator() {unreachable();}
138 public:
139 fat_iterator(const fat_iterator& p)
140 : _list(p._list), _iter(p._iter) {}
141 explicit fat_iterator(ADP_NODE_LIST* l, iterator i)
142 : _list(l), _iter(i) {}
143 bool is_end()const {return _iter == _list->end();}
144 ADP_NODE* operator*() {return (is_end()) ? NULL : *_iter;}
145 fat_iterator& operator++() {assert(!is_end()); ++_iter; return *this;}
146 fat_iterator operator++(int)
147 {assert(!is_end()); fat_iterator t(*this); ++_iter; return t;}
148 bool operator==(const fat_iterator& x)const
149 {unreachable(); assert(_list==x._list); return (_iter==x._iter);}
150 bool operator!=(const fat_iterator& x)const
151 {assert(_list==x._list); return (_iter!=x._iter);}
152 iterator iter()const {return _iter;}
153 ADP_NODE_LIST* list()const {return _list;}
154 fat_iterator end()const {return fat_iterator(_list, _list->end());}
156 //void insert(ADP_NODE* c) {list()->insert(iter(),c);}
159 // status queries
160 bool is_empty()const {return _al.empty();}
161 const ADP_NODE_LIST* parent()const {return _parent;}
162 const LANGUAGE* language()const {untested(); return _language;}
164 // return an iterator
165 iterator begin() {return _al.begin();}
166 iterator end() {return _al.end();}
167 iterator find_again(const std::string& short_name, iterator);
168 iterator find_(const std::string& short_name)
169 {return find_again(short_name, begin());}
171 ADP_NODE_LIST& erase(iterator i);
172 ADP_NODE_LIST& erase(ADP_NODE* c);
173 ADP_NODE_LIST& erase_all();
174 ADP_NODE_LIST& expand();
175 ADP_NODE_LIST& do_forall( void (ADP_NODE::*thing)( void ) );
180 // return a const_iterator
181 const_iterator begin()const {return _al.begin();}
182 const_iterator end()const {return _al.end();}
183 const_iterator find_again(const std::string& short_name, const_iterator)const;
184 const_iterator find_(const std::string& short_name)const
185 {return find_again(short_name, begin());}
187 // add to it
188 void print();
190 //ADP_NODE_LIST& insert(ADP::iterator i, ADP_NODE* c) {
191 // _al.insert(i, c); return *this;
194 ADP_NODE_LIST& push_front(ADP_NODE* c) {_al.push_front(c); return *this;}
195 ADP_NODE_LIST& push_back(ADP_NODE* c) {_al.push_back(c); return *this;}
198 TIME_PAIR tt_review();
200 TIME_PAIR tt_preview();
202 ADP_NODE_LIST& save();
204 NODE_MAP* nodes()const {assert(_nm); return _nm;}
205 PARAM_LIST* params();
206 PARAM_LIST* params()const;
208 // more complex stuff
209 void attach_params(PARAM_LIST* p, const ADP_NODE_LIST* scope);
210 void shallow_copy(const ADP_NODE_LIST*);
211 void map_subckt_nodes(const ADP_NODE* model, const ADP_NODE* owner);
213 explicit ADP_NODE_LIST();
214 ADP_NODE_LIST(const ADP_NODE* model, ADP_NODE* owner, const ADP_NODE_LIST* scope,
215 PARAM_LIST* p);
216 ~ADP_NODE_LIST();
217 private:
218 explicit ADP_NODE_LIST(const ADP_NODE_LIST&) {unreachable(); incomplete();}
219 public:
220 static ADP_NODE_LIST adp_node_list; // in globals.cc
222 /*--------------------------------------------------------------------------*/
223 /*--------------------------------------------------------------------------*/
224 #endif