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

Method recvID

SRC/database/quick.cpp:92–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92int
93FileDatastore::recvID(int dataTag, int commitTag,
94 ID &theID,
95 ChannelAddress *theAddress)
96{
97 // we first check ID not too big
98 int idSize = theID.Size();
99 if (idSize >= maxIDsize) {
100 opserr << "FileDatastore::recvID() - the database does not deal with IDs";
101 opserr << " of this size " << idSize << endln;
102 return -1;
103 }
104
105 // open the file - if not already opened
106 if (ids[idSize] == 0) {
107 char fileName[70];
108 char intName[10];
109 strcpy(fileName, dataBase);
110 itoa(idSize, intName);
111 strcat(fileName,".IDs.");
112 strcat(fileName,intName);
113 ids[idSize] = this->openFile(fileName);
114 int loc = ids[idSize]->tellg();
115 if (loc == -1) loc = 0;
116 fileEnds.ids[idSize] = loc;
117 }
118
119 // we now read in the data unti we reach eof or find the data
120 int stepSize = (2 + idSize)*sizeof(int);
121 fstream *theStream = ids[idSize];
122
123 theStream->seekg(0);
124 bool found = false;
125 int pos =0;
126 int fileEnd = fileEnds.ids[idSize];
127
128 while ((pos < fileEnd) && (found == false)) {
129 theStream->read((char *)&idBuffer, stepSize);
130 if ((idBuffer.dbTag == dataTag) && (idBuffer.commitTag == commitTag))
131 found = true;
132 pos += stepSize;
133 }
134
135 if (found == false) {
136 opserr << "FileDatastore::recvID() - failed to find data for ID of size ";
137 opserr << idSize << endln;
138 return -1;
139 }
140
141 // we now place the received data into the ID
142 idBuffer.dbTag = dataTag;
143 idBuffer.commitTag = commitTag;
144 for (int i=0; i<idSize; i++)
145 theID(i) = idBuffer.data[i];
146
147 return 0;
148}

Callers 15

recvSelfMethod · 0.45
recvSelfMethod · 0.45
~BinaryFileStreamMethod · 0.45
recvSelfMethod · 0.45
setOrderMethod · 0.45
recvSelfMethod · 0.45
recvSelfMethod · 0.45
setOrderMethod · 0.45
recvSelfMethod · 0.45
recvSelfMethod · 0.45
recvSelfMethod · 0.45
recvSelfMethod · 0.45

Calls 2

openFileMethod · 0.95
SizeMethod · 0.45

Tested by

no test coverage detected