Cache DynamicProfileRuleS in the profileStore for reduced I/O
This commit is contained in:
parent
bc5a6fc7c3
commit
dd4fd82582
@ -229,9 +229,7 @@ bool storeDynamicProfileRules(const std::vector<DynamicProfileRule> &rules)
|
||||
PartialProfile *loadDynamicProfile(const ImageMetaData *im)
|
||||
{
|
||||
PartialProfile *ret = new PartialProfile(true, true);
|
||||
std::vector<DynamicProfileRule> rules;
|
||||
if (loadDynamicProfileRules(rules)) {
|
||||
for (auto &rule : rules) {
|
||||
for (auto &rule : profileStore.getDynamicProfileRules()) {
|
||||
if (rule.matches(im)) {
|
||||
printf("found matching profile %s\n",
|
||||
rule.profilepath.c_str());
|
||||
@ -244,6 +242,5 @@ PartialProfile *loadDynamicProfile(const ImageMetaData *im)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -308,13 +308,10 @@ DynamicProfilePanel::DynamicProfilePanel():
|
||||
|
||||
show_all_children();
|
||||
|
||||
std::vector<DynamicProfileRule> rules;
|
||||
if (loadDynamicProfileRules(rules)) {
|
||||
for (auto &r : rules) {
|
||||
for (auto &r : profileStore.getDynamicProfileRules()) {
|
||||
add_rule(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DynamicProfilePanel::update_rule(Gtk::TreeModel::Row row,
|
||||
@ -514,13 +511,15 @@ void DynamicProfilePanel::on_button_edit()
|
||||
|
||||
void DynamicProfilePanel::save()
|
||||
{
|
||||
std::vector<DynamicProfileRule> rules;
|
||||
auto &rules = profileStore.getDynamicProfileRules();
|
||||
rules.clear();
|
||||
int serial = 1;
|
||||
for (auto row : treemodel_->children()) {
|
||||
rules.emplace_back(to_rule(row, serial++));
|
||||
}
|
||||
if (!storeDynamicProfileRules(rules)) {
|
||||
printf("Error in saving dynamic profile rules\n");
|
||||
rules.clear();
|
||||
} else {
|
||||
printf("Saved %d dynamic profile rules\n", int(rules.size()));
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ bool ProfileStore::init ()
|
||||
storeState = STORESTATE_BEINGINITIALIZED;
|
||||
parseMutex = new MyMutex();
|
||||
_parseProfiles ();
|
||||
loadDynamicProfileRules(dynamicRules);
|
||||
storeState = STORESTATE_INITIALIZED;
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "threadutils.h"
|
||||
#include "paramsedited.h"
|
||||
#include "guiutils.h"
|
||||
#include "dynamicprofile.h"
|
||||
|
||||
|
||||
/** @brief This will implement callback functions for the ProfileStore
|
||||
@ -161,6 +162,9 @@ private:
|
||||
/** List of the client of this store */
|
||||
std::list<ProfileStoreListener*> listeners;
|
||||
|
||||
/** cache for dynamic profile rules */
|
||||
std::vector<DynamicProfileRule> dynamicRules;
|
||||
|
||||
/** @brief Method to recursively parse a profile folder with a level depth arbitrarily limited to 3
|
||||
*
|
||||
* @param realPath current full path of the scanned directory ; e.g.: ~/MyProfiles/
|
||||
@ -204,6 +208,11 @@ public:
|
||||
return internalDynamicEntry;
|
||||
}
|
||||
|
||||
std::vector<DynamicProfileRule> &getDynamicProfileRules()
|
||||
{
|
||||
return dynamicRules;
|
||||
}
|
||||
|
||||
void addListener(ProfileStoreListener *listener);
|
||||
void removeListener(ProfileStoreListener *listener);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user