| 251 | } |
| 252 | |
| 253 | int FileContents::nextLine(int userId) |
| 254 | { |
| 255 | switch(usage) { |
| 256 | case InputFileRandomOrder: |
| 257 | return rand() % numLinesInFile; |
| 258 | case InputFileSequentialOrder: { |
| 259 | int ret = lineCounter; |
| 260 | lineCounter = (lineCounter + 1) % numLinesInFile; |
| 261 | return ret; |
| 262 | } |
| 263 | case InputFileUser: |
| 264 | if (userId == 0) { |
| 265 | return -1; |
| 266 | } |
| 267 | if ((userId - 1) >= numLinesInFile) { |
| 268 | ERROR("%s has only %d lines, yet user %d was requested.", fileName, numLinesInFile, userId); |
| 269 | } |
| 270 | return userId - 1; |
| 271 | default: |
| 272 | ERROR("Internal error: unknown file usage mode!"); |
| 273 | return -1; |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | void FileContents::dump(void) |
| 278 | { |