/* * _Selector.cpp * * Created on: 2016年3月28日 * Author: fasiondog */ #include #include #include "../_Parameter.h" #include "../pickle_support.h" using namespace boost::python; using namespace hku; class SelectorWrap : public SelectorBase, public wrapper { public: SelectorWrap() : SelectorBase() {} SelectorWrap(const string& name) : SelectorBase(name) {} virtual ~SelectorWrap() {} void _reset() { if (override func = this->get_override("_reset")) { func(); } else { SelectorBase::_reset(); } } void default_reset() { this->SelectorBase::_reset(); } SystemList getSelectedSystemList(Datetime date) { return this->get_override("get_selected_system_list")(date); } SelectorPtr _clone() { return this->get_override("_clone")(); } }; string (SelectorBase::*sb_get_name)() const = &SelectorBase::name; void (SelectorBase::*sb_set_name)(const string&) = &SelectorBase::name; SelectorPtr (*SE_Fixed_1)() = SE_Fixed; SelectorPtr (*SE_Fixed_2)(const StockList&, const SYSPtr&) = SE_Fixed; void export_Selector() { class_("SelectorBase", init<>()) .def(init()) .def(self_ns::str(self)) .def(self_ns::repr(self)) .add_property("name", sb_get_name, sb_set_name) .def("get_param", &SelectorBase::getParam) .def("set_param", &SelectorBase::setParam) .def("have_param", &SelectorBase::haveParam) .def("reset", &SelectorBase::reset) .def("clone", &SelectorBase::clone) .def("_reset", &SelectorBase::_reset, &SelectorWrap::default_reset) .def("_clone", pure_virtual(&SelectorBase::_clone)) .def("get_selected_system_list", pure_virtual(&SelectorBase::getSelectedSystemList)) .def("add_stock", &SelectorBase::addStock) //.def("add_stock_list", &SelectorBase::addStockList) // 在python中扩展 .def("clear", &SelectorBase::clear) #if HKU_PYTHON_SUPPORT_PICKLE .def_pickle(name_init_pickle_suite()) #endif ; register_ptr_to_python(); def("SE_Fixed", SE_Fixed_1); def("SE_Fixed", SE_Fixed_2); }