ATLAS Offline Software
Loading...
Searching...
No Matches
VP1AvailEvents::Imp Class Reference
Collaboration diagram for VP1AvailEvents::Imp:

Classes

class  EventID

Public Member Functions

QString attemptGenerationOfTmpSubdir (const QString &preferredname, QString &cachevar)
void cleanupTmpLocalFiles ()

Static Public Member Functions

static EventID evtToID (const VP1EventFile &evt)

Public Attributes

VP1AvailEventstheclass
int timeCutForNew
QString tmpDir
int maxLocalFilesToKeep
QString tmpLocalFileDir
QString tmpActiveRetrievalDir
QList< EventIDhistoryOrdered
std::set< EventIDhistorySorted
QList< VP1EventFilelastAllLocal
QList< VP1EventFilelastFresh
std::map< QString, std::pair< QDateTime, QList< VP1EventFile > > > dircache

Detailed Description

Definition at line 27 of file VP1AvailEvents.cxx.

Member Function Documentation

◆ attemptGenerationOfTmpSubdir()

QString VP1AvailEvents::Imp::attemptGenerationOfTmpSubdir ( const QString & preferredname,
QString & cachevar )

Definition at line 248 of file VP1AvailEvents.cxx.

249{
250 if (!cachevar.isEmpty())
251 return cachevar=="bad"?"":cachevar;
252
253 QFileInfo fi(tmpDir);
254 if (!( fi.exists()&&fi.isDir())) {
255 theclass->message("Could not create subdir in "+tmpDir+", since it does not exists or is not a directory" );
256 cachevar="bad";
257 return "";
258 }
259 int i(0);
260 while (true) {
261 ++i;
262 QString dir = tmpDir+(tmpDir.endsWith("/")?"":"/")+preferredname+(i==1?QString(""):QString::number(i))+"/";
263 if (!QFile::exists(dir)) {
264 bool ok = QDir().mkdir(dir);
265 if (!ok) {
266 theclass->message("Could not create directory:: "+dir );
267 cachevar="bad";
268 return "";
269 }
270 cachevar = dir;
271 return dir;
272 }
273 }
274}
VP1AvailEvents * theclass
std::string number(const double &d, const std::string &s)
Definition utils.cxx:186

◆ cleanupTmpLocalFiles()

void VP1AvailEvents::Imp::cleanupTmpLocalFiles ( )

Definition at line 289 of file VP1AvailEvents.cxx.

290{
291 if (maxLocalFilesToKeep<=2)
292 return;
293 if (tmpLocalFileDir.isEmpty())
294 return;
295 QString dir = theclass->tmpLocalFileDir();
296 if (dir.isEmpty())
297 return;
298
299 QList<VP1EventFile> events = theclass->allLocalEvents();
300 int ntoremove = events.count()-maxLocalFilesToKeep;
301 if (ntoremove<=3)//3 instead of 0 to keep down the times we call the machinery below.
302 return;
303
304 //Rules of engagement:
305 //We never delete the current event. We never delete the previous
306 //event. We never delete the maxLocalFilesToKeep newest of the fresh
307 //events.
308
309 QList<Imp::EventID> protectedEvents;
310 if (!historyOrdered.isEmpty()) {
311 protectedEvents << historyOrdered.back();
312 if (historyOrdered.count()>1)
313 protectedEvents << historyOrdered.at(historyOrdered.count()-2);
314 }
315 QList<VP1EventFile> freshEvts = theclass->freshEvents();
316 int ifreshkept(0);
317 for (VP1EventFile evt : theclass->freshEvents()) {
318 protectedEvents << Imp::evtToID(evt);
319 if (++ifreshkept==maxLocalFilesToKeep)
320 break;
321 }
322
323 //Remove:
324 for (int i = events.count()-1; i>=0; --i ) {
325 if (protectedEvents.contains(Imp::evtToID(events.at(i)))) {
326 continue;
327 }
328 QFile::remove(events.at(i).fileName());
329 if (--ntoremove<=0)
330 break;
331 }
332 theclass->invalidateDirCache(theclass->tmpLocalFileDir());
333}
static EventID evtToID(const VP1EventFile &evt)
QList< EventID > historyOrdered

◆ evtToID()

EventID VP1AvailEvents::Imp::evtToID ( const VP1EventFile & evt)
inlinestatic

Definition at line 55 of file VP1AvailEvents.cxx.

55 {
56 return EventID(evt.runNumber(),evt.eventNumber());
57 }

Member Data Documentation

◆ dircache

std::map<QString,std::pair<QDateTime,QList<VP1EventFile> > > VP1AvailEvents::Imp::dircache

Definition at line 64 of file VP1AvailEvents.cxx.

◆ historyOrdered

QList<EventID> VP1AvailEvents::Imp::historyOrdered

Definition at line 59 of file VP1AvailEvents.cxx.

◆ historySorted

std::set<EventID> VP1AvailEvents::Imp::historySorted

Definition at line 60 of file VP1AvailEvents.cxx.

◆ lastAllLocal

QList<VP1EventFile> VP1AvailEvents::Imp::lastAllLocal

Definition at line 61 of file VP1AvailEvents.cxx.

◆ lastFresh

QList<VP1EventFile> VP1AvailEvents::Imp::lastFresh

Definition at line 62 of file VP1AvailEvents.cxx.

◆ maxLocalFilesToKeep

int VP1AvailEvents::Imp::maxLocalFilesToKeep

Definition at line 32 of file VP1AvailEvents.cxx.

◆ theclass

VP1AvailEvents* VP1AvailEvents::Imp::theclass

Definition at line 29 of file VP1AvailEvents.cxx.

◆ timeCutForNew

int VP1AvailEvents::Imp::timeCutForNew

Definition at line 30 of file VP1AvailEvents.cxx.

◆ tmpActiveRetrievalDir

QString VP1AvailEvents::Imp::tmpActiveRetrievalDir

Definition at line 35 of file VP1AvailEvents.cxx.

◆ tmpDir

QString VP1AvailEvents::Imp::tmpDir

Definition at line 31 of file VP1AvailEvents.cxx.

◆ tmpLocalFileDir

QString VP1AvailEvents::Imp::tmpLocalFileDir

Definition at line 34 of file VP1AvailEvents.cxx.


The documentation for this class was generated from the following file: