#include <G4OrderedTable.hh>
Definition at line 43 of file G4OrderedTable.hh.
◆ G4OrderedTable() [1/2]
G4OrderedTable::G4OrderedTable |
( |
| ) |
|
◆ G4OrderedTable() [2/2]
G4OrderedTable::G4OrderedTable |
( |
std::size_t |
cap | ) |
|
|
explicit |
◆ ~G4OrderedTable()
G4OrderedTable::~G4OrderedTable |
( |
| ) |
|
|
virtual |
◆ clearAndDestroy()
void G4OrderedTable::clearAndDestroy |
( |
| ) |
|
Definition at line 53 of file G4OrderedTable.cc.
54{
56 while(size() > 0)
57 {
58 a = back();
59 pop_back();
60 for(auto i = cbegin(); i != cend(); ++i)
61 {
62 if(*i == a)
63 {
64 erase(i);
65 --i;
66 }
67 }
68 if(a != nullptr)
69 {
70 delete a;
71 }
72 }
73}
Referenced by Retrieve(), and G4SandiaTable::~G4SandiaTable().
◆ Retrieve()
Definition at line 129 of file G4OrderedTable.cc.
130{
131 std::ifstream fIn;
132
133 if(!ascii)
134 {
135 fIn.open(fileName, std::ios::in | std::ios::binary);
136 }
137 else
138 {
139 fIn.open(fileName, std::ios::in);
140 }
141
142
143 if(!fIn)
144 {
145#ifdef G4VERBOSE
146 G4cerr <<
"G4OrderedTable::Retrieve():";
148#endif
149 fIn.close();
150 return false;
151 }
152
153
155
156
158 if(!ascii)
159 {
160 fIn.read((char*) (&tableSize), sizeof tableSize);
161 }
162 else
163 {
164 fIn >> tableSize;
165 }
166 if(tableSize <= 0)
167 {
168#ifdef G4VERBOSE
169 G4cerr <<
"G4OrderedTable::Retrieve():";
170 G4cerr <<
" Invalid table size: " << tableSize <<
G4endl;
171#endif
172 return false;
173 }
174 reserve(tableSize);
175
176
177 for(
G4int idx = 0; idx < tableSize; ++idx)
178 {
180 if(!ascii)
181 {
182 fIn.read((char*) (&vType), sizeof vType);
183 }
184 else
185 {
186 fIn >> vType;
187 }
189 {
190#ifdef G4VERBOSE
191 G4cerr <<
"G4OrderedTable::Retrieve():";
192 G4cerr <<
" Illegal Data Vector type: " << vType <<
" in ";
194#endif
195 fIn.close();
196 return false;
197 }
198
200
202 {
203#ifdef G4VERBOSE
204 G4cerr <<
"G4OrderedTable::Retrieve(): ";
205 G4cerr <<
" Error in retreiving " << idx
206 << "-th Physics Vector from file: ";
208#endif
209 fIn.close();
210 delete pVec;
211 return false;
212 }
213
214
215 push_back(pVec);
216 }
217 fIn.close();
218 return true;
219}
G4GLOB_DLL std::ostream G4cerr
G4bool Retrieve(std::ifstream &fIn, G4bool ascii=false)
◆ Store()
Definition at line 76 of file G4OrderedTable.cc.
77{
78 std::ofstream fOut;
79
80
81 if(!ascii)
82 {
83 fOut.open(fileName, std::ios::out | std::ios::binary);
84 }
85 else
86 {
87 fOut.open(fileName, std::ios::out);
88 }
89
90
91 if(!fOut)
92 {
93#ifdef G4VERBOSE
94 G4cerr <<
"G4OrderedTable::::Store():";
96#endif
97 fOut.close();
98 return false;
99 }
100
102 if(!ascii)
103 {
104 fOut.write((char*) (&tableSize), sizeof tableSize);
105 }
106 else
107 {
108 fOut << tableSize <<
G4endl;
109 }
110
112 for(auto itr = cbegin(); itr != cend(); ++itr)
113 {
114 if(!ascii)
115 {
116 fOut.write((char*) (&vType), sizeof vType);
117 }
118 else
119 {
121 }
122 (*itr)->Store(fOut, ascii);
123 }
124 fOut.close();
125 return true;
126}
◆ operator<<
std::ostream & operator<< |
( |
std::ostream & |
out, |
|
|
G4OrderedTable & |
table |
|
) |
| |
|
friend |
Definition at line 222 of file G4OrderedTable.cc.
223{
224
225 std::size_t i = 0;
226 for(auto itr = right.cbegin(); itr != right.cend(); ++itr)
227 {
228 out << std::setw(8) << i << "-th Vector ";
230 out << *(*itr);
231 i += 1;
232 }
234 return out;
235}
The documentation for this class was generated from the following files: