MCPcopy Create free account
hub / github.com/OpenSees/OpenSees / sendID

Method sendID

SRC/database/FileDatastore.cpp:200–361  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

198
199
200int
201FileDatastore::sendID(int dataTag, int commitTag,
202 const ID &theID,
203 ChannelAddress *theAddress)
204{
205 if (currentCommitTag != commitTag)
206 this->resetFilePointers();
207
208 currentCommitTag = commitTag;
209
210 FileDatastoreOutputFile *theFileStruct =0;
211
212 //
213 // next we see if we already have this file;
214 // if not we need to create data structure & open it
215 // if we have data structure, need to check file is opened (we close in a commit)
216 //
217
218 int idSize = theID.Size();
219 int stepSize = (1 + idSize)*sizeof(int);
220
221 theIDFilesIter = theIDFiles.find(idSize);
222 if (theIDFilesIter == theIDFiles.end()) {
223
224 // we first check if we need to resize send buffer
225 if (idSize > currentMaxInt) {
226 if (this->resizeInt(idSize) < 0) {
227 opserr << "FileDatastore::sendID() - failed in resizeInt()\n";
228 return -1;
229 }
230 }
231
232 char *fileName = new char[strlen(dataBase)+21];
233 theFileStruct = new FileDatastoreOutputFile;
234
235 if (fileName == 0 || theFileStruct == 0) {
236 opserr << "FileDatastore::sendID() - out of memory\n";
237 return -1;
238 }
239
240 static char intName[20];
241 strcpy(fileName, dataBase);
242 sprintf(intName,"%d.%d",idSize,commitTag);
243 strcat(fileName,".IDs.");
244 strcat(fileName,intName);
245
246 if (this->openFile(fileName, theFileStruct, stepSize) < 0) {
247 opserr << "FileDatastore::sendID() - could not open file\n";
248 delete [] fileName;
249 return -1;
250 } else
251 theIDFiles.insert(MAP_FILES_TYPE(idSize, theFileStruct));
252
253 delete [] fileName;
254
255 } else {
256
257 theFileStruct = theIDFilesIter->second;

Callers

nothing calls this directly

Calls 7

resetFilePointersMethod · 0.95
resizeIntMethod · 0.95
openFileMethod · 0.95
SizeMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected