Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
LRUFileManager.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2012-2021 Euclid Science Ground Segment
3 *
4 * This library is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 3.0 of the License, or (at your option)
7 * any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#ifndef POOLTESTS_LRUFILEMANAGER_H
20#define POOLTESTS_LRUFILEMANAGER_H
21
22#include "FileManager.h"
23
24namespace Euclid {
25namespace FilePool {
26
30class LRUFileManager final : public FileManager {
31public:
37 explicit LRUFileManager(unsigned limit = 500);
38 virtual ~LRUFileManager();
39
40 void notifyUsed(FileId id) override;
41
42 unsigned getLimit() const;
43 unsigned getUsed() const;
44 unsigned getAvailable() const;
45
46protected:
47 void notifyIntentToOpen(bool write) override;
48 void notifyOpenedFile(FileId id) override;
49 void notifyClosedFile(FileId id) override;
50
51private:
52 unsigned m_limit;
57};
58
59} // namespace FilePool
60} // namespace Euclid
61
62#endif // POOLTESTS_LRUFILEMANAGER_H
intptr_t FileId
Opaque FileId, its concrete type should only be assumed to be copyable and hashable.
Definition FileManager.h:65
std::map< FileId, std::list< FileId >::iterator > m_current_pos
std::list< FileId > m_sorted_ids
Sorted from less to more recent.
void notifyClosedFile(FileId id) override
void notifyUsed(FileId id) override
void notifyOpenedFile(FileId id) override
void notifyIntentToOpen(bool write) override