1717#include < utility>
1818
1919// LibTokaMap includes
20- #include < handlers/mapping_handler.hpp>
21- #include < map_types/data_source_mapping.hpp>
20+ #include < libtokamap.hpp>
2221
2322// UDA includes
2423#include < clientserver/errorLog.h>
3332
3433#include " uda_data_source.hpp"
3534#include " uda_plugin_helpers.hpp"
35+ #include " utils/profiler.hpp"
3636
3737namespace
3838{
@@ -99,6 +99,13 @@ class JSONMappingPlugin
9999 public:
100100 int entry_handle (IDAM_PLUGIN_INTERFACE* plugin_interface);
101101
102+ ~JSONMappingPlugin ()
103+ {
104+ if (m_init) {
105+ reset (nullptr );
106+ }
107+ }
108+
102109 private:
103110 int execute (IDAM_PLUGIN_INTERFACE* plugin_interface);
104111 int init (IDAM_PLUGIN_INTERFACE* plugin_interface);
@@ -133,6 +140,10 @@ int JSONMappingPlugin::init(IDAM_PLUGIN_INTERFACE* plugin_interface)
133140 return 0 ;
134141 }
135142
143+ #if ENABLE_PROFILING
144+ libtokamap::Profiler::init ();
145+ #endif
146+
136147 const char * config_path = getenv (" UDA_MAPPING_CONFIG_PATH" );
137148 if (config_path != nullptr ) {
138149 m_mapping_handler.init (std::filesystem::path{config_path});
@@ -143,10 +154,12 @@ int JSONMappingPlugin::init(IDAM_PLUGIN_INTERFACE* plugin_interface)
143154 auto data_source = std::make_unique<json_plugin::UDADataSource>(" UDA" , " get" , plugin_interface->pluginList , false );
144155 m_mapping_handler.register_data_source (" UDA" , std::move (data_source));
145156
146- auto mastu_data_source = std::make_unique<json_plugin::UDADataSource>(" CUSTOM_MASTU" , " get" , plugin_interface->pluginList , false );
157+ auto mastu_data_source =
158+ std::make_unique<json_plugin::UDADataSource>(" CUSTOM_MASTU" , " get" , plugin_interface->pluginList , false );
147159 m_mapping_handler.register_data_source (" CUSTOM_MASTU" , std::move (mastu_data_source));
148160
149- auto geom_data_source = std::make_unique<json_plugin::UDADataSource>(" GEOMETRY" , " get" , plugin_interface->pluginList , false );
161+ auto geom_data_source =
162+ std::make_unique<json_plugin::UDADataSource>(" GEOMETRY" , " get" , plugin_interface->pluginList , false );
150163 m_mapping_handler.register_data_source (" GEOMETRY" , std::move (geom_data_source));
151164
152165 m_init = true ;
@@ -164,6 +177,13 @@ int JSONMappingPlugin::init(IDAM_PLUGIN_INTERFACE* plugin_interface)
164177int JSONMappingPlugin::reset (IDAM_PLUGIN_INTERFACE* /* plugin_interface*/ ) // silence unused warning
165178{
166179 if (m_init) {
180+ #if ENABLE_PROFILING
181+ const char * profile_file = getenv (" UDA_MAPPING_PROFILE_FILE" );
182+ if (profile_file != nullptr ) {
183+ libtokamap::Profiler::write (profile_file);
184+ }
185+ #endif
186+
167187 // Free Heap & reset counters if initialised
168188 m_mapping_handler.unregister_data_source (" UDA" );
169189 m_mapping_handler.unregister_data_source (" CUSTOM_MASTU" );
@@ -235,6 +255,9 @@ int JSONMappingPlugin::get(IDAM_PLUGIN_INTERFACE* plugin_interface)
235255
236256 auto type_index = std::type_index{typeid (void )};
237257 switch (datatype) {
258+ case UDA_TYPE_SHORT:
259+ type_index = std::type_index{typeid (short )};
260+ break ;
238261 case UDA_TYPE_INT:
239262 type_index = std::type_index{typeid (int )};
240263 break ;
@@ -247,6 +270,33 @@ int JSONMappingPlugin::get(IDAM_PLUGIN_INTERFACE* plugin_interface)
247270 case UDA_TYPE_STRING:
248271 type_index = std::type_index{typeid (char )};
249272 break ;
273+ case UDA_TYPE_UNSIGNED_LONG64:
274+ type_index = std::type_index{typeid (uint64_t )};
275+ break ;
276+ case UDA_TYPE_UNSIGNED_INT:
277+ type_index = std::type_index{typeid (unsigned int )};
278+ break ;
279+ case UDA_TYPE_LONG:
280+ type_index = std::type_index{typeid (long )};
281+ break ;
282+ case UDA_TYPE_UNSIGNED_CHAR:
283+ type_index = std::type_index{typeid (unsigned char )};
284+ break ;
285+ case UDA_TYPE_UNSIGNED_SHORT:
286+ type_index = std::type_index{typeid (unsigned short )};
287+ break ;
288+ case UDA_TYPE_UNSIGNED_LONG:
289+ type_index = std::type_index{typeid (unsigned long )};
290+ break ;
291+ case UDA_TYPE_LONG64:
292+ type_index = std::type_index{typeid (int64_t )};
293+ break ;
294+ case UDA_TYPE_COMPLEX:
295+ type_index = std::type_index{typeid (COMPLEX)};
296+ break ;
297+ case UDA_TYPE_DCOMPLEX:
298+ type_index = std::type_index{typeid (DCOMPLEX)};
299+ break ;
250300 default :
251301 break ;
252302 }
0 commit comments