6 #ifndef TURI_CAPI_WRAPPER_STRUCTS_HPP_ 7 #define TURI_CAPI_WRAPPER_STRUCTS_HPP_ 9 #include <capi/TuriCreate.h> 10 #include <model_server/lib/variant.hpp> 11 #include <model_server/lib/variant_converter.hpp> 12 #include <core/data/flexible_type/flexible_type.hpp> 13 #include <model_server/lib/extensions/model_base.hpp> 14 #include <core/data/sframe/gl_sarray.hpp> 15 #include <core/data/sframe/gl_sframe.hpp> 18 struct capi_struct_type_info {
19 virtual const char* name()
const = 0;
20 virtual void free(
const void* v) = 0;
33 #define DECLARE_CAPI_WRAPPER_STRUCT(struct_name, wrapping_type) \ 34 struct capi_struct_type_info_##struct_name; \ 37 extern capi_struct_type_info_##struct_name \ 38 capi_struct_type_info_##struct_name##_inst; \ 42 struct struct_name##_struct { \ 43 capi_struct_type_info* type_info = nullptr; \ 44 wrapping_type value; \ 47 typedef struct struct_name##_struct struct_name; \ 50 struct capi_struct_type_info_##struct_name : public capi_struct_type_info { \ 51 const char* name() const { return #struct_name; } \ 52 void free(const void* v) { \ 53 if (UNLIKELY(v == nullptr)) { \ 56 const struct_name* vv = static_cast<const struct_name*>(v); \ 57 ASSERT_TRUE(vv->type_info == this); \ 58 ASSERT_TRUE(this == &(capi_struct_type_info_##struct_name##_inst)); \ 63 static inline struct_name* new_##struct_name() { \ 64 struct_name* ret = new struct_name##_struct(); \ 65 ret->type_info = &(capi_struct_type_info_##struct_name##_inst); \ 69 template <typename... Args> \ 70 static inline struct_name* new_##struct_name(Args&&... args) { \ 71 struct_name* ret = new_##struct_name(); \ 72 ret->value = wrapping_type(std::forward<Args>(args)...); \ 76 typedef std::map<std::string, turi::aggregate::groupby_descriptor_type> groupby_aggregator_map_type;
78 DECLARE_CAPI_WRAPPER_STRUCT(tc_error, std::string);
85 DECLARE_CAPI_WRAPPER_STRUCT(tc_flex_enum_list, std::vector<turi::flex_type_enum>);
89 DECLARE_CAPI_WRAPPER_STRUCT(tc_parameters, turi::variant_map_type);
90 DECLARE_CAPI_WRAPPER_STRUCT(tc_model, std::shared_ptr<turi::model_base>);
91 DECLARE_CAPI_WRAPPER_STRUCT(tc_groupby_aggregator, groupby_aggregator_map_type);
92 DECLARE_CAPI_WRAPPER_STRUCT(tc_plot, std::shared_ptr<turi::visualization::Plot>);
boost::make_recursive_variant< flexible_type, std::shared_ptr< unity_sgraph_base >, dataframe_t, std::shared_ptr< model_base >, std::shared_ptr< unity_sframe_base >, std::shared_ptr< unity_sarray_base >, std::map< std::string, boost::recursive_variant_ >, std::vector< boost::recursive_variant_ >, boost::recursive_wrapper< function_closure_info > >::type variant_type
std::vector< std::pair< flexible_type, flexible_type > > flex_dict
std::vector< flexible_type > flex_list