@@ -18,27 +18,24 @@ int main(int argc, char **argv)
1818 using factory_base_type = xp::xfactory_base<base_type>;
1919 using plugin_registry_type = xp::xplugin_registry<factory_base_type>;
2020
21- plugin_registry_type registry;
22- registry.add_from_directory (plugin_directory);
21+ plugin_registry_type registry (plugin_directory);
2322
2423 std::cout << " available plugins:" << std::endl;
25- for (auto & p : registry. plugin_names () )
24+ for (auto p : registry)
2625 {
27- std::cout << p << std::endl;
26+ std::cout << p. first << std::endl;
2827 }
2928
3029 // create data to accumulate
3130 std::vector<double > data = {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 };
3231
3332 // create and use plugin_accumulator_max
34- auto factory_max = registry.create_factory (" plugin_accumulator_max" );
35- auto acc_max = factory_max->create ();
33+ auto acc_max = registry[" plugin_accumulator_max" ]->create ();
3634 auto result_max = acc_max->accumulate (data);
3735 std::cout << " accumulator " << acc_max->name () << " result: " << result_max << std::endl;
3836
3937 // create and use plugin_accumulator_min
40- auto factory_min = registry.create_factory (" plugin_accumulator_min" );
41- auto acc_min = factory_min->create ();
38+ auto acc_min = registry[" plugin_accumulator_min" ]->create ();
4239 auto result_min = acc_min->accumulate (data);
4340 std::cout << " accumulator " << acc_min->name () << " result: " << result_min << std::endl;
4441}
0 commit comments