#include <G4OrderedTable.hh>
Definition at line 57 of file G4OrderedTable.hh.
◆ G4OrderedTable() [1/2]
G4OrderedTable::G4OrderedTable |
( |
| ) |
|
◆ G4OrderedTable() [2/2]
G4OrderedTable::G4OrderedTable |
( |
size_t |
cap | ) |
|
|
explicit |
◆ ~G4OrderedTable()
G4OrderedTable::~G4OrderedTable |
( |
| ) |
|
|
virtual |
◆ clearAndDestroy()
void G4OrderedTable::clearAndDestroy |
( |
| ) |
|
|
inline |
Definition at line 90 of file G4OrderedTable.hh.
91{
93 while (size()>0)
94 {
95 a = back();
96 pop_back();
97 for (iterator i=begin(); i!=end(); i++)
98 {
99 if (*i==a)
100 {
101 erase(i);
102 i--;
103 }
104 }
105 if ( a ) { delete a; }
106 }
107}
Referenced by Retrieve(), and G4SandiaTable::~G4SandiaTable().
◆ Retrieve()
Definition at line 110 of file G4OrderedTable.cc.
112{
113 std::ifstream fIn;
114
115 if (ascii)
116 { fIn.open(fileName,std::ios::in|std::ios::binary); }
117 else
118 { fIn.open(fileName,std::ios::in); }
119
120
121 if (!fIn)
122 {
123#ifdef G4VERBOSE
124 G4cerr <<
"G4OrderedTable::Retrieve():";
126#endif
127 fIn.close();
128 return false;
129 }
130
131
133
134
136 if (!ascii)
137 {
138 fIn.read((char*)(&tableSize), sizeof tableSize);
139 }
140 else
141 {
142 fIn >> tableSize;
143 }
144 if (tableSize<=0)
145 {
146#ifdef G4VERBOSE
147 G4cerr <<
"G4OrderedTable::Retrieve():";
148 G4cerr <<
" Invalid table size: " << tableSize <<
G4endl;
149#endif
150 return false;
151 }
152 reserve(tableSize);
153
154
155 for (
G4int idx=0; idx<tableSize; ++idx)
156 {
158 if (!ascii)
159 {
160 fIn.read( (char*)(&vType), sizeof vType);
161 }
162 else
163 {
164 fIn >> vType;
165 }
167 {
168#ifdef G4VERBOSE
169 G4cerr <<
"G4OrderedTable::Retrieve():";
170 G4cerr <<
" Illegal Data Vector type: " << vType <<
" in ";
172#endif
173 fIn.close();
174 return false;
175 }
176
178
180 {
181#ifdef G4VERBOSE
182 G4cerr <<
"G4OrderedTable::Retrieve(): ";
183 G4cerr <<
" Rrror in retreiving " << idx
184 << "-th Physics Vector from file: ";
186#endif
187 fIn.close();
188 delete pVec;
189 return false;
190 }
191
192
193 push_back(pVec);
194 }
195 fIn.close();
196 return true;
197}
G4DLLIMPORT std::ostream G4cerr
G4bool Retrieve(std::ifstream &fIn, G4bool ascii=false)
◆ Store()
Definition at line 57 of file G4OrderedTable.cc.
59{
60 std::ofstream fOut;
61
62
63 if (!ascii)
64 { fOut.open(fileName, std::ios::out|std::ios::binary); }
65 else
66 { fOut.open(fileName, std::ios::out); }
67
68
69 if (!fOut)
70 {
71#ifdef G4VERBOSE
72 G4cerr <<
"G4OrderedTable::::Store():";
74#endif
75 fOut.close();
76 return false;
77 }
78
79
80 size_t tableSize = size();
81 if (!ascii)
82 {
83 fOut.write( (char*)(&tableSize), sizeof tableSize);
84 }
85 else
86 {
87 fOut << tableSize <<
G4endl;
88 }
89
90
93 {
94 if (!ascii)
95 {
96 fOut.write( (char*)(&vType), sizeof vType);
97 }
98 else
99 {
101 }
102 (*itr)->Store(fOut,ascii);
103 }
104 fOut.close();
105 return true;
106}
G4OrderedTable::iterator G4OrderedTableIterator
◆ operator<<
std::ostream & operator<< |
( |
std::ostream & |
out, |
|
|
G4OrderedTable & |
table |
|
) |
| |
|
friend |
Definition at line 199 of file G4OrderedTable.cc.
201{
202
203 size_t i=0;
205 {
206 out << std::setw(8) << i << "-th Vector ";
208 out << *(*itr);
209 i +=1;
210 }
212 return out;
213}
The documentation for this class was generated from the following files: