Commit 870cf284 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Automatize addition of generator functions to algorithms

parent bd46b0ec
......@@ -24,6 +24,14 @@ MACRO(corryvreckan_algorithm name)
# Add the current directory as include directory
TARGET_INCLUDE_DIRECTORIES(${LIBNAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
# Set the special header flags and add the special dynamic implementation file
TARGET_COMPILE_DEFINITIONS(${LIBNAME} PRIVATE CORRYVRECKAN_ALGORITHM_NAME=${name})
TARGET_COMPILE_DEFINITIONS(${LIBNAME} PRIVATE CORRYVRECKAN_ALGORITHM_HEADER="${name}.h")
TARGET_SOURCES(${LIBNAME} PRIVATE "${PROJECT_SOURCE_DIR}/src/core/dynamic_algorithm_impl.cpp")
SET_PROPERTY(SOURCE "${PROJECT_SOURCE_DIR}/src/core/dynamic_algorithm_impl.cpp" APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${name}.h")
SET_PROPERTY(SOURCE "${PROJECT_SOURCE_DIR}/src/core/Algorithm.C" APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${name}.h")
# Link the standard allpix libraries
TARGET_LINK_LIBRARIES(${LIBNAME} ${CORRYVRECKAN_LIBRARIES} ${CORRYVRECKAN_DEPS_LIBRARIES})
......
/**
* @file
* @brief Special file automatically included in the algorithm for the dynamic loading
*
* Needs the following names to be defined by the build system
* - CORRYVRECKAN_ALGORITHM_NAME: name of the module
* - CORRYVRECKAN_ALGORITHM_HEADER: name of the header defining the module
*
* @copyright Copyright (c) 2017 CERN and the Allpix Squared authors.
* This software is distributed under the terms of the MIT License, copied verbatim in the file "LICENSE.md".
* In applying this license, CERN does not waive the privileges and immunities granted to it by virtue of its status as an
* Intergovernmental Organization or submit itself to any jurisdiction.
*/
#ifndef CORRYVRECKAN_ALGORITHM_NAME
#error "This header should only be automatically included during the build"
#endif
#include <memory>
#include <utility>
#include "core/config/Configuration.hpp"
#include "core/utils/log.h"
#include CORRYVRECKAN_ALGORITHM_HEADER
namespace corryvreckan {
extern "C" {
Algorithm* corryvreckan_module_generator(Configuration config, Clipboard* clipboard);
Algorithm* corryvreckan_module_generator(Configuration config, Clipboard* clipboard) {
auto algorithm = new CORRYVRECKAN_ALGORITHM_NAME(std::move(config), clipboard); // NOLINT
return static_cast<Algorithm*>(algorithm);
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment