From 8570a6f3da00c8ee66ec58d3f3e22669cf90b5c1 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Tue, 7 May 2024 19:50:38 -0500 Subject: [PATCH] feat: nopayloadclient service --- cmake/jana_plugin.cmake | 18 ++++++++++++++++++ src/services/CMakeLists.txt | 1 + src/services/payload/CMakeLists.txt | 18 ++++++++++++++++++ src/services/payload/Payload_service.cc | 13 +++++++++++++ src/services/payload/Payload_service.h | 25 +++++++++++++++++++++++++ src/services/payload/payload.cc | 17 +++++++++++++++++ 6 files changed, 92 insertions(+) create mode 100644 src/services/payload/CMakeLists.txt create mode 100644 src/services/payload/Payload_service.cc create mode 100644 src/services/payload/Payload_service.h create mode 100644 src/services/payload/payload.cc diff --git a/cmake/jana_plugin.cmake b/cmake/jana_plugin.cmake index ef090303f7..8b24d8ca33 100644 --- a/cmake/jana_plugin.cmake +++ b/cmake/jana_plugin.cmake @@ -322,6 +322,24 @@ macro(plugin_add_irt _name) endmacro() +# Adds nopayloadclient for a plugin +macro(plugin_add_nopayloadclient _name) + + if(NOT CURL_FOUND) + find_package(CURL REQUIRED) + endif() + + find_library(npc_lib REQUIRED NAMES nopayloadclient) + find_path(npc_include REQUIRED NAMES nopayloadclient) + + # Add include directories + plugin_include_directories(${PLUGIN_NAME} PUBLIC curl ${npc_include}) + + # Add libraries + plugin_link_libraries(${PLUGIN_NAME} curl ${npc_lib}) + +endmacro() + # Adds podio, edm4hep, edm4eic for a plugin macro(plugin_add_event_model _name) diff --git a/src/services/CMakeLists.txt b/src/services/CMakeLists.txt index 8eb1fbe332..02dd19801f 100644 --- a/src/services/CMakeLists.txt +++ b/src/services/CMakeLists.txt @@ -5,4 +5,5 @@ add_subdirectory(geometry/acts) add_subdirectory(geometry/richgeo) add_subdirectory(io/podio) add_subdirectory(log) +add_subdirectory(payload) add_subdirectory(rootfile) diff --git a/src/services/payload/CMakeLists.txt b/src/services/payload/CMakeLists.txt new file mode 100644 index 0000000000..bed3bd6e79 --- /dev/null +++ b/src/services/payload/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.16) + +# Automatically set plugin name the same as the directory name Don't forget +# string(REPLACE " " "_" PLUGIN_NAME ${PLUGIN_NAME}) if this dir has spaces in +# its name +get_filename_component(PLUGIN_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) + +# Function creates ${PLUGIN_NAME}_plugin and ${PLUGIN_NAME}_library targets +# Setting default includes, libraries and installation paths +plugin_add(${PLUGIN_NAME} WITH_STATIC_LIBRARY) + +# The macro grabs sources as *.cc *.cpp *.c and headers as *.h *.hh *.hpp Then +# correctly sets sources for ${_name}_plugin and ${_name}_library targets Adds +# headers to the correct installation directory +plugin_glob_all(${PLUGIN_NAME}) + +# Find dependencies +plugin_add_nopayloadclient(${PLUGIN_NAME}) diff --git a/src/services/payload/Payload_service.cc b/src/services/payload/Payload_service.cc new file mode 100644 index 0000000000..0e2ab6fd88 --- /dev/null +++ b/src/services/payload/Payload_service.cc @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (C) 2024 Wouter Deconinck + +#include "Payload_service.h" + +#include +#include +#include + +Payload_service::Payload_service(JApplication *app) +: m_client("EICrecon") { + m_application = app; +} diff --git a/src/services/payload/Payload_service.h b/src/services/payload/Payload_service.h new file mode 100644 index 0000000000..4395c4960a --- /dev/null +++ b/src/services/payload/Payload_service.h @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (C) 2024 Wouter Deconinck + +#pragma once + +#include +#include +#include +#include +#include + +class Payload_service : public JService +{ +public: + explicit Payload_service(JApplication *app); + ~Payload_service() { }; + +private: + + Payload_service() = default; + + nopayloadclient::NoPayloadClient m_client; + + JApplication* m_application; +}; diff --git a/src/services/payload/payload.cc b/src/services/payload/payload.cc new file mode 100644 index 0000000000..b1f6db3d37 --- /dev/null +++ b/src/services/payload/payload.cc @@ -0,0 +1,17 @@ +// Copyright 2022, David Lawrence +// Subject to the terms in the LICENSE file found in the top-level directory. +// +// + +#include +#include + +#include "Log_service.h" + + +extern "C" { +void InitPlugin(JApplication *app) { + InitJANAPlugin(app); + app->ProvideService(std::make_shared(app) ); +} +}