Suppose I have tons of file names in my_dir/my_subdir, formatted in some way:
data11_7TeV.00179691.physics_Egamma.merge.NTUP_PHOTON.f360_m796_p541_tid319627_00
data11_7TeV.00180400.physics_Egamma.merge.NTUP_PHOTON.f369_m812_p541_tid334757_00
data11_7TeV.00178109.physics_Egamma.merge.D2AOD_DIPHO.f351_m765_p539_p540_tid312017_00
For example, data11_7TeVthis is data_type, 00179691start number, NTUP_PHOTONdata format.
I want to write an interface to do something like this:
dataset = DataManager("my_dir/my_subdir").filter_type("data11_7TeV").filter_run("> 00179691").filter_tag("m = 796");
cout << dataset.count();
vector<string> dataset_list = dataset.get_list();
dataset.save_filter("file.txt", "ALIAS");
dataset2 = DataManagerAlias("file.txt", "ALIAS");
cout << dataset2.filter_tag("p = 123").count();
I need lazy behavior, for example, no valid filtering should be performed before any actions like countor get_list. I do not want to repeat the filtering if it is already done. I'm just learning something about a design template, and I think I can use:
- abstract base class
AbstractFilterthat implements methodsfilter* - factory to solve from the called method that decorator uses
- ,
filter *, , :
AbstractFilter::filter_run(string arg) {
decorator = factory.get_decorator_run(arg); // if arg is "> 00179691" returns FilterRunGreater(00179691)
return decorator(this);
}
jQuery, .
- ? , ? , , .