MeshLib Documentation
Loading...
Searching...
No Matches
MRRecentFilesStore.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRViewerFwd.h"
4#include "MRMesh/MRSignal.h"
5#include <string>
6#include <vector>
7#include <filesystem>
8
9namespace MR
10{
11
12using FileNamesStack = std::vector<std::filesystem::path>;
13
17{
18public:
19 RecentFilesStore() = default;
22 RecentFilesStore( std::string appName, int capacity = 10 ) :
23 appName_{std::move(appName)}, capacity_{capacity} {}
24
27 MRVIEWER_API void storeFile( const std::filesystem::path& file ) const;
28
30 MRVIEWER_API std::vector<std::filesystem::path> getStoredFiles() const;
31
33 int getCapacity() const { return capacity_; }
34
36 MRVIEWER_API boost::signals2::connection onUpdate( const boost::function<void( const FileNamesStack& files )> & slot, boost::signals2::connect_position position = boost::signals2::at_back );
37
38private:
39 std::string appName_;
40 int capacity_{5};
41 boost::signals2::signal<void( const FileNamesStack& files )> updateSignal_;
42};
43
44} //namespace MR
Definition MRRecentFilesStore.h:17
MRVIEWER_API boost::signals2::connection onUpdate(const boost::function< void(const FileNamesStack &files)> &slot, boost::signals2::connect_position position=boost::signals2::at_back)
Connects given slot to receive signal on every update of this store.
int getCapacity() const
Returns maximum size of recently opened files stack.
Definition MRRecentFilesStore.h:33
RecentFilesStore(std::string appName, int capacity=10)
Definition MRRecentFilesStore.h:22
MRVIEWER_API std::vector< std::filesystem::path > getStoredFiles() const
Returns filenames from storage.
MRVIEWER_API void storeFile(const std::filesystem::path &file) const
RecentFilesStore()=default
Definition MRCameraOrientationPlugin.h:8
std::vector< std::filesystem::path > FileNamesStack
Definition MRIOFilesMenuItems.h:14