9741fb3f5c
- OpenFileList has a simpler interface
50 lines
1.0 KiB
C++
50 lines
1.0 KiB
C++
#pragma once
|
|
#ifndef FSPP_IMPL_FUSEOPENFILELIST_H_
|
|
#define FSPP_IMPL_FUSEOPENFILELIST_H_
|
|
|
|
#include "../fs_interface/File.h"
|
|
#include "../fs_interface/OpenFile.h"
|
|
#include "messmer/cpp-utils/macros.h"
|
|
#include "IdList.h"
|
|
|
|
namespace fspp {
|
|
|
|
class FuseOpenFileList {
|
|
public:
|
|
FuseOpenFileList();
|
|
virtual ~FuseOpenFileList();
|
|
|
|
int open(std::unique_ptr<OpenFile> file);
|
|
OpenFile *get(int descriptor);
|
|
void close(int descriptor);
|
|
|
|
private:
|
|
IdList<OpenFile> _open_files;
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(FuseOpenFileList);
|
|
};
|
|
|
|
inline FuseOpenFileList::FuseOpenFileList()
|
|
:_open_files() {
|
|
}
|
|
|
|
inline FuseOpenFileList::~FuseOpenFileList() {
|
|
}
|
|
|
|
inline int FuseOpenFileList::open(std::unique_ptr<OpenFile> file) {
|
|
return _open_files.add(std::move(file));
|
|
}
|
|
|
|
inline OpenFile *FuseOpenFileList::get(int descriptor) {
|
|
return _open_files.get(descriptor);
|
|
}
|
|
|
|
inline void FuseOpenFileList::close(int descriptor) {
|
|
//The destructor of the stored FuseOpenFile closes the file
|
|
_open_files.remove(descriptor);
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* FSPP_IMPL_FUSEOPENFILELIST_H_ */
|