Skip to content

Commit

Permalink
feat: nopayloadclient service
Browse files Browse the repository at this point in the history
  • Loading branch information
wdconinc committed May 10, 2024
1 parent db2273d commit 3ceb7f6
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cmake/jana_plugin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,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)

Expand Down
1 change: 1 addition & 0 deletions src/services/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ add_subdirectory(geometry/acts)
add_subdirectory(geometry/richgeo)
add_subdirectory(io/podio)
add_subdirectory(log)
add_subdirectory(payload)
add_subdirectory(rootfile)
add_subdirectory(pid_lut)
18 changes: 18 additions & 0 deletions src/services/payload/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
13 changes: 13 additions & 0 deletions src/services/payload/Payload_service.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright (C) 2024 Wouter Deconinck

#include "Payload_service.h"

#include <JANA/JException.h>
#include <nlohmann/json.hpp>
#include <nopayloadclient/nopayloadclient.hpp>

Payload_service::Payload_service(JApplication *app)
: m_client("EICrecon") {
m_application = app;
}
25 changes: 25 additions & 0 deletions src/services/payload/Payload_service.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright (C) 2024 Wouter Deconinck

#pragma once

#include <JANA/JApplication.h>
#include <JANA/Services/JServiceLocator.h>
#include <nlohmann/json.hpp>
#include <nopayloadclient/nopayloadclient.hpp>
#include <string>

class Payload_service : public JService
{
public:
explicit Payload_service(JApplication *app);
~Payload_service() { };

private:

Payload_service() = default;

nopayloadclient::NoPayloadClient m_client;

JApplication* m_application;
};
17 changes: 17 additions & 0 deletions src/services/payload/payload.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2022, David Lawrence
// Subject to the terms in the LICENSE file found in the top-level directory.
//
//

#include <JANA/JApplication.h>
#include <memory>

#include "Log_service.h"


extern "C" {
void InitPlugin(JApplication *app) {
InitJANAPlugin(app);
app->ProvideService(std::make_shared<Log_service>(app) );
}
}

0 comments on commit 3ceb7f6

Please sign in to comment.