1 #include "searchtuner.h"
3 TunableSetting::TunableSetting(VarType _type, TunableParam _param) :
9 TunableSetting::TunableSetting(TunableParam _param) :
15 void TunableSetting::setDecision(int _low, int _high, int _default, int _selection) {
18 defaultValue = _default;
19 selectedValue = _selection;
22 unsigned int tunableSettingHash(TunableSetting *setting) {
23 return setting->hasVar ^ setting->type ^ setting->param;
26 bool tunableSettingEquals(TunableSetting *setting1, TunableSetting *setting2) {
27 return setting1->hasVar == setting2->hasVar &&
28 setting1->type == setting2->type &&
29 setting1->param == setting2->param;
32 SearchTuner::SearchTuner() {
35 SearchTuner::~SearchTuner() {
36 HSIteratorTunableSetting *iterator=settings.iterator();
37 while(iterator->hasNext()) {
38 TunableSetting *setting=iterator->next();
44 int SearchTuner::getTunable(TunableParam param, TunableDesc *descriptor) {
45 TunableSetting setting(param);
46 TunableSetting * result = usedSettings.get(&setting);
48 result = settings.get(&setting);
49 if ( result == NULL) {
50 result=new TunableSetting(param);
51 result->setDecision(descriptor->lowValue, descriptor->highValue, descriptor->defaultValue, descriptor->defaultValue);
54 usedSettings.add(result);
56 return result->selectedValue;
59 int SearchTuner::getVarTunable(VarType vartype, TunableParam param, TunableDesc *descriptor) {
60 TunableSetting setting(vartype, param);
61 TunableSetting * result = usedSettings.get(&setting);
63 result = settings.get(&setting);
64 if ( result == NULL) {
65 result=new TunableSetting(vartype, param);
66 result->setDecision(descriptor->lowValue, descriptor->highValue, descriptor->defaultValue, descriptor->defaultValue);
69 usedSettings.add(result);
71 return result->selectedValue;