-
Notifications
You must be signed in to change notification settings - Fork 0
/
TA_Lib.inl
77 lines (60 loc) · 1.75 KB
/
TA_Lib.inl
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
namespace TA
{
template<typename T>
AbsOut<T> Lib::CallFunc(const std::string& name, int start_idx, int end_idx, const AbsBaseParam* const args, ...)
{
va_list args_ptr;
va_start(args_ptr, end_idx);
std::vector<const AbsBaseParam* const> v_args;
for (int i = 0;; ++i)
{
const AbsBaseParam* const _arg = va_arg(args_ptr, const AbsBaseParam* const);
if (_arg == nullptr)
{
break;
}
v_args.push_back(_arg);
}
va_end(args_ptr);
return _call_func<T>(name.c_str(), start_idx, end_idx, v_args);
}
template<typename T>
AbsOut<T> Lib::_call_func(const char* name, int start_idx, int end_idx, const std::vector<const AbsBaseParam* const>& v_args)
{
TA_ParamHolder *params = nullptr;
try
{
TA_RetCode retCode = TA_SUCCESS;
const TA_FuncHandle *handle = nullptr;
const TA_FuncInfo *theInfo = nullptr;
retCode = TA_GetFuncHandle(name, &handle);
_handle_error(retCode);
retCode = TA_GetFuncInfo(handle, &theInfo);
_handle_error(retCode);
retCode = TA_ParamHolderAlloc(handle, ¶ms);
_handle_error(retCode);
//todo logic;
int s_params_idx = 0;
_full_input_params(params, theInfo, s_params_idx, v_args);
s_params_idx += theInfo->nbInput;
_full_opt_input_params(params, theInfo, s_params_idx, v_args);
s_params_idx += theInfo->nbOptInput;
AbsOut<T> out(end_idx - start_idx + 1);
_full_output_params(params, theInfo, v_args, out);
retCode = TA_CallFunc(params, start_idx, end_idx, out.begin_ptr(), out.nb_element_ptr());
_handle_error(retCode);
TA_ParamHolderFree(params);
return std::move(out);
}
catch (const Exception& e)
{
if (params)
{
TA_ParamHolderFree(params);
}
e.rethrow();
}
//to eliminate compile warning!
throw LogicException("");
}
}