From 0ba3ad56420ed8bc5353905d48b7c1f73461438f Mon Sep 17 00:00:00 2001 From: sdixon Date: Tue, 16 Sep 2025 17:26:10 +0100 Subject: [PATCH 01/15] removing caching and adding feature to return time instead of data from a uda signal --- mapping_plugin/src/uda_data_source.cpp | 192 ++++++++++++++++--------- 1 file changed, 124 insertions(+), 68 deletions(-) diff --git a/mapping_plugin/src/uda_data_source.cpp b/mapping_plugin/src/uda_data_source.cpp index 128bfe2..d57289f 100644 --- a/mapping_plugin/src/uda_data_source.cpp +++ b/mapping_plugin/src/uda_data_source.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include "map_types/data_source_mapping.hpp" #include "map_types/map_arguments.hpp" @@ -89,79 +90,38 @@ int json_plugin::UDADataSource::call_plugins(DATA_BLOCK* data_block, const libto return err; } // Return 1 if no request receieved - /* - * - * generate subset info then remove subset syntax from - * request string - * - */ - REQUEST_DATA request = {0}; strcpy(request.signal, request_str.c_str()); ENVIRONMENT* environment = getIdamClientEnvironment(); makeRequestData(&request, *m_plugin_list, environment); - // if (m_cache_enabled) { - // std::string key_found = ram_cache->has_entry(request_str) ? "True" : "False"; - // ram_cache->log(libtokamap:LogLevel::DEBUG, "key, \"" + request_str + "\" in cache? " + key_found); - // } - - /* - * - * CACHING GOES HERE - * - */ - - // check cache for request string and only get data if it's not already there - // currently copies whole datablock (data, error, and dims) - // if (m_cache_enabled) { - // ram_cache->log(libtokamap::LogLevel::DEBUG, "caching disabled"); - // } - - bool cache_hit = false; - if (m_cache_enabled && ram_cache != nullptr) { - cache_hit = json_plugin::copy_from_cache(*ram_cache, request_str, data_block); - } - if (cache_hit) { - // ram_cache->log(libtokamap:LogLevel::INFO, "Adding cached datablock onto plugin_interface"); - // ram_cache->log(libtokamap:LogLevel::INFO, - // "data on plugin_interface (data_n): " + std::to_string(data_block->data_n)); - err = 0; - } else { - IDAM_PLUGIN_INTERFACE interface = {0}; - CLIENT_BLOCK client_block; - DATA_SOURCE data_source; - SIGNAL_DESC signal_desc; - initClientBlock(&client_block, 0, ""); - initDataSource(&data_source); - initSignalDesc(&signal_desc); - - interface.request_data = &request; - interface.pluginList = m_plugin_list; - interface.data_block = data_block; - interface.environment = environment; - interface.client_block = &client_block; - interface.data_source = &data_source; - interface.signal_desc = &signal_desc; - - err = callPlugin(m_plugin_list, request_str.c_str(), &interface); - - if (err != 0) { - // add check of int udaNumErrors() and if more than one, don't wipe - // 220 situation when UDA tries to get data and cannot find it - if (err == 220) { - closeUdaError(); - } - return err; - } // return code if failure, no need to proceed + IDAM_PLUGIN_INTERFACE interface = {0}; + CLIENT_BLOCK client_block; + DATA_SOURCE data_source; + SIGNAL_DESC signal_desc; + initClientBlock(&client_block, 0, ""); + initDataSource(&data_source); + initSignalDesc(&signal_desc); + + interface.request_data = &request; + interface.pluginList = m_plugin_list; + interface.data_block = data_block; + interface.environment = environment; + interface.client_block = &client_block; + interface.data_source = &data_source; + interface.signal_desc = &signal_desc; - // Add retrieved datablock to cache. data is copied from datablock into a new libtokamap:data_entry. original - // data remains on block (on plugin_interface structure) for return. - if (m_cache_enabled && ram_cache != nullptr) { - json_plugin::copy_to_cache(*ram_cache, request_str, data_block); + err = callPlugin(m_plugin_list, request_str.c_str(), &interface); + + if (err != 0) { + // add check of int udaNumErrors() and if more than one, don't wipe + // 220 situation when UDA tries to get data and cannot find it + if (err == 220) { + closeUdaError(); } - } + return err; + } // return code if failure, no need to proceed return err; } @@ -174,10 +134,106 @@ libtokamap::TypedDataArray set_return_data(DataBlock& data_block, size_t size, s auto array = libtokamap::TypedDataArray{reinterpret_cast(data_block.data), size, std::move(shape), false}; // we set the data_block.data to nullptr to avoid double deletion data_block.data = nullptr; + freeDataBlock(&data_block); return array; } + +void expand_compressed_dim(DIMS& dim) +{ + if (dim.compressed == 0) + { + return; + } + uncompressDim(&dim); + dim.compressed = 0; + dim.method = 0; + if (dim.sams != nullptr) { + free(dim.sams); + dim.sams = nullptr; + } + if (dim.offs != nullptr) { + free(dim.offs); + dim.offs = nullptr; + } + if (dim.ints != nullptr) { + free(dim.ints); + dim.ints = nullptr; + } + dim.udoms = 0; +} + +void free_all_dims(DATA_BLOCK& data_block) +{ + if (data_block.dims == nullptr) { + return; + } + + for (unsigned int i = 0; i= data_block.rank){ + throw std::runtime_error{"dimension index requested is out-of-bounds"}; + } + if(data_block.dims == nullptr or data_block.dims[index].dim == nullptr){ + throw std::runtime_error{"No dimension data exists for index requested"}; + } + + // just free the previous data for now + // can alter behaviour if we need to add caching later + if (data_block.data != nullptr){ + free(data_block.data); + data_block.data = nullptr; + } + + // copy dim data onto data_block + auto dim = data_block.dims[index]; + expand_compressed_dim(dim); + data_block.data = dim.dim; + dim.dim = nullptr; + data_block.data_n = dim.dim_n; + data_block.data_type = dim.data_type; + + // avoid any confusion during later cleaup + free_all_dims(data_block); + + // "get" function just returns the data array to the calling scope + // no need to add compressed dims and set rank to 1 for normal return + // of this data_block. +} + +void replace_data_with_time(DATA_BLOCK& data_block) +{ + if (data_block.order < 0){ + throw std::runtime_error{"No time data exists on datablack where requested"}; + } + if (data_block.order >= data_block.rank){ + throw std::runtime_error{"corrupt datablock. time index is out-of-bounds"}; + } + + replace_data_with_dim(data_block, data_block.order); +} + } // namespace + libtokamap::TypedDataArray json_plugin::UDADataSource::get(const libtokamap::DataSourceArgs& data_source_args, const libtokamap::MapArguments& arguments, libtokamap::RamCache* ram_cache) @@ -189,9 +245,8 @@ libtokamap::TypedDataArray json_plugin::UDADataSource::get(const libtokamap::Dat return {}; } - // temporary solution to the slice functionality returning arrays of 1 element - if (data_block.rank == 1 && data_block.data_n == 1) { - data_block.rank = 0; + if (data_source_args.count("time") != 0 && data_source_args.at("time").get()){ + replace_data_with_time(data_block); } size_t size = data_block.data_n; @@ -200,6 +255,7 @@ libtokamap::TypedDataArray json_plugin::UDADataSource::get(const libtokamap::Dat shape[i] = data_block.dims[i].dim_n; } + //note set_return_data destroys the data_block after moving the data out of it switch (data_block.data_type) { case UDA_TYPE_INT: return set_return_data(data_block, size, std::move(shape)); From 3c9c16b41721699341351865910a4a7df18fb058 Mon Sep 17 00:00:00 2001 From: sdixon Date: Thu, 18 Sep 2025 00:27:16 +0100 Subject: [PATCH 02/15] fixing set-return-time --- mapping_plugin/src/uda_data_source.cpp | 109 +++++++++---------------- 1 file changed, 40 insertions(+), 69 deletions(-) diff --git a/mapping_plugin/src/uda_data_source.cpp b/mapping_plugin/src/uda_data_source.cpp index d57289f..1b91922 100644 --- a/mapping_plugin/src/uda_data_source.cpp +++ b/mapping_plugin/src/uda_data_source.cpp @@ -49,7 +49,15 @@ std::string json_plugin::UDADataSource::get_request_str(const libtokamap::DataSo const libtokamap::MapArguments& arguments) const { std::stringstream string_stream; - string_stream << m_plugin_name << "::" << m_function.value_or("get") << "("; + // string_stream << m_plugin_name << "::" << m_function.value_or("get") << "("; + string_stream << m_plugin_name << "::"; + + if ( data_source_args.count("function") != 0 ) { + string_stream << data_source_args.at("function").get(); + } else { + string_stream << m_function.value_or("get"); + } + string_stream << "("; // m_map_args 'field' currently nlohmann json // parse to string/bool @@ -134,7 +142,21 @@ libtokamap::TypedDataArray set_return_data(DataBlock& data_block, size_t size, s auto array = libtokamap::TypedDataArray{reinterpret_cast(data_block.data), size, std::move(shape), false}; // we set the data_block.data to nullptr to avoid double deletion data_block.data = nullptr; - freeDataBlock(&data_block); + + // I think typically this datablock is just a shallow copy from the client-cached datablock list + // so will be cleaned up anyway later + // freeDataBlock(&data_block); + return array; +} + +template +libtokamap::TypedDataArray set_return_dim(DataBlock& data_block, size_t index) +{ + auto dim = data_block.dims[index]; + size_t size = dim.dim_n; + auto array = libtokamap::TypedDataArray{reinterpret_cast(dim.dim), size, {size}, false}; + // we set the data_block.data to nullptr to avoid double deletion + dim.dim = nullptr; return array; } @@ -162,78 +184,27 @@ void expand_compressed_dim(DIMS& dim) dim.udoms = 0; } -void free_all_dims(DATA_BLOCK& data_block) +libtokamap::TypedDataArray set_return_time(DataBlock& data_block) { - if (data_block.dims == nullptr) { - return; - } - - for (unsigned int i = 0; i= data_block.rank){ - throw std::runtime_error{"dimension index requested is out-of-bounds"}; - } - if(data_block.dims == nullptr or data_block.dims[index].dim == nullptr){ - throw std::runtime_error{"No dimension data exists for index requested"}; - } - - // just free the previous data for now - // can alter behaviour if we need to add caching later - if (data_block.data != nullptr){ - free(data_block.data); - data_block.data = nullptr; - } - - // copy dim data onto data_block - auto dim = data_block.dims[index]; + size_t index = data_block.order; + auto dim = data_block.dims[index]; expand_compressed_dim(dim); - data_block.data = dim.dim; - dim.dim = nullptr; - data_block.data_n = dim.dim_n; - data_block.data_type = dim.data_type; - - // avoid any confusion during later cleaup - free_all_dims(data_block); - - // "get" function just returns the data array to the calling scope - // no need to add compressed dims and set rank to 1 for normal return - // of this data_block. -} - -void replace_data_with_time(DATA_BLOCK& data_block) -{ - if (data_block.order < 0){ - throw std::runtime_error{"No time data exists on datablack where requested"}; - } - if (data_block.order >= data_block.rank){ - throw std::runtime_error{"corrupt datablock. time index is out-of-bounds"}; + switch (dim.data_type) { + case UDA_TYPE_INT: + return set_return_dim(data_block, index); + case UDA_TYPE_FLOAT: + return set_return_dim(data_block, index); + case UDA_TYPE_DOUBLE: + return set_return_dim(data_block, index); + case UDA_TYPE_STRING: + return set_return_dim(data_block, index); + default: + throw std::runtime_error{"unknown data type"}; } - - replace_data_with_dim(data_block, data_block.order); } } // namespace - libtokamap::TypedDataArray json_plugin::UDADataSource::get(const libtokamap::DataSourceArgs& data_source_args, const libtokamap::MapArguments& arguments, libtokamap::RamCache* ram_cache) @@ -246,11 +217,11 @@ libtokamap::TypedDataArray json_plugin::UDADataSource::get(const libtokamap::Dat } if (data_source_args.count("time") != 0 && data_source_args.at("time").get()){ - replace_data_with_time(data_block); + return set_return_time(data_block); } size_t size = data_block.data_n; - std::vector shape(data_block.rank); + std::vector shape{data_block.rank}; for (int i = 0; i < data_block.rank; ++i) { shape[i] = data_block.dims[i].dim_n; } From de2bd87971c57608bac7565392c6210e99de81db Mon Sep 17 00:00:00 2001 From: sdixon Date: Thu, 18 Sep 2025 22:29:39 +0100 Subject: [PATCH 03/15] changing set-return semantics in uda_data_source.cpp --- mapping_plugin/src/uda_data_source.cpp | 213 +++++++++++++++---------- 1 file changed, 129 insertions(+), 84 deletions(-) diff --git a/mapping_plugin/src/uda_data_source.cpp b/mapping_plugin/src/uda_data_source.cpp index 1b91922..47ea382 100644 --- a/mapping_plugin/src/uda_data_source.cpp +++ b/mapping_plugin/src/uda_data_source.cpp @@ -136,73 +136,132 @@ int json_plugin::UDADataSource::call_plugins(DATA_BLOCK* data_block, const libto namespace { -template -libtokamap::TypedDataArray set_return_data(DataBlock& data_block, size_t size, std::vector&& shape) -{ - auto array = libtokamap::TypedDataArray{reinterpret_cast(data_block.data), size, std::move(shape), false}; - // we set the data_block.data to nullptr to avoid double deletion - data_block.data = nullptr; - - // I think typically this datablock is just a shallow copy from the client-cached datablock list - // so will be cleaned up anyway later - // freeDataBlock(&data_block); - return array; -} + class ArrayBuilder + { + private: + const char* m_data = nullptr; + size_t m_size = {}; + std::vector m_shape; + int m_data_type = UDA_TYPE_UNKNOWN; + bool m_owning = true; + bool m_ownership_locked = false; + bool m_buildable = false; + bool m_free_data_required = false; -template -libtokamap::TypedDataArray set_return_dim(DataBlock& data_block, size_t index) -{ - auto dim = data_block.dims[index]; - size_t size = dim.dim_n; - auto array = libtokamap::TypedDataArray{reinterpret_cast(dim.dim), size, {size}, false}; - // we set the data_block.data to nullptr to avoid double deletion - dim.dim = nullptr; - return array; -} + public: + ArrayBuilder() = default; + ~ArrayBuilder() + { + if (m_free_data_required and m_data != nullptr) { + free(const_cast(m_data)); + } + } -void expand_compressed_dim(DIMS& dim) -{ - if (dim.compressed == 0) - { - return; - } - uncompressDim(&dim); - dim.compressed = 0; - dim.method = 0; - if (dim.sams != nullptr) { - free(dim.sams); - dim.sams = nullptr; - } - if (dim.offs != nullptr) { - free(dim.offs); - dim.offs = nullptr; - } - if (dim.ints != nullptr) { - free(dim.ints); - dim.ints = nullptr; - } - dim.udoms = 0; -} + ArrayBuilder(const ArrayBuilder&) = delete; + ArrayBuilder& operator=(const ArrayBuilder&) = delete; + ArrayBuilder(ArrayBuilder&& other) = delete; + ArrayBuilder& operator=(ArrayBuilder&& other) = delete; + + enum class OwnershipPolicy + { + VIEW, + COPY + }; + + void set_ownership(OwnershipPolicy policy) + { + bool is_owning = (policy == OwnershipPolicy::COPY); + if (m_ownership_locked and m_owning != is_owning) { + throw std::runtime_error("Ownership policy already enforced by a previous option"); + } + m_owning = is_owning; + } + ArrayBuilder& ownership(OwnershipPolicy policy) + { + set_ownership(policy); + return *this; + } -libtokamap::TypedDataArray set_return_time(DataBlock& data_block) -{ - size_t index = data_block.order; - auto dim = data_block.dims[index]; - expand_compressed_dim(dim); - switch (dim.data_type) { - case UDA_TYPE_INT: - return set_return_dim(data_block, index); - case UDA_TYPE_FLOAT: - return set_return_dim(data_block, index); - case UDA_TYPE_DOUBLE: - return set_return_dim(data_block, index); - case UDA_TYPE_STRING: - return set_return_dim(data_block, index); - default: - throw std::runtime_error{"unknown data type"}; - } -} + void set_data(const DATA_BLOCK& db) + { + m_data = db.data; + m_size = db.data_n; + m_shape.reserve(db.rank); + for (int i = 0; i < db.rank; ++i) { + m_shape[i] = db.dims[i].dim_n; + } + m_data_type = db.data_type; + m_buildable = true; + } + ArrayBuilder& data(const DATA_BLOCK& db) + { + set_data(db); + return *this; + } + + void set_dimension_data(const DIMS& dim) + { + if (dim.compressed > 0) { + DIMS tmp_dim = dim; + + uncompressDim(&tmp_dim); + tmp_dim.compressed = 0; + tmp_dim.method = 0; + + m_data = tmp_dim.dim; + tmp_dim.dim = nullptr; + m_free_data_required = true; + + m_owning = true; + m_ownership_locked = true; // cannot guarantee sufficient object lifetime? + } else { + m_data = dim.dim; + } + m_size = dim.dim_n; + m_shape = {m_size}; + m_data_type = dim.data_type; + m_buildable = true; + } + ArrayBuilder& dimension(const DIMS& dim) + { + set_dimension_data(dim); + return *this; + } + + void set_time_data(const DATA_BLOCK& db) + { + auto index = db.order; + if (index < 0 or index > db.rank or db.rank < 1) { + throw std::runtime_error("No time data available for this signal"); + } + set_dimension_data(db.dims[index]); + } + ArrayBuilder& time(const DATA_BLOCK& db) + { + set_time_data(db); + return *this; + } + + libtokamap::TypedDataArray build() + { + switch (m_data_type) { + case UDA_TYPE_INT: + return libtokamap::TypedDataArray(reinterpret_cast(const_cast(m_data)), + m_size, std::move(m_shape), m_owning); + case UDA_TYPE_FLOAT: + return libtokamap::TypedDataArray(reinterpret_cast(const_cast(m_data)), + m_size, std::move(m_shape), m_owning); + case UDA_TYPE_DOUBLE: + return libtokamap::TypedDataArray(reinterpret_cast(const_cast(m_data)), + m_size, std::move(m_shape), m_owning); + case UDA_TYPE_STRING: + return libtokamap::TypedDataArray(const_cast(m_data), m_size, std::move(m_shape), m_owning); + default: + throw std::runtime_error{"unknown data type"}; + } + } + }; } // namespace libtokamap::TypedDataArray json_plugin::UDADataSource::get(const libtokamap::DataSourceArgs& data_source_args, @@ -216,27 +275,13 @@ libtokamap::TypedDataArray json_plugin::UDADataSource::get(const libtokamap::Dat return {}; } + ArrayBuilder array_builder; if (data_source_args.count("time") != 0 && data_source_args.at("time").get()){ - return set_return_time(data_block); - } - - size_t size = data_block.data_n; - std::vector shape{data_block.rank}; - for (int i = 0; i < data_block.rank; ++i) { - shape[i] = data_block.dims[i].dim_n; - } - - //note set_return_data destroys the data_block after moving the data out of it - switch (data_block.data_type) { - case UDA_TYPE_INT: - return set_return_data(data_block, size, std::move(shape)); - case UDA_TYPE_FLOAT: - return set_return_data(data_block, size, std::move(shape)); - case UDA_TYPE_DOUBLE: - return set_return_data(data_block, size, std::move(shape)); - case UDA_TYPE_STRING: - return set_return_data(data_block, size, std::move(shape)); - default: - throw std::runtime_error{"unknown data type"}; + return array_builder.ownership(ArrayBuilder::OwnershipPolicy::VIEW) + .time(data_block) + .build(); } + return array_builder.ownership(ArrayBuilder::OwnershipPolicy::VIEW) + .data(data_block) + .build(); } From f735cf46bfda1cca183758c15665fbf56ca52086 Mon Sep 17 00:00:00 2001 From: sdixon Date: Fri, 19 Sep 2025 13:17:39 +0100 Subject: [PATCH 04/15] build fixes --- CMakeLists.txt | 10 +++++++--- mapping_plugin/CMakeLists.txt | 6 +----- mapping_plugin/config/libtokamap_config.json.in | 4 +--- mapping_plugin/mapping_plugin.cpp | 2 ++ mapping_plugin/src/uda_data_source.cpp | 5 +++-- mapping_plugin/src/uda_plugin_helpers.cpp | 2 ++ mapping_plugin/src/uda_plugin_helpers.hpp | 2 +- mapping_plugin/test/CMakeLists.txt | 5 +---- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index abd43dc..551db95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ list( ) # Specify C++ standard for all targets -set( CMAKE_CXX_STANDARD 17 ) +set( CMAKE_CXX_STANDARD 20 ) set( CMAKE_CXX_STANDARD_REQUIRED ON ) set( CMAKE_CXX_EXTENSIONS OFF ) @@ -55,11 +55,15 @@ endif() include( FetchContent ) FetchContent_Declare( libtokamap - GIT_REPOSITORY git@github.com:jholloc/libtokamap.git - GIT_TAG main + GIT_REPOSITORY https://github.com/ukaea/libtokamap.git + GIT_TAG develop + CMAKE_ARGS -DENABLE_TESTS=OFF ) FetchContent_MakeAvailable( libtokamap ) + find_package( UDA REQUIRED ) add_subdirectory( mapping_plugin ) +# add_subdirectory( geometry_map_plugin ) +# add_subdirectory( CUSTOM_MASTU_plugin ) diff --git a/mapping_plugin/CMakeLists.txt b/mapping_plugin/CMakeLists.txt index 4ece78f..42346c4 100644 --- a/mapping_plugin/CMakeLists.txt +++ b/mapping_plugin/CMakeLists.txt @@ -8,11 +8,6 @@ find_package( UDA 2.7.0 REQUIRED ) find_package( Boost REQUIRED ) -# Specify C++ standard for all targets -set( CMAKE_CXX_STANDARD 17 ) -set( CMAKE_CXX_STANDARD_REQUIRED ON ) -set( CMAKE_CXX_EXTENSIONS OFF ) - set( SOURCES src/uda_data_source.cpp src/uda_ram_cache.cpp @@ -34,6 +29,7 @@ target_include_directories( libtokamap_uda_extension PRIVATE ${CMAKE_SOURCE_DIR}/libtokamap/src ) target_link_libraries( libtokamap_uda_extension PRIVATE Boost::boost LibTokaMap::libtokamap ) +target_compile_features(libtokamap_uda_extension PUBLIC cxx_std_17) find_package( Boost REQUIRED ) diff --git a/mapping_plugin/config/libtokamap_config.json.in b/mapping_plugin/config/libtokamap_config.json.in index c6b0d09..d8921ad 100644 --- a/mapping_plugin/config/libtokamap_config.json.in +++ b/mapping_plugin/config/libtokamap_config.json.in @@ -1,8 +1,6 @@ { "mapping_directory": "@CMAKE_INSTALL_PREFIX@/etc/JSON_mappings", - "globals_schema": "@CMAKE_BINARY_DIR@/_deps/libtokamap-src/schemas/mappings.schema.json", - "mapping_schema": "@CMAKE_BINARY_DIR@/_deps/libtokamap-src/schemas/globals.schema.json", - "mapping_config_schema": "@CMAKE_BINARY_DIR@/_deps/libtokamap-src/schemas/mappings.cfg.schema.json", + "schemas_directory": "@CMAKE_BINARY_DIR@/_deps/libtokamap-src/schemas", "cache_enabled": false, "cache_size": 100 } diff --git a/mapping_plugin/mapping_plugin.cpp b/mapping_plugin/mapping_plugin.cpp index d8c0f2f..8a2943e 100644 --- a/mapping_plugin/mapping_plugin.cpp +++ b/mapping_plugin/mapping_plugin.cpp @@ -247,6 +247,8 @@ int JSONMappingPlugin::get(IDAM_PLUGIN_INTERFACE* plugin_interface) case UDA_TYPE_STRING: type_index = std::type_index{typeid(char)}; break; + case UDA_TYPE_UNSIGNED_LONG64: + type_index = std::type_index{typeid(uint64_t)}; default: break; } diff --git a/mapping_plugin/src/uda_data_source.cpp b/mapping_plugin/src/uda_data_source.cpp index 47ea382..d5ac165 100644 --- a/mapping_plugin/src/uda_data_source.cpp +++ b/mapping_plugin/src/uda_data_source.cpp @@ -27,8 +27,9 @@ #include "map_types/data_source_mapping.hpp" #include "map_types/map_arguments.hpp" -#include "uda_ram_cache.hpp" -#include "utils/ram_cache.hpp" +// #include "uda_ram_cache.hpp" +// #include "utils/ram_cache.hpp" +#include "utils/typed_data_array.hpp" // TODO: // - handle compressed dims diff --git a/mapping_plugin/src/uda_plugin_helpers.cpp b/mapping_plugin/src/uda_plugin_helpers.cpp index 482e646..88f260c 100644 --- a/mapping_plugin/src/uda_plugin_helpers.cpp +++ b/mapping_plugin/src/uda_plugin_helpers.cpp @@ -19,6 +19,7 @@ std::unordered_map json_plugin::uda_type_map() static std::unordered_map type_map; if (type_map.empty()) { type_map = {{typeid(unsigned int).name(), UDA_TYPE_UNSIGNED_INT}, + {typeid(uint64_t).name(), UDA_TYPE_UNSIGNED_LONG64}, {typeid(int).name(), UDA_TYPE_INT}, {typeid(float).name(), UDA_TYPE_FLOAT}, {typeid(double).name(), UDA_TYPE_DOUBLE}, @@ -33,6 +34,7 @@ std::unordered_map json_plugin::uda_type_index_map() static std::unordered_map type_map; if (type_map.empty()) { type_map = {{std::type_index{ typeid(unsigned int) }, UDA_TYPE_UNSIGNED_INT}, + {std::type_index{ typeid(uint64_t) }, UDA_TYPE_UNSIGNED_LONG64}, {std::type_index{ typeid(int) }, UDA_TYPE_INT}, {std::type_index{ typeid(float) }, UDA_TYPE_FLOAT}, {std::type_index{ typeid(double) }, UDA_TYPE_DOUBLE}, diff --git a/mapping_plugin/src/uda_plugin_helpers.hpp b/mapping_plugin/src/uda_plugin_helpers.hpp index 2119a61..4539941 100644 --- a/mapping_plugin/src/uda_plugin_helpers.hpp +++ b/mapping_plugin/src/uda_plugin_helpers.hpp @@ -8,7 +8,7 @@ #include #include -#include "map_types/map_arguments.hpp" +#include "utils/typed_data_array.hpp" namespace json_plugin { diff --git a/mapping_plugin/test/CMakeLists.txt b/mapping_plugin/test/CMakeLists.txt index 3bd6647..7777150 100644 --- a/mapping_plugin/test/CMakeLists.txt +++ b/mapping_plugin/test/CMakeLists.txt @@ -6,10 +6,6 @@ # LANGUAGES CXX # ) -set( CMAKE_CXX_STANDARD 17 ) -set( CMAKE_CXX_STANDARD_REQUIRED ON ) -set( CMAKE_CXX_EXTENSIONS OFF ) - find_package( Boost REQUIRED ) set( TEST_SOURCES @@ -26,6 +22,7 @@ FetchContent_MakeAvailable( Catch2 ) # Create test executable add_executable( mapping_plugin_tests ${TEST_SOURCES} ) +target_compile_features(mapping_plugin_tests PUBLIC cxx_std_17) # INCLUDE target_include_directories( mapping_plugin_tests PRIVATE From 317b9431a515c6997e40ea6676c6322312b33138 Mon Sep 17 00:00:00 2001 From: sdixon Date: Fri, 19 Sep 2025 14:32:24 +0100 Subject: [PATCH 05/15] fixing data array bug in uda_data_source --- mapping_plugin/src/uda_data_source.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mapping_plugin/src/uda_data_source.cpp b/mapping_plugin/src/uda_data_source.cpp index d5ac165..28e991d 100644 --- a/mapping_plugin/src/uda_data_source.cpp +++ b/mapping_plugin/src/uda_data_source.cpp @@ -189,7 +189,7 @@ namespace m_size = db.data_n; m_shape.reserve(db.rank); for (int i = 0; i < db.rank; ++i) { - m_shape[i] = db.dims[i].dim_n; + m_shape.push_back(db.dims[i].dim_n); } m_data_type = db.data_type; m_buildable = true; @@ -282,7 +282,7 @@ libtokamap::TypedDataArray json_plugin::UDADataSource::get(const libtokamap::Dat .time(data_block) .build(); } - return array_builder.ownership(ArrayBuilder::OwnershipPolicy::VIEW) + return array_builder.ownership(ArrayBuilder::OwnershipPolicy::COPY) .data(data_block) .build(); } From 3f0531b0f645dd3b1fac3b0a63cea7053ec92e13 Mon Sep 17 00:00:00 2001 From: sdixon Date: Fri, 19 Sep 2025 14:53:16 +0100 Subject: [PATCH 06/15] adding in more uda types --- mapping_plugin/mapping_plugin.cpp | 28 +++++++++++++++++++++++ mapping_plugin/src/uda_plugin_helpers.cpp | 12 ++++++++++ mapping_plugin/src/uda_type_sizes.hpp | 9 ++++++++ 3 files changed, 49 insertions(+) diff --git a/mapping_plugin/mapping_plugin.cpp b/mapping_plugin/mapping_plugin.cpp index 8a2943e..93e094c 100644 --- a/mapping_plugin/mapping_plugin.cpp +++ b/mapping_plugin/mapping_plugin.cpp @@ -235,6 +235,9 @@ int JSONMappingPlugin::get(IDAM_PLUGIN_INTERFACE* plugin_interface) auto type_index = std::type_index{typeid(void)}; switch (datatype) { + case UDA_TYPE_SHORT: + type_index = std::type_index{typeid(short)}; + break; case UDA_TYPE_INT: type_index = std::type_index{typeid(int)}; break; @@ -249,6 +252,31 @@ int JSONMappingPlugin::get(IDAM_PLUGIN_INTERFACE* plugin_interface) break; case UDA_TYPE_UNSIGNED_LONG64: type_index = std::type_index{typeid(uint64_t)}; + break; + case UDA_TYPE_UNSIGNED_INT: + type_index = std::type_index{typeid(unsigned int)}; + break; + case UDA_TYPE_LONG: + type_index = std::type_index{typeid(long)}; + break; + case UDA_TYPE_UNSIGNED_CHAR: + type_index = std::type_index{typeid(unsigned char)}; + break; + case UDA_TYPE_UNSIGNED_SHORT: + type_index = std::type_index{typeid(unsigned short)}; + break; + case UDA_TYPE_UNSIGNED_LONG: + type_index = std::type_index{typeid(unsigned long)}; + break; + case UDA_TYPE_LONG64: + type_index = std::type_index{typeid(int64_t)}; + break; + case UDA_TYPE_COMPLEX: + type_index = std::type_index{typeid(COMPLEX)}; + break; + case UDA_TYPE_DCOMPLEX: + type_index = std::type_index{typeid(DCOMPLEX)}; + break; default: break; } diff --git a/mapping_plugin/src/uda_plugin_helpers.cpp b/mapping_plugin/src/uda_plugin_helpers.cpp index 88f260c..5d4bc20 100644 --- a/mapping_plugin/src/uda_plugin_helpers.cpp +++ b/mapping_plugin/src/uda_plugin_helpers.cpp @@ -19,11 +19,18 @@ std::unordered_map json_plugin::uda_type_map() static std::unordered_map type_map; if (type_map.empty()) { type_map = {{typeid(unsigned int).name(), UDA_TYPE_UNSIGNED_INT}, + {typeid(unsigned char).name(), UDA_TYPE_UNSIGNED_CHAR}, + {typeid(unsigned short).name(), UDA_TYPE_UNSIGNED_SHORT}, + {typeid(unsigned long).name(), UDA_TYPE_UNSIGNED_LONG}, {typeid(uint64_t).name(), UDA_TYPE_UNSIGNED_LONG64}, + {typeid(short).name(), UDA_TYPE_SHORT}, {typeid(int).name(), UDA_TYPE_INT}, + {typeid(long).name(), UDA_TYPE_LONG}, {typeid(float).name(), UDA_TYPE_FLOAT}, {typeid(double).name(), UDA_TYPE_DOUBLE}, {typeid(char).name(), UDA_TYPE_STRING}, + {typeid(COMPLEX).name(), UDA_TYPE_COMPLEX}, + {typeid(DCOMPLEX).name(), UDA_TYPE_DCOMPLEX}, {typeid(void).name(), UDA_TYPE_UNKNOWN}}; } return type_map; @@ -34,11 +41,16 @@ std::unordered_map json_plugin::uda_type_index_map() static std::unordered_map type_map; if (type_map.empty()) { type_map = {{std::type_index{ typeid(unsigned int) }, UDA_TYPE_UNSIGNED_INT}, + {std::type_index{ typeid(unsigned short) }, UDA_TYPE_UNSIGNED_SHORT}, + {std::type_index{ typeid(unsigned long) }, UDA_TYPE_UNSIGNED_LONG}, {std::type_index{ typeid(uint64_t) }, UDA_TYPE_UNSIGNED_LONG64}, {std::type_index{ typeid(int) }, UDA_TYPE_INT}, + {std::type_index{ typeid(short) }, UDA_TYPE_SHORT}, {std::type_index{ typeid(float) }, UDA_TYPE_FLOAT}, {std::type_index{ typeid(double) }, UDA_TYPE_DOUBLE}, {std::type_index{ typeid(char) }, UDA_TYPE_STRING}, + {std::type_index{ typeid(COMPLEX) }, UDA_TYPE_COMPLEX}, + {std::type_index{ typeid(DCOMPLEX) }, UDA_TYPE_DCOMPLEX}, {std::type_index{ typeid(void) }, UDA_TYPE_UNKNOWN}}; } return type_map; diff --git a/mapping_plugin/src/uda_type_sizes.hpp b/mapping_plugin/src/uda_type_sizes.hpp index dcbb025..aef8ab7 100644 --- a/mapping_plugin/src/uda_type_sizes.hpp +++ b/mapping_plugin/src/uda_type_sizes.hpp @@ -6,12 +6,15 @@ #include #include +#include namespace json_plugin { inline size_t size_of_uda_type(int type_enum) { switch (type_enum) { + case UDA_TYPE_CHAR: + return sizeof(char); case UDA_TYPE_SHORT: return sizeof(short); case UDA_TYPE_INT: @@ -20,6 +23,8 @@ inline size_t size_of_uda_type(int type_enum) return sizeof(long); case UDA_TYPE_LONG64: return sizeof(int64_t); + case UDA_TYPE_UNSIGNED_CHAR: + return sizeof(unsigned char); case UDA_TYPE_UNSIGNED_SHORT: return sizeof(unsigned short); case UDA_TYPE_UNSIGNED_INT: @@ -32,6 +37,10 @@ inline size_t size_of_uda_type(int type_enum) return sizeof(float); case UDA_TYPE_DOUBLE: return sizeof(double); + case UDA_TYPE_COMPLEX: + return sizeof(COMPLEX); + case UDA_TYPE_DCOMPLEX: + return sizeof(DCOMPLEX); default: throw std::runtime_error(std::string("uda type ") + std::to_string(type_enum) + " not implemented for json_imas_mapping cache"); From 638ff8546b18e851f42d731e49cc340e1db7c0a7 Mon Sep 17 00:00:00 2001 From: sdixon Date: Fri, 19 Sep 2025 19:50:29 +0100 Subject: [PATCH 07/15] adding more uda return types to uda_data_source --- mapping_plugin/src/uda_data_source.cpp | 59 ++++++++++++++++++++------ 1 file changed, 45 insertions(+), 14 deletions(-) diff --git a/mapping_plugin/src/uda_data_source.cpp b/mapping_plugin/src/uda_data_source.cpp index 28e991d..e4c0084 100644 --- a/mapping_plugin/src/uda_data_source.cpp +++ b/mapping_plugin/src/uda_data_source.cpp @@ -243,20 +243,52 @@ namespace return *this; } + private: + template + libtokamap::TypedDataArray _array_factory() + { + return libtokamap::TypedDataArray(reinterpret_cast(const_cast(m_data)), + m_size, std::move(m_shape), m_owning); + } + template<> + libtokamap::TypedDataArray _array_factory() + { + return libtokamap::TypedDataArray(const_cast(m_data), m_size, std::move(m_shape), m_owning); + } + + public: libtokamap::TypedDataArray build() { switch (m_data_type) { + case UDA_TYPE_SHORT: + return _array_factory(); case UDA_TYPE_INT: - return libtokamap::TypedDataArray(reinterpret_cast(const_cast(m_data)), - m_size, std::move(m_shape), m_owning); + return _array_factory(); + case UDA_TYPE_UNSIGNED_INT: + return _array_factory(); + case UDA_TYPE_LONG: + return _array_factory(); + case UDA_TYPE_LONG64: + return _array_factory(); case UDA_TYPE_FLOAT: - return libtokamap::TypedDataArray(reinterpret_cast(const_cast(m_data)), - m_size, std::move(m_shape), m_owning); + return _array_factory(); case UDA_TYPE_DOUBLE: - return libtokamap::TypedDataArray(reinterpret_cast(const_cast(m_data)), - m_size, std::move(m_shape), m_owning); + return _array_factory(); + case UDA_TYPE_UNSIGNED_CHAR: + return _array_factory(); + case UDA_TYPE_UNSIGNED_SHORT: + return _array_factory(); + case UDA_TYPE_UNSIGNED_LONG: + return _array_factory(); + case UDA_TYPE_UNSIGNED_LONG64: + return _array_factory(); + case UDA_TYPE_CHAR: case UDA_TYPE_STRING: - return libtokamap::TypedDataArray(const_cast(m_data), m_size, std::move(m_shape), m_owning); + return _array_factory(); + case UDA_TYPE_COMPLEX: + return _array_factory(); + case UDA_TYPE_DCOMPLEX: + return _array_factory(); default: throw std::runtime_error{"unknown data type"}; } @@ -276,13 +308,12 @@ libtokamap::TypedDataArray json_plugin::UDADataSource::get(const libtokamap::Dat return {}; } - ArrayBuilder array_builder; if (data_source_args.count("time") != 0 && data_source_args.at("time").get()){ - return array_builder.ownership(ArrayBuilder::OwnershipPolicy::VIEW) - .time(data_block) - .build(); + return ArrayBuilder().ownership(ArrayBuilder::OwnershipPolicy::COPY) + .time(data_block) + .build(); } - return array_builder.ownership(ArrayBuilder::OwnershipPolicy::COPY) - .data(data_block) - .build(); + return ArrayBuilder().ownership(ArrayBuilder::OwnershipPolicy::COPY) + .data(data_block) + .build(); } From 801d035f5dfd35a64fc96b44d9effceb4009d2bc Mon Sep 17 00:00:00 2001 From: Adam Parker Date: Fri, 19 Sep 2025 21:59:14 +0100 Subject: [PATCH 08/15] *fix* uda_data_source_test.cpp to get it to compile and run --- .../test/src/uda_data_source_test.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/mapping_plugin/test/src/uda_data_source_test.cpp b/mapping_plugin/test/src/uda_data_source_test.cpp index 7466802..e53f4a1 100644 --- a/mapping_plugin/test/src/uda_data_source_test.cpp +++ b/mapping_plugin/test/src/uda_data_source_test.cpp @@ -20,6 +20,7 @@ // LibTokaMap includes #include #include +#include #include // UDA includes @@ -42,7 +43,7 @@ make_map_arguments(const std::type_index data_type, const int rank) static std::unordered_map> empty_entries; static nlohmann::json empty_global_data = nlohmann::json::object(); - return MapArguments(empty_entries, empty_global_data, data_type, rank); + return MapArguments(empty_entries, empty_global_data, data_type, rank, false, false, nullptr); } int plugin_return_scalar(IDAM_PLUGIN_INTERFACE* interface) @@ -91,7 +92,9 @@ TEST_CASE("PluginMapping calls UDA data source", "[plugin_mapping][uda_data_sour std::strcpy(plugin.format, "UDA"); auto test_source = std::make_unique("UDA", "get", &plugin_list, false); - DataSourceMapping::register_data_source("UDA", std::move(test_source)); + auto* data_source_ptr = test_source.get(); + MappingHandler mapping_handler; + mapping_handler.register_data_source("UDA", std::move(test_source)); SECTION("Integer values are correctly returned") { @@ -101,7 +104,7 @@ TEST_CASE("PluginMapping calls UDA data source", "[plugin_mapping][uda_data_sour std::optional slice = {}; std::shared_ptr ram_cache = nullptr; - auto mapping = std::make_unique("UDA", request_args, offset, scale, slice, ram_cache); + auto mapping = std::make_unique("UDA", data_source_ptr, request_args, offset, scale, slice); REQUIRE(mapping != nullptr); MapArguments map_args = make_map_arguments(std::type_index{typeid(int)}, 1); @@ -126,7 +129,9 @@ TEST_CASE("Slicing and offsetting returned data", "[plugin_mapping][uda_data_sou std::strcpy(plugin.format, "UDA"); auto test_source = std::make_unique("UDA", "get", &plugin_list, false); - DataSourceMapping::register_data_source("UDA", std::move(test_source)); + auto* data_source_ptr = test_source.get(); + MappingHandler mapping_handler; + mapping_handler.register_data_source("UDA", std::move(test_source)); SECTION("Float values are correctly returned") { @@ -136,7 +141,7 @@ TEST_CASE("Slicing and offsetting returned data", "[plugin_mapping][uda_data_sou std::optional slice = {}; std::shared_ptr ram_cache = nullptr; - auto mapping = std::make_unique("UDA", request_args, offset, scale, slice, ram_cache); + auto mapping = std::make_unique("UDA", data_source_ptr, request_args, offset, scale, slice); REQUIRE(mapping != nullptr); MapArguments map_args = make_map_arguments(std::type_index{typeid(int)}, 1); @@ -161,7 +166,7 @@ TEST_CASE("Slicing and offsetting returned data", "[plugin_mapping][uda_data_sou std::string slice = "[0:" + std::to_string(range_len) + "]"; std::shared_ptr ram_cache = nullptr; - auto mapping = std::make_unique("UDA", request_args, offset, scale, slice, ram_cache); + auto mapping = std::make_unique("UDA", data_source_ptr, request_args, offset, scale, slice); REQUIRE(mapping != nullptr); MapArguments map_args = make_map_arguments(std::type_index{typeid(int)}, 1); From 5357429e53b71d2723cbac099e8dd6cd93f94492 Mon Sep 17 00:00:00 2001 From: Adam Parker Date: Fri, 19 Sep 2025 22:06:18 +0100 Subject: [PATCH 09/15] Change headers in utils plugin_helpers to use --- mapping_plugin/src/uda_plugin_helpers.cpp | 3 +-- mapping_plugin/src/uda_plugin_helpers.hpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/mapping_plugin/src/uda_plugin_helpers.cpp b/mapping_plugin/src/uda_plugin_helpers.cpp index 5d4bc20..a9f08d2 100644 --- a/mapping_plugin/src/uda_plugin_helpers.cpp +++ b/mapping_plugin/src/uda_plugin_helpers.cpp @@ -1,6 +1,7 @@ #include "uda_plugin_helpers.hpp" #include +#include #include #include #include @@ -12,8 +13,6 @@ #include #include -#include "map_types/map_arguments.hpp" - std::unordered_map json_plugin::uda_type_map() { static std::unordered_map type_map; diff --git a/mapping_plugin/src/uda_plugin_helpers.hpp b/mapping_plugin/src/uda_plugin_helpers.hpp index 4539941..7208617 100644 --- a/mapping_plugin/src/uda_plugin_helpers.hpp +++ b/mapping_plugin/src/uda_plugin_helpers.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include #include @@ -8,8 +9,6 @@ #include #include -#include "utils/typed_data_array.hpp" - namespace json_plugin { From 373d19ce7e6fbde351ea242595efdae783bcb3c8 Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Mon, 22 Sep 2025 16:23:54 +0100 Subject: [PATCH 10/15] tidying up code --- mapping_plugin/mapping_plugin.cpp | 6 +- mapping_plugin/src/uda_data_source.cpp | 299 +++++++++++----------- mapping_plugin/src/uda_plugin_helpers.cpp | 28 +- mapping_plugin/src/uda_ram_cache.cpp | 5 +- mapping_plugin/src/uda_type_sizes.hpp | 2 +- 5 files changed, 166 insertions(+), 174 deletions(-) diff --git a/mapping_plugin/mapping_plugin.cpp b/mapping_plugin/mapping_plugin.cpp index 93e094c..eb8dea6 100644 --- a/mapping_plugin/mapping_plugin.cpp +++ b/mapping_plugin/mapping_plugin.cpp @@ -143,10 +143,12 @@ int JSONMappingPlugin::init(IDAM_PLUGIN_INTERFACE* plugin_interface) auto data_source = std::make_unique("UDA", "get", plugin_interface->pluginList, false); m_mapping_handler.register_data_source("UDA", std::move(data_source)); - auto mastu_data_source = std::make_unique("CUSTOM_MASTU", "get", plugin_interface->pluginList, false); + auto mastu_data_source = + std::make_unique("CUSTOM_MASTU", "get", plugin_interface->pluginList, false); m_mapping_handler.register_data_source("CUSTOM_MASTU", std::move(mastu_data_source)); - auto geom_data_source = std::make_unique("GEOMETRY", "get", plugin_interface->pluginList, false); + auto geom_data_source = + std::make_unique("GEOMETRY", "get", plugin_interface->pluginList, false); m_mapping_handler.register_data_source("GEOMETRY", std::move(geom_data_source)); m_init = true; diff --git a/mapping_plugin/src/uda_data_source.cpp b/mapping_plugin/src/uda_data_source.cpp index e4c0084..077d1c8 100644 --- a/mapping_plugin/src/uda_data_source.cpp +++ b/mapping_plugin/src/uda_data_source.cpp @@ -13,6 +13,7 @@ // UDA includes #include +#include #include #include #include @@ -23,7 +24,6 @@ #include #include #include -#include #include "map_types/data_source_mapping.hpp" #include "map_types/map_arguments.hpp" @@ -53,7 +53,7 @@ std::string json_plugin::UDADataSource::get_request_str(const libtokamap::DataSo // string_stream << m_plugin_name << "::" << m_function.value_or("get") << "("; string_stream << m_plugin_name << "::"; - if ( data_source_args.count("function") != 0 ) { + if (data_source_args.count("function") != 0) { string_stream << data_source_args.at("function").get(); } else { string_stream << m_function.value_or("get"); @@ -137,164 +137,157 @@ int json_plugin::UDADataSource::call_plugins(DATA_BLOCK* data_block, const libto namespace { - class ArrayBuilder +class ArrayBuilder +{ + private: + const char* m_data = nullptr; + size_t m_size = {}; + std::vector m_shape; + int m_data_type = UDA_TYPE_UNKNOWN; + bool m_owning = true; + bool m_ownership_locked = false; + bool m_buildable = false; + bool m_free_data_required = false; + + public: + ArrayBuilder() = default; + ~ArrayBuilder() { - private: - const char* m_data = nullptr; - size_t m_size = {}; - std::vector m_shape; - int m_data_type = UDA_TYPE_UNKNOWN; - bool m_owning = true; - bool m_ownership_locked = false; - bool m_buildable = false; - bool m_free_data_required = false; - - public: - ArrayBuilder() = default; - ~ArrayBuilder() - { - if (m_free_data_required and m_data != nullptr) { - free(const_cast(m_data)); - } + if (m_free_data_required and m_data != nullptr) { + free(const_cast(m_data)); } + } - ArrayBuilder(const ArrayBuilder&) = delete; - ArrayBuilder& operator=(const ArrayBuilder&) = delete; - ArrayBuilder(ArrayBuilder&& other) = delete; - ArrayBuilder& operator=(ArrayBuilder&& other) = delete; - - enum class OwnershipPolicy - { - VIEW, - COPY - }; - - void set_ownership(OwnershipPolicy policy) - { - bool is_owning = (policy == OwnershipPolicy::COPY); - if (m_ownership_locked and m_owning != is_owning) { - throw std::runtime_error("Ownership policy already enforced by a previous option"); - } - m_owning = is_owning; - } - ArrayBuilder& ownership(OwnershipPolicy policy) - { - set_ownership(policy); - return *this; - } + ArrayBuilder(const ArrayBuilder&) = delete; + ArrayBuilder& operator=(const ArrayBuilder&) = delete; + ArrayBuilder(ArrayBuilder&& other) = delete; + ArrayBuilder& operator=(ArrayBuilder&& other) = delete; - void set_data(const DATA_BLOCK& db) - { - m_data = db.data; - m_size = db.data_n; - m_shape.reserve(db.rank); - for (int i = 0; i < db.rank; ++i) { - m_shape.push_back(db.dims[i].dim_n); - } - m_data_type = db.data_type; - m_buildable = true; - } - ArrayBuilder& data(const DATA_BLOCK& db) - { - set_data(db); - return *this; - } - - void set_dimension_data(const DIMS& dim) - { - if (dim.compressed > 0) { - DIMS tmp_dim = dim; - - uncompressDim(&tmp_dim); - tmp_dim.compressed = 0; - tmp_dim.method = 0; - - m_data = tmp_dim.dim; - tmp_dim.dim = nullptr; - m_free_data_required = true; - - m_owning = true; - m_ownership_locked = true; // cannot guarantee sufficient object lifetime? - } else { - m_data = dim.dim; - } - m_size = dim.dim_n; - m_shape = {m_size}; - m_data_type = dim.data_type; - m_buildable = true; - } - ArrayBuilder& dimension(const DIMS& dim) - { - set_dimension_data(dim); - return *this; - } + enum class OwnershipPolicy { VIEW, COPY }; - void set_time_data(const DATA_BLOCK& db) - { - auto index = db.order; - if (index < 0 or index > db.rank or db.rank < 1) { - throw std::runtime_error("No time data available for this signal"); - } - set_dimension_data(db.dims[index]); - } - ArrayBuilder& time(const DATA_BLOCK& db) - { - set_time_data(db); - return *this; + void set_ownership(OwnershipPolicy policy) + { + bool is_owning = (policy == OwnershipPolicy::COPY); + if (m_ownership_locked and m_owning != is_owning) { + throw std::runtime_error("Ownership policy already enforced by a previous option"); } + m_owning = is_owning; + } + ArrayBuilder& ownership(OwnershipPolicy policy) + { + set_ownership(policy); + return *this; + } - private: - template - libtokamap::TypedDataArray _array_factory() - { - return libtokamap::TypedDataArray(reinterpret_cast(const_cast(m_data)), - m_size, std::move(m_shape), m_owning); + void set_data(const DATA_BLOCK& db) + { + m_data = db.data; + m_size = db.data_n; + m_shape.reserve(db.rank); + for (int i = 0; i < db.rank; ++i) { + m_shape.push_back(db.dims[i].dim_n); } - template<> - libtokamap::TypedDataArray _array_factory() - { - return libtokamap::TypedDataArray(const_cast(m_data), m_size, std::move(m_shape), m_owning); + m_data_type = db.data_type; + m_buildable = true; + } + ArrayBuilder& data(const DATA_BLOCK& db) + { + set_data(db); + return *this; + } + + void set_dimension_data(const DIMS& dim) + { + if (dim.compressed > 0) { + DIMS tmp_dim = dim; + + uncompressDim(&tmp_dim); + tmp_dim.compressed = 0; + tmp_dim.method = 0; + + m_data = tmp_dim.dim; + tmp_dim.dim = nullptr; + m_free_data_required = true; + + m_owning = true; + m_ownership_locked = true; // cannot guarantee sufficient object lifetime? + } else { + m_data = dim.dim; } + m_size = dim.dim_n; + m_shape = {m_size}; + m_data_type = dim.data_type; + m_buildable = true; + } + ArrayBuilder& dimension(const DIMS& dim) + { + set_dimension_data(dim); + return *this; + } - public: - libtokamap::TypedDataArray build() - { - switch (m_data_type) { - case UDA_TYPE_SHORT: - return _array_factory(); - case UDA_TYPE_INT: - return _array_factory(); - case UDA_TYPE_UNSIGNED_INT: - return _array_factory(); - case UDA_TYPE_LONG: - return _array_factory(); - case UDA_TYPE_LONG64: - return _array_factory(); - case UDA_TYPE_FLOAT: - return _array_factory(); - case UDA_TYPE_DOUBLE: - return _array_factory(); - case UDA_TYPE_UNSIGNED_CHAR: - return _array_factory(); - case UDA_TYPE_UNSIGNED_SHORT: - return _array_factory(); - case UDA_TYPE_UNSIGNED_LONG: - return _array_factory(); - case UDA_TYPE_UNSIGNED_LONG64: - return _array_factory(); - case UDA_TYPE_CHAR: - case UDA_TYPE_STRING: - return _array_factory(); - case UDA_TYPE_COMPLEX: - return _array_factory(); - case UDA_TYPE_DCOMPLEX: - return _array_factory(); - default: - throw std::runtime_error{"unknown data type"}; - } + void set_time_data(const DATA_BLOCK& db) + { + auto index = db.order; + if (index < 0 or index > db.rank or db.rank < 1) { + throw std::runtime_error("No time data available for this signal"); } + set_dimension_data(db.dims[index]); + } + ArrayBuilder& time(const DATA_BLOCK& db) + { + set_time_data(db); + return *this; + } - }; + private: + template libtokamap::TypedDataArray _array_factory() + { + return libtokamap::TypedDataArray(reinterpret_cast(const_cast(m_data)), m_size, std::move(m_shape), + m_owning); + } + template <> libtokamap::TypedDataArray _array_factory() + { + return libtokamap::TypedDataArray(const_cast(m_data), m_size, std::move(m_shape), m_owning); + } + + public: + libtokamap::TypedDataArray build() + { + switch (m_data_type) { + case UDA_TYPE_SHORT: + return _array_factory(); + case UDA_TYPE_INT: + return _array_factory(); + case UDA_TYPE_UNSIGNED_INT: + return _array_factory(); + case UDA_TYPE_LONG: + return _array_factory(); + case UDA_TYPE_LONG64: + return _array_factory(); + case UDA_TYPE_FLOAT: + return _array_factory(); + case UDA_TYPE_DOUBLE: + return _array_factory(); + case UDA_TYPE_UNSIGNED_CHAR: + return _array_factory(); + case UDA_TYPE_UNSIGNED_SHORT: + return _array_factory(); + case UDA_TYPE_UNSIGNED_LONG: + return _array_factory(); + case UDA_TYPE_UNSIGNED_LONG64: + return _array_factory(); + case UDA_TYPE_CHAR: + case UDA_TYPE_STRING: + return _array_factory(); + case UDA_TYPE_COMPLEX: + return _array_factory(); + case UDA_TYPE_DCOMPLEX: + return _array_factory(); + default: + throw std::runtime_error{"unknown data type"}; + } + } +}; } // namespace libtokamap::TypedDataArray json_plugin::UDADataSource::get(const libtokamap::DataSourceArgs& data_source_args, @@ -308,12 +301,8 @@ libtokamap::TypedDataArray json_plugin::UDADataSource::get(const libtokamap::Dat return {}; } - if (data_source_args.count("time") != 0 && data_source_args.at("time").get()){ - return ArrayBuilder().ownership(ArrayBuilder::OwnershipPolicy::COPY) - .time(data_block) - .build(); + if (data_source_args.count("time") != 0 && data_source_args.at("time").get()) { + return ArrayBuilder().ownership(ArrayBuilder::OwnershipPolicy::COPY).time(data_block).build(); } - return ArrayBuilder().ownership(ArrayBuilder::OwnershipPolicy::COPY) - .data(data_block) - .build(); + return ArrayBuilder().ownership(ArrayBuilder::OwnershipPolicy::COPY).data(data_block).build(); } diff --git a/mapping_plugin/src/uda_plugin_helpers.cpp b/mapping_plugin/src/uda_plugin_helpers.cpp index a9f08d2..4b11f1f 100644 --- a/mapping_plugin/src/uda_plugin_helpers.cpp +++ b/mapping_plugin/src/uda_plugin_helpers.cpp @@ -1,13 +1,13 @@ #include "uda_plugin_helpers.hpp" #include +#include #include +#include #include #include #include #include -#include -#include #include #include @@ -39,18 +39,18 @@ std::unordered_map json_plugin::uda_type_index_map() { static std::unordered_map type_map; if (type_map.empty()) { - type_map = {{std::type_index{ typeid(unsigned int) }, UDA_TYPE_UNSIGNED_INT}, - {std::type_index{ typeid(unsigned short) }, UDA_TYPE_UNSIGNED_SHORT}, - {std::type_index{ typeid(unsigned long) }, UDA_TYPE_UNSIGNED_LONG}, - {std::type_index{ typeid(uint64_t) }, UDA_TYPE_UNSIGNED_LONG64}, - {std::type_index{ typeid(int) }, UDA_TYPE_INT}, - {std::type_index{ typeid(short) }, UDA_TYPE_SHORT}, - {std::type_index{ typeid(float) }, UDA_TYPE_FLOAT}, - {std::type_index{ typeid(double) }, UDA_TYPE_DOUBLE}, - {std::type_index{ typeid(char) }, UDA_TYPE_STRING}, - {std::type_index{ typeid(COMPLEX) }, UDA_TYPE_COMPLEX}, - {std::type_index{ typeid(DCOMPLEX) }, UDA_TYPE_DCOMPLEX}, - {std::type_index{ typeid(void) }, UDA_TYPE_UNKNOWN}}; + type_map = {{std::type_index{typeid(unsigned int)}, UDA_TYPE_UNSIGNED_INT}, + {std::type_index{typeid(unsigned short)}, UDA_TYPE_UNSIGNED_SHORT}, + {std::type_index{typeid(unsigned long)}, UDA_TYPE_UNSIGNED_LONG}, + {std::type_index{typeid(uint64_t)}, UDA_TYPE_UNSIGNED_LONG64}, + {std::type_index{typeid(int)}, UDA_TYPE_INT}, + {std::type_index{typeid(short)}, UDA_TYPE_SHORT}, + {std::type_index{typeid(float)}, UDA_TYPE_FLOAT}, + {std::type_index{typeid(double)}, UDA_TYPE_DOUBLE}, + {std::type_index{typeid(char)}, UDA_TYPE_STRING}, + {std::type_index{typeid(COMPLEX)}, UDA_TYPE_COMPLEX}, + {std::type_index{typeid(DCOMPLEX)}, UDA_TYPE_DCOMPLEX}, + {std::type_index{typeid(void)}, UDA_TYPE_UNKNOWN}}; } return type_map; } diff --git a/mapping_plugin/src/uda_ram_cache.cpp b/mapping_plugin/src/uda_ram_cache.cpp index 711f7e0..cc263f8 100644 --- a/mapping_plugin/src/uda_ram_cache.cpp +++ b/mapping_plugin/src/uda_ram_cache.cpp @@ -13,8 +13,8 @@ #include #include #include -#include #include +#include // LibTokaMap includes #include @@ -148,7 +148,8 @@ std::unique_ptr make_data_entry(DATA_BLOCK* data_blo } // namespace -void json_plugin::copy_to_cache(libtokamap::RamCache& ram_cache, const std::string& key, const DATA_BLOCK* data_block) { +void json_plugin::copy_to_cache(libtokamap::RamCache& ram_cache, const std::string& key, const DATA_BLOCK* data_block) +{ auto entry = std::make_unique(); size_t data_size = data_block->data_n * size_of_uda_type(data_block->data_type); diff --git a/mapping_plugin/src/uda_type_sizes.hpp b/mapping_plugin/src/uda_type_sizes.hpp index aef8ab7..bcdc5ae 100644 --- a/mapping_plugin/src/uda_type_sizes.hpp +++ b/mapping_plugin/src/uda_type_sizes.hpp @@ -5,8 +5,8 @@ #include #include -#include #include +#include namespace json_plugin { From 4b14f9fb396f1b28c33cab58ac4ed3ab7380d2e4 Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Mon, 22 Sep 2025 16:37:40 +0100 Subject: [PATCH 11/15] updating cmake and commenting out broken CI for now --- .github/workflows/build.yml | 30 +++++++++++++++--------------- mapping_plugin/CMakeLists.txt | 1 - mapping_plugin/test/CMakeLists.txt | 1 - 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8cf6802..e298a57 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,23 +39,23 @@ jobs: if: matrix.os == 'macos-latest' run: brew update-reset && brew install boost - - name: Configure CMake - run: > - cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=${{ matrix.release }} -DENABLE_TESTING=ON -DENABLE_EXAMPLES=ON + # - name: Configure CMake + # run: > + # cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=${{ matrix.release }} -DENABLE_TESTING=ON -DENABLE_EXAMPLES=ON - - name: Build - run: cmake --build build --config ${{ matrix.release }} - - - name: Install - if: matrix.os != 'windows-latest' - run: sudo cmake --install build --config ${{ matrix.release }} + # - name: Build + # run: cmake --build build --config ${{ matrix.release }} # - name: Install - # if: matrix.os == 'windows-latest' - # run: cmake --install build --config ${{ matrix.release }} + # if: matrix.os != 'windows-latest' + # run: sudo cmake --install build --config ${{ matrix.release }} + + # # - name: Install + # # if: matrix.os == 'windows-latest' + # # run: cmake --install build --config ${{ matrix.release }} - - name: Test - run: ctest --test-dir build --output-on-failure + # - name: Test + # run: ctest --test-dir build --output-on-failure - - name: Examples - run: ./build/libtokamap/examples/simple_mapper/simple_mapper + # - name: Examples + # run: ./build/libtokamap/examples/simple_mapper/simple_mapper diff --git a/mapping_plugin/CMakeLists.txt b/mapping_plugin/CMakeLists.txt index 42346c4..86ec7a6 100644 --- a/mapping_plugin/CMakeLists.txt +++ b/mapping_plugin/CMakeLists.txt @@ -29,7 +29,6 @@ target_include_directories( libtokamap_uda_extension PRIVATE ${CMAKE_SOURCE_DIR}/libtokamap/src ) target_link_libraries( libtokamap_uda_extension PRIVATE Boost::boost LibTokaMap::libtokamap ) -target_compile_features(libtokamap_uda_extension PUBLIC cxx_std_17) find_package( Boost REQUIRED ) diff --git a/mapping_plugin/test/CMakeLists.txt b/mapping_plugin/test/CMakeLists.txt index 7777150..5512032 100644 --- a/mapping_plugin/test/CMakeLists.txt +++ b/mapping_plugin/test/CMakeLists.txt @@ -22,7 +22,6 @@ FetchContent_MakeAvailable( Catch2 ) # Create test executable add_executable( mapping_plugin_tests ${TEST_SOURCES} ) -target_compile_features(mapping_plugin_tests PUBLIC cxx_std_17) # INCLUDE target_include_directories( mapping_plugin_tests PRIVATE From b889bd4428e2a44ef5e58c4b668c182b88afd0d9 Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Tue, 23 Sep 2025 09:37:13 +0100 Subject: [PATCH 12/15] adding option to use libtokamap profiling --- CMakeLists.txt | 7 +-- cmake/StandardSettings.cmake | 56 ----------------------- mapping_plugin/CMakeLists.txt | 7 +++ mapping_plugin/config/json_mapping.cfg.in | 1 + mapping_plugin/mapping_plugin.cpp | 22 ++++++++- 5 files changed, 32 insertions(+), 61 deletions(-) delete mode 100644 cmake/StandardSettings.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 551db95..4759fbc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,10 +42,12 @@ if( POLICY CMP0167 ) endif() # Set project options -include( StandardSettings ) include( StaticAnalyzers ) include( Utils ) +option( ENABLE_TESTING "Enable unit tests for the project (from the `test` subfolder)." OFF ) +option( ENABLE_PROFILING "Enable profiling for the project." OFF ) + # add_clang_format_target() if( ENABLE_TESTING ) @@ -57,12 +59,11 @@ FetchContent_Declare( libtokamap GIT_REPOSITORY https://github.com/ukaea/libtokamap.git GIT_TAG develop - CMAKE_ARGS -DENABLE_TESTS=OFF + CMAKE_ARGS -DENABLE_TESTS=OFF -DENABLE_PROFILING=${ENABLE_PROFILING} ) FetchContent_MakeAvailable( libtokamap ) - find_package( UDA REQUIRED ) add_subdirectory( mapping_plugin ) # add_subdirectory( geometry_map_plugin ) diff --git a/cmake/StandardSettings.cmake b/cmake/StandardSettings.cmake deleted file mode 100644 index f3f25a9..0000000 --- a/cmake/StandardSettings.cmake +++ /dev/null @@ -1,56 +0,0 @@ -# Compiler options -option( - ${PROJECT_NAME}_WARNINGS_AS_ERRORS - "Treat compiler warnings as errors." ON -) - -# Unit testing -option( - ${PROJECT_NAME}_ENABLE_TESTING - "Enable unit tests for the projects (from the `test` subfolder)." OFF -) -option( - ${PROJECT_NAME}_ENABLE_CODE_COVERAGE - "Enable code coverage for unit tests." OFF -) - -# Static analyzers -# Currently supporting: Clang-Tidy, Cppcheck. -option( - ${PROJECT_NAME}_ENABLE_CLANG_TIDY - "Enable static analysis with Clang-Tidy." OFF -) -option( - ${PROJECT_NAME}_ENABLE_CPPCHECK - "Enable static analysis with Cppcheck." OFF -) - -# Miscellaneous options -# Generate compile_commands.json for clang based tools -set( CMAKE_EXPORT_COMPILE_COMMANDS ON ) - -option( - ${PROJECT_NAME}_VERBOSE_OUTPUT - "Enable verbose output, allowing\ - for a better understanding of each step taken." ON -) - -option( - ${PROJECT_NAME}_ENABLE_CCACHE - "Enable the usage of Ccache, in order to speed up rebuild times." OFF -) - -find_program( CCACHE_FOUND ccache ) -if( CCACHE_FOUND ) - set_property( GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache ) - set_property( GLOBAL PROPERTY RULE_LAUNCH_LINK ccache ) -endif() - -option( - ${PROJECT_NAME}_ENABLE_ASAN - "Enable Address Sanitize to detect memory error." OFF -) -if( ${PROJECT_NAME}_ENABLE_ASAN ) - add_compile_options(-fsanitize=address) - add_link_options(-fsanitize=address) -endif() diff --git a/mapping_plugin/CMakeLists.txt b/mapping_plugin/CMakeLists.txt index 86ec7a6..0b2a5bb 100644 --- a/mapping_plugin/CMakeLists.txt +++ b/mapping_plugin/CMakeLists.txt @@ -32,6 +32,11 @@ target_link_libraries( libtokamap_uda_extension PRIVATE Boost::boost LibTokaMap: find_package( Boost REQUIRED ) +set( EXTRA_DEFINITIONS ) +if( ENABLE_PROFILING ) + list( APPEND EXTRA_DEFINITIONS -DENABLE_PROFILING ) +endif() + include( plugins ) uda_plugin( NAME IMAS_JSON_MAP @@ -53,6 +58,8 @@ uda_plugin( LibTokaMap::libtokamap libtokamap_uda_extension uda_client + EXTRA_DEFINITIONS + ${EXTRA_DEFINITIONS} ) # Unit testing setup diff --git a/mapping_plugin/config/json_mapping.cfg.in b/mapping_plugin/config/json_mapping.cfg.in index e2d6dea..354cbe5 100644 --- a/mapping_plugin/config/json_mapping.cfg.in +++ b/mapping_plugin/config/json_mapping.cfg.in @@ -1,3 +1,4 @@ # Needed at runtime to find the installed mappings locations on the server side machine # Environmental Variables are available on server after install export UDA_MAPPING_CONFIG_PATH=@CMAKE_INSTALL_PREFIX@/etc/plugins.d/libtokamap_config.json +export UDA_MAPPING_PROFILE_FILE=@CMAKE_INSTALL_PREFIX@/etc/profile.json diff --git a/mapping_plugin/mapping_plugin.cpp b/mapping_plugin/mapping_plugin.cpp index eb8dea6..ce823fb 100644 --- a/mapping_plugin/mapping_plugin.cpp +++ b/mapping_plugin/mapping_plugin.cpp @@ -17,8 +17,7 @@ #include // LibTokaMap includes -#include -#include +#include // UDA includes #include @@ -33,6 +32,7 @@ #include "uda_data_source.hpp" #include "uda_plugin_helpers.hpp" +#include "utils/profiler.hpp" namespace { @@ -99,6 +99,13 @@ class JSONMappingPlugin public: int entry_handle(IDAM_PLUGIN_INTERFACE* plugin_interface); + ~JSONMappingPlugin() + { + if (m_init) { + reset(nullptr); + } + } + private: int execute(IDAM_PLUGIN_INTERFACE* plugin_interface); int init(IDAM_PLUGIN_INTERFACE* plugin_interface); @@ -133,6 +140,10 @@ int JSONMappingPlugin::init(IDAM_PLUGIN_INTERFACE* plugin_interface) return 0; } +#if ENABLE_PROFILING + libtokamap::Profiler::init(); +#endif + const char* config_path = getenv("UDA_MAPPING_CONFIG_PATH"); if (config_path != nullptr) { m_mapping_handler.init(std::filesystem::path{config_path}); @@ -166,6 +177,13 @@ int JSONMappingPlugin::init(IDAM_PLUGIN_INTERFACE* plugin_interface) int JSONMappingPlugin::reset(IDAM_PLUGIN_INTERFACE* /*plugin_interface*/) // silence unused warning { if (m_init) { +#if ENABLE_PROFILING + const char* profile_file = getenv("UDA_MAPPING_PROFILE_FILE"); + if (profile_file != nullptr) { + libtokamap::Profiler::write(profile_file); + } +#endif + // Free Heap & reset counters if initialised m_mapping_handler.unregister_data_source("UDA"); m_mapping_handler.unregister_data_source("CUSTOM_MASTU"); From a73465440f993c3c57473bc80fe27eebf0799d68 Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Mon, 29 Sep 2025 09:42:00 +0100 Subject: [PATCH 13/15] making fetching of libtokamap optional (default off) --- CMakeLists.txt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4759fbc..357a2b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,7 @@ include( Utils ) option( ENABLE_TESTING "Enable unit tests for the project (from the `test` subfolder)." OFF ) option( ENABLE_PROFILING "Enable profiling for the project." OFF ) +option( FETCH_LIBTOKAMAP "Fetch libtokamap as a dependency." OFF ) # add_clang_format_target() @@ -54,15 +55,17 @@ if( ENABLE_TESTING ) enable_testing() endif() -include( FetchContent ) -FetchContent_Declare( - libtokamap - GIT_REPOSITORY https://github.com/ukaea/libtokamap.git - GIT_TAG develop - CMAKE_ARGS -DENABLE_TESTS=OFF -DENABLE_PROFILING=${ENABLE_PROFILING} -) +if( FETCH_LIBTOKAMAP ) + include( FetchContent ) + FetchContent_Declare( + libtokamap + GIT_REPOSITORY https://github.com/ukaea/libtokamap.git + GIT_TAG develop + CMAKE_ARGS -DENABLE_TESTS=OFF -DENABLE_PROFILING=${ENABLE_PROFILING} + ) -FetchContent_MakeAvailable( libtokamap ) + FetchContent_MakeAvailable( libtokamap ) +endif() find_package( UDA REQUIRED ) add_subdirectory( mapping_plugin ) From a99ba6bc92c8c5f2fda2df978bdc3cc848f09986 Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Mon, 29 Sep 2025 11:29:01 +0100 Subject: [PATCH 14/15] fixing build when using external libtokamap --- CMakeLists.txt | 2 ++ mapping_plugin/CMakeLists.txt | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 357a2b4..3838d52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,8 @@ if( FETCH_LIBTOKAMAP ) ) FetchContent_MakeAvailable( libtokamap ) +else() + add_clang_format_target() endif() find_package( UDA REQUIRED ) diff --git a/mapping_plugin/CMakeLists.txt b/mapping_plugin/CMakeLists.txt index 0b2a5bb..e01b833 100644 --- a/mapping_plugin/CMakeLists.txt +++ b/mapping_plugin/CMakeLists.txt @@ -7,6 +7,7 @@ find_package( UDA 2.7.0 REQUIRED ) find_package( Boost REQUIRED ) +find_package( libtokamap REQUIRED ) set( SOURCES src/uda_data_source.cpp @@ -26,12 +27,9 @@ add_library( libtokamap_uda_extension ${SOURCES} ) target_include_directories( libtokamap_uda_extension PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src ${CMAKE_CURRENT_LIST_DIR}/ext_include - ${CMAKE_SOURCE_DIR}/libtokamap/src ) target_link_libraries( libtokamap_uda_extension PRIVATE Boost::boost LibTokaMap::libtokamap ) -find_package( Boost REQUIRED ) - set( EXTRA_DEFINITIONS ) if( ENABLE_PROFILING ) list( APPEND EXTRA_DEFINITIONS -DENABLE_PROFILING ) From d1a0e2844e1a5b4eddaa70d3aa337cf0bd24aa54 Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Wed, 1 Oct 2025 14:59:58 +0100 Subject: [PATCH 15/15] fixing activate script --- CMakeLists.txt | 2 -- cmake/plugins.cmake | 2 +- mapping_plugin/CMakeLists.txt | 1 + 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3838d52..7fedc31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,5 +71,3 @@ endif() find_package( UDA REQUIRED ) add_subdirectory( mapping_plugin ) -# add_subdirectory( geometry_map_plugin ) -# add_subdirectory( CUSTOM_MASTU_plugin ) diff --git a/cmake/plugins.cmake b/cmake/plugins.cmake index 723cb81..4b1cee5 100644 --- a/cmake/plugins.cmake +++ b/cmake/plugins.cmake @@ -28,7 +28,7 @@ macro( uda_plugin ) "${ARGN}" ) - set( BUILT_PLUGINS ${BUILT_PLUGINS} "${PLUGIN_NAME}" PARENT_SCOPE ) + set( BUILT_PLUGINS ${BUILT_PLUGINS} "${PLUGIN_NAME}" ) if( NOT PLUGIN_VERSION ) set( PLUGIN_VERSION "0.0.0" ) diff --git a/mapping_plugin/CMakeLists.txt b/mapping_plugin/CMakeLists.txt index e01b833..5255a9a 100644 --- a/mapping_plugin/CMakeLists.txt +++ b/mapping_plugin/CMakeLists.txt @@ -98,6 +98,7 @@ install( ) # Generate scripts +list( GET UDA_DIR 0 UDA_HOME ) string( REGEX REPLACE ";" " " PLUGINS "${BUILT_PLUGINS}" ) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/scripts/activate-plugins.sh.in