hikyuu2/libs/hikyuu_python/trade_sys/_Environment.cpp

68 lines
1.9 KiB
C++
Raw Normal View History

2015-01-07 01:26:14 +08:00
/*
* _Environment.cpp
*
* Created on: 2013-3-2
* Author: fasiondog
*/
/*
* _TradeRecord.cpp
*
* Created on: 2013-2-25
* Author: fasiondog
*/
#include <boost/python.hpp>
#include <hikyuu/trade_sys/environment/EnvironmentBase.h>
using namespace boost::python;
using namespace hku;
class EnvironmentWrap: public EnvironmentBase, public wrapper<EnvironmentBase>{
public:
EnvironmentWrap(const string& name): EnvironmentBase(name) { }
2016-05-18 02:03:29 +08:00
void _reset() {
if (override func = get_override("_reset")) {
func();
}
EnvironmentBase::_reset();
2015-01-07 01:26:14 +08:00
}
2016-05-18 02:03:29 +08:00
void default_reset() {
this->EnvironmentBase::_reset();
2015-01-07 01:26:14 +08:00
}
EnvironmentPtr _clone() {
return this->get_override("_clone")();
}
2016-05-18 02:03:29 +08:00
void _calculate() {
this->get_override("_calculate")();
}
2015-01-07 01:26:14 +08:00
};
2016-05-16 01:45:01 +08:00
string (EnvironmentBase::*get_name)() const = &EnvironmentBase::name;
void (EnvironmentBase::*set_name)(const string&) = &EnvironmentBase::name;
2015-01-07 01:26:14 +08:00
void export_Environment() {
class_<EnvironmentWrap, boost::noncopyable>("EnvironmentBase", init<const string&>())
.def(self_ns::str(self))
2016-05-16 01:45:01 +08:00
.add_property("name", get_name, set_name)
.def("getParam", &EnvironmentBase::getParam<boost::any>)
.def("setParam", &EnvironmentBase::setParam<object>)
2016-05-18 02:03:29 +08:00
.def("setQuery", &EnvironmentBase::setQuery)
.def("getQuery", &EnvironmentBase::getQuery)
.def("isValid", &EnvironmentBase::isValid)
.def("_addValid", &EnvironmentBase::_addValid)
2015-01-07 01:26:14 +08:00
.def("reset", &EnvironmentBase::reset)
.def("clone", &EnvironmentBase::clone)
2016-05-18 02:03:29 +08:00
.def("_reset", &EnvironmentBase::_reset, &EnvironmentWrap::default_reset)
2015-01-07 01:26:14 +08:00
.def("_clone", pure_virtual(&EnvironmentBase::_clone))
2016-05-18 02:03:29 +08:00
.def("_calculate", pure_virtual(&EnvironmentBase::_calculate))
2015-01-07 01:26:14 +08:00
;
register_ptr_to_python<EnvironmentPtr>();
}