-
Notifications
You must be signed in to change notification settings - Fork 556
/
_IndicatorImp.cpp
116 lines (98 loc) · 3.77 KB
/
_IndicatorImp.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
* _IndicatorImp.cpp
*
* Created on: 2013-2-13
* Author: fasiondog
*/
#include <boost/python.hpp>
#include <hikyuu/indicator/Indicator.h>
#include "../_Parameter.h"
#include "../pickle_support.h"
using namespace boost::python;
using namespace hku;
class IndicatorImpWrap: public IndicatorImp, public wrapper<IndicatorImp> {
public:
IndicatorImpWrap(): IndicatorImp() {}
IndicatorImpWrap(const string& name): IndicatorImp(name) {}
IndicatorImpWrap(const string& name, size_t result_num):
IndicatorImp(name, result_num) {}
IndicatorImpPtr operator()(const Indicator& ind) {
if (override call = get_override("__call__")) {
return call(ind);
}
return IndicatorImp::operator()(ind);
}
IndicatorImpPtr default_call(const Indicator& ind) {
return this->IndicatorImp::operator()(ind);
}
void _calculate(const Indicator& ind) {
if (override call = get_override("_calculate")) {
call(ind);
} else {
IndicatorImp::_calculate(ind);
}
}
void default_calculate(const Indicator& ind) {
this->IndicatorImp::_calculate(ind);
}
bool check() {
if (override call = get_override("check")) {
return call();
} else {
return IndicatorImp::check();
}
}
bool default_check() {
return this->IndicatorImp::check();
}
IndicatorImpPtr _clone() {
if (override call = get_override("_clone")) {
return call();
} else {
return IndicatorImp::_clone();
}
}
IndicatorImpPtr default_clone() {
return this->IndicatorImp::_clone();
}
bool isNeedContext() const {
if (override call = get_override("isNeedContext")) {
return call();
} else {
return IndicatorImp::isNeedContext();
}
}
bool default_isNeedContext() const {
return this->IndicatorImp::isNeedContext();
}
};
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(_set_overloads, _set, 2, 3)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(_append_overloads, _append, 1, 2)
string (IndicatorImp::*read_name)() const = &IndicatorImp::name;
void (IndicatorImp::*write_name)(const string&) = &IndicatorImp::name;
void export_IndicatorImp() {
class_<IndicatorImpWrap, boost::noncopyable>("IndicatorImp", init<>())
.def(init<const string&>())
.def(init<const string&, size_t>())
.def(self_ns::str(self))
.add_property("name", read_name, write_name)
.add_property("discard", &IndicatorImp::discard)
.def("getParameter", &IndicatorImp::getParameter,
return_value_policy<copy_const_reference>())
.def("getParam", &IndicatorImp::getParam<boost::any>)
.def("setParam", &IndicatorImp::setParam<object>)
.def("setDiscard", &IndicatorImp::setDiscard)
.def("_set", &IndicatorImp::_set, _set_overloads())
.def("_readyBuffer", &IndicatorImp::_readyBuffer)
.def("getResultNumber", &IndicatorImp::getResultNumber)
.def("getResultAsPriceList", &IndicatorImp::getResultAsPriceList)
.def("calculate", &IndicatorImp::calculate)
.def("check", &IndicatorImp::check, &IndicatorImpWrap::default_check)
.def("clone", &IndicatorImp::clone)
.def("_calculate", &IndicatorImp::_calculate, &IndicatorImpWrap::default_calculate)
.def("__call__", &IndicatorImp::operator(), &IndicatorImpWrap::default_call)
.def("_clone", &IndicatorImp::_clone, &IndicatorImpWrap::default_clone)
.def("isNeedContext", &IndicatorImp::isNeedContext, &IndicatorImpWrap::default_isNeedContext)
;
register_ptr_to_python<IndicatorImpPtr>();
}