Skip to content
Snippets Groups Projects
Commit 65e2d47d authored by Bas van der Tol's avatar Bas van der Tol
Browse files

Add sdp_element to ska-sdp-func-bindings

parent 56b8997e
Branches
Tags
1 merge request!313AST-1325 Add ska-sdp-func bindings
Pipeline #63078 passed with warnings
# Copyright (C) 2023 ASTRON (Netherlands Institute for Radio Astronomy)
# SPDX-License-Identifier: GPL-3.0-or-later
add_library(ska-sdp-func-everybeam OBJECT skasdpfunceverybeam.cc
add_library(ska-sdp-func-everybeam OBJECT sdp_element.cc skasdpfunceverybeam.cc
skasdpfuncelementresponse.cc)
# The ska-sdp-func-everybeam object library is included in the SHARED library everybeam
......@@ -11,7 +11,8 @@ set_property(TARGET ska-sdp-func-everybeam PROPERTY POSITION_INDEPENDENT_CODE
target_link_libraries(ska-sdp-func-everybeam ska-sdp-func::ska-sdp-func xtensor)
install(FILES skasdpfunceverybeam.h DESTINATION "include/${CMAKE_PROJECT_NAME}")
install(FILES skasdpfunceverybeam.h sdp_element.h
DESTINATION "include/${CMAKE_PROJECT_NAME}")
add_executable(tbindings tbindings.cc)
target_link_libraries(tbindings everybeam ska-sdp-func::ska-sdp-func)
#include "sdp_element.h"
#include <map>
#include <string>
namespace {
std::map<std::string,
std::tuple<make_function_t, destroy_function_t, evaluate_function_t>>&
get_sdp_element_function_map() {
static std::map<std::string, std::tuple<make_function_t, destroy_function_t,
evaluate_function_t>>
function_map;
return function_map;
}
} // namespace
int sdp_register_element(const char* name, const make_function_t make_function,
const destroy_function_t destroy_function,
const evaluate_function_t evaluate_function) {
std::map<std::string, std::tuple<make_function_t, destroy_function_t,
evaluate_function_t>>& function_map =
get_sdp_element_function_map();
function_map[name] =
std::make_tuple(make_function, destroy_function, evaluate_function);
return 0;
}
sdp_Error sdp_get_element_functions(const char* name,
make_function_t& make_function,
destroy_function_t& destroy_function,
evaluate_function_t& evaluate_function) {
std::map<std::string, std::tuple<make_function_t, destroy_function_t,
evaluate_function_t>>& function_map =
get_sdp_element_function_map();
if (!function_map.count(name)) return SDP_ERR_INVALID_ARGUMENT;
std::tie(make_function, destroy_function, evaluate_function) =
function_map[name];
return SDP_SUCCESS;
}
#include <ska-sdp-func/utility/sdp_errors.h>
#include <ska-sdp-func/utility/sdp_mem.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef void* sdp_element_t;
typedef sdp_element_t (*make_function_t)(const char* name);
typedef void (*destroy_function_t)(sdp_element_t element_response);
typedef void (*evaluate_function_t)(sdp_element_t element_response,
int num_points, const sdp_Mem* theta,
const sdp_Mem* phi, sdp_Mem* response);
[[gnu::visibility("default")]] int sdp_register_element(
const char* name, const make_function_t make_function,
const destroy_function_t destroy_function,
const evaluate_function_t evaluate_function);
[[gnu::visibility("default")]] sdp_Error sdp_get_element_functions(
const char* name, make_function_t& make_function,
destroy_function_t& destroy_function,
evaluate_function_t& evaluate_function);
#ifdef __cplusplus
}
#endif
......@@ -8,7 +8,7 @@
#include <memory>
#include <ska-sdp-func/station_beam/sdp_element.h>
#include "sdp_element.h"
namespace everybeam {
......
#include <ska-sdp-func/station_beam/sdp_element.h>
#include "sdp_element.h"
#ifdef __cplusplus
extern "C" {
......
#include "ska-sdp-func/station_beam/sdp_element.h"
#include "sdp_element.h"
#include <complex>
#include <dlfcn.h>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment