Commit fb815482 authored by Samuel GAIST's avatar Samuel GAIST Committed by André Anjos

[prefix] Add algorithm and experiments for V2 API

parent bdc0e748
{
"language": "cxx",
"groups": [
{
"name": "main",
"inputs": {
"in_data": {
"type": "user/single_integer/1"
}
}
}
],
"results": {
"out_data": {
"type": "int32",
"display": false
}
}
}
cmake_minimum_required(VERSION 3.0)
project(BEAT_CORE_CXX_INTEGERS_ANALYZER)
set(BEAT_BACKEND_CXX_DIR "/usr/local/beat")
# CMake setup
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if (COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif (COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
# Retrieve the dependencies
find_package(Boost REQUIRED)
# Setup the search paths
include_directories(
"${BEAT_BACKEND_CXX_DIR}/include"
"${Boost_INCLUDE_DIRS}"
)
link_directories(
"${BEAT_BACKEND_CXX_DIR}/bin"
)
# List the source files
set(HEADERS "algorithm.h"
"beat_setup.h"
"user_single_integer_1.h"
)
set(SRCS "algorithm.cpp"
"beat_setup.cpp"
"user_single_integer_1.cpp"
)
# Create and link the library
add_library(cxx_integers_echo_analyzer SHARED ${SRCS} ${HEADERS})
target_link_libraries(cxx_integers_echo_analyzer beat_backend_cxx)
set_target_properties(cxx_integers_echo_analyzer PROPERTIES
COMPILE_FLAGS "-fPIC"
OUTPUT_NAME "1"
PREFIX ""
LIBRARY_OUTPUT_DIRECTORY "${BEAT_CORE_CXX_INTEGERS_ECHO_ANALYZER_SOURCE_DIR}"
)
// NOTE: This file implements the algorithm declared in the file
// 'user/cxx_integers_echo/1.json'
#include "algorithm.h"
#include "beat.backend.cxx/input.h"
#include "beat.backend.cxx/inputlist.h"
#include "beat.backend.cxx/outputlist.h"
#include "beat.backend.cxx/dataloader.h"
#include "user_single_integer_1.h"
using namespace beat::backend::cxx;
Algorithm::Algorithm()
{
}
//---------------------------------------------------------
Algorithm::~Algorithm()
{
}
//---------------------------------------------------------
bool Algorithm::setup(const json& parameters)
{
return true;
}
//---------------------------------------------------------
bool Algorithm::prepare(const DataLoaderList& data_load_list)
{
return true;
}
//---------------------------------------------------------
bool Algorithm::process(const InputList& inputs,
const DataLoaderList& data_load_list,
const OutputList& outputs)
{
auto data = inputs["in_data"]->data<dataformats::user::single_integer_1>();
outputs["out_data"]->write(data);
return true;
}
//---------------------------------------------------------
IAlgorithm* create_algorithm()
{
return new Algorithm();
}
// NOTE: This file implements the algorithm declared in the file
// 'user/cxx_integers_echo/1.json'
#ifndef _BEAT_GENERATED_ALGORITHM_H_
#define _BEAT_GENERATED_ALGORITHM_H_
#include <beat.backend.cxx/algorithm.h>
class Algorithm: public beat::backend::cxx::IAlgorithmSequential
{
public:
Algorithm();
virtual ~Algorithm();
bool setup(const json& parameters) override;
bool prepare(const beat::backend::cxx::DataLoaderList& data_load_list) override;
bool process(const beat::backend::cxx::InputList& inputs,
const beat::backend::cxx::DataLoaderList& data_load_list,
const beat::backend::cxx::OutputList& outputs) override;
};
extern "C" {
beat::backend::cxx::IAlgorithm* create_algorithm();
}
#endif
// NOTE: This file was automatically generated from the algorithm declaration file
// 'user/cxx_integers_echo/1.json'
#include <beat.backend.cxx/dataformatfactory.h>
#include "beat_setup.h"
#include "user_single_integer_1.h"
using namespace beat::backend::cxx;
void setup_beat_cxx_module()
{
DataFormatFactory* factory = DataFormatFactory::getInstance();
factory->registerDataFormat<dataformats::user::single_integer_1>();
}
// NOTE: This file was automatically generated from the algorithm declaration file
// 'user/cxx_integers_echo/1.json'
#ifndef _BEAT_SETUP_H_
#define _BEAT_SETUP_H_
extern "C" {
void setup_beat_cxx_module();
}
#endif
// NOTE: This file was automatically generated from the dataformat declaration file
// 'user/single_integer/1.json'
#include "user_single_integer_1.h"
#include <beat.backend.cxx/dataformatfactory.h>
using namespace beat::backend::cxx;
dataformats::user::single_integer_1::single_integer_1()
{
}
//---------------------------------------------------------
size_t dataformats::user::single_integer_1::fixed_size()
{
return sizeof(int32_t);
}
//---------------------------------------------------------
size_t dataformats::user::single_integer_1::size() const
{
return dataformats::user::single_integer_1::fixed_size();
}
//---------------------------------------------------------
void dataformats::user::single_integer_1::pack(uint8_t** buffer) const
{
beat::backend::cxx::pack(value, buffer);
}
//---------------------------------------------------------
void dataformats::user::single_integer_1::unpack(uint8_t** buffer)
{
value = beat::backend::cxx::unpack_scalar<int32_t>(buffer);
}
//---------------------------------------------------------
Data* dataformats::user::single_integer_1::create()
{
return new user::single_integer_1();
}
//---------------------------------------------------------
const char *dataformats::user::single_integer_1::getNameStatic()
{
return "user/single_integer/1";
}
//---------------------------------------------------------
std::string dataformats::user::single_integer_1::toJson() const
{
return "{"
"\"field\":\"int32_t\""
"}";
}
// NOTE: This file was automatically generated from the dataformat declaration file
// 'user/single_integer/1.json'
#ifndef _BEAT_GENERATED_user_single_integer_1_H_
#define _BEAT_GENERATED_user_single_integer_1_H_
#include <beat.backend.cxx/data.h>
namespace dataformats {
namespace user {
class single_integer_1: public beat::backend::cxx::DataImpl<single_integer_1>
{
public:
single_integer_1();
static size_t fixed_size();
size_t size() const override;
void pack(uint8_t** buffer) const override;
void unpack(uint8_t** buffer) override;
static Data* create();
static const char *getNameStatic();
std::string toJson() const override;
public:
int32_t value;
};
} // user
} // dataformats
#endif
{
"schema_version": 2,
"language": "cxx",
"api_version": 2,
"type": "autonomous",
"splittable": true,
"groups": [
{
"name": "main",
"inputs": {
"in_data": {
"type": "user/single_integer/1"
}
},
"outputs": {
"out_data": {
"type": "user/single_integer/1"
}
}
}
]
}
cmake_minimum_required(VERSION 3.0)
project(BEAT_CORE_CXX_INTEGERS_ECHO_AUTONOMOUS)
set(BEAT_BACKEND_CXX_DIR "/usr/local/beat")
# CMake setup
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if (COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif (COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
# Retrieve the dependencies
find_package(Boost REQUIRED)
# Setup the search paths
include_directories(
"${BEAT_BACKEND_CXX_DIR}/include"
"${Boost_INCLUDE_DIRS}"
)
link_directories(
"${BEAT_BACKEND_CXX_DIR}/bin"
)
# List the source files
set(HEADERS "algorithm.h"
"beat_setup.h"
"user_single_integer_1.h"
)
set(SRCS "algorithm.cpp"
"beat_setup.cpp"
"user_single_integer_1.cpp"
)
# Create and link the library
add_library(cxx_integers_echo_autonomous SHARED ${SRCS} ${HEADERS})
target_link_libraries(cxx_integers_echo_autonomous beat_backend_cxx)
set_target_properties(cxx_integers_echo_autonomous PROPERTIES
COMPILE_FLAGS "-fPIC"
OUTPUT_NAME "1"
PREFIX ""
LIBRARY_OUTPUT_DIRECTORY "${BEAT_CORE_CXX_INTEGERS_ECHO_AUTONOMOUS_SOURCE_DIR}"
)
// NOTE: This file implements the algorithm declared in the file
// 'user/cxx_integers_echo/1.json'
#include "algorithm.h"
#include "beat.backend.cxx/outputlist.h"
#include "beat.backend.cxx/dataloader.h"
#include "user_single_integer_1.h"
#include <iostream>
using namespace beat::backend::cxx;
Algorithm::Algorithm()
{
}
//---------------------------------------------------------
Algorithm::~Algorithm()
{
}
//---------------------------------------------------------
bool Algorithm::setup(const json& parameters)
{
return true;
}
//---------------------------------------------------------
bool Algorithm::prepare(const DataLoaderList& data_load_list)
{
return true;
}
//---------------------------------------------------------
bool Algorithm::process(const DataLoaderList& data_load_list, const OutputList& outputs)
{
auto data_loader = data_load_list.loader_of("in_data");
std::map<std::string, beat::backend::cxx::Data *> data;
int64_t start = -1;
int64_t end = -1;
for (int i = 0 ; i < data_loader->count() ; ++i) {
std::tie(data, start, end) = (*data_loader)[i];
auto value = static_cast<dataformats::user::single_integer_1*>(data["in_data"]);
outputs["out_data"]->write(value);
}
return true;
}
//---------------------------------------------------------
IAlgorithm* create_algorithm()
{
return new Algorithm();
}
// NOTE: This file implements the algorithm declared in the file
// 'user/cxx_integers_echo/1.json'
#ifndef _BEAT_GENERATED_ALGORITHM_H_
#define _BEAT_GENERATED_ALGORITHM_H_
#include <beat.backend.cxx/algorithm.h>
class Algorithm: public beat::backend::cxx::IAlgorithmAutonomous
{
public:
Algorithm();
virtual ~Algorithm();
bool setup(const json& parameters) override;
bool prepare(const beat::backend::cxx::DataLoaderList& data_load_list) override;
bool process(const beat::backend::cxx::DataLoaderList& data_load_list,
const beat::backend::cxx::OutputList& outputs) override;
};
extern "C" {
beat::backend::cxx::IAlgorithm* create_algorithm();
}
#endif
// NOTE: This file was automatically generated from the algorithm declaration file
// 'user/cxx_integers_echo/1.json'
#include <beat.backend.cxx/dataformatfactory.h>
#include "beat_setup.h"
#include "user_single_integer_1.h"
using namespace beat::backend::cxx;
void setup_beat_cxx_module()
{
DataFormatFactory* factory = DataFormatFactory::getInstance();
factory->registerDataFormat<dataformats::user::single_integer_1>();
}
// NOTE: This file was automatically generated from the algorithm declaration file
// 'user/cxx_integers_echo/1.json'
#ifndef _BEAT_SETUP_H_
#define _BEAT_SETUP_H_
extern "C" {
void setup_beat_cxx_module();
}
#endif
// NOTE: This file was automatically generated from the dataformat declaration file
// 'user/single_integer/1.json'
#include "user_single_integer_1.h"
#include <beat.backend.cxx/dataformatfactory.h>
using namespace beat::backend::cxx;
dataformats::user::single_integer_1::single_integer_1()
{
}
//---------------------------------------------------------
size_t dataformats::user::single_integer_1::fixed_size()
{
return sizeof(int32_t);
}
//---------------------------------------------------------
size_t dataformats::user::single_integer_1::size() const
{
return dataformats::user::single_integer_1::fixed_size();
}
//---------------------------------------------------------
void dataformats::user::single_integer_1::pack(uint8_t** buffer) const
{
beat::backend::cxx::pack(value, buffer);
}
//---------------------------------------------------------
void dataformats::user::single_integer_1::unpack(uint8_t** buffer)
{
value = beat::backend::cxx::unpack_scalar<int32_t>(buffer);
}
//---------------------------------------------------------
Data* dataformats::user::single_integer_1::create()
{
return new user::single_integer_1();
}
//---------------------------------------------------------
const char *dataformats::user::single_integer_1::getNameStatic()
{
return "user/single_integer/1";
}
//---------------------------------------------------------
std::string dataformats::user::single_integer_1::toJson() const
{
return "{"
"\"field\":\"int32_t\""
"}";
}
// NOTE: This file was automatically generated from the dataformat declaration file
// 'user/single_integer/1.json'
#ifndef _BEAT_GENERATED_user_single_integer_1_H_
#define _BEAT_GENERATED_user_single_integer_1_H_
#include <beat.backend.cxx/data.h>
namespace dataformats {
namespace user {
class single_integer_1: public beat::backend::cxx::DataImpl<single_integer_1>
{
public:
single_integer_1();
static size_t fixed_size();
size_t size() const override;
void pack(uint8_t** buffer) const override;
void unpack(uint8_t** buffer) override;
static Data* create();
static const char *getNameStatic();
std::string toJson() const override;
public:
int32_t value;
};
} // user
} // dataformats
#endif
{
"schema_version": 2,
"language": "cxx",
"api_version": 2,
"type": "legacy",
"splittable": true,
"groups": [
{
"name": "main",
"inputs": {
"in_data": {
"type": "user/single_integer/1"
}
},
"outputs": {
"out_data": {
"type": "user/single_integer/1"
}
}
}
]
}
cmake_minimum_required(VERSION 3.0)
project(BEAT_CORE_CXX_INTEGERS_ECHO_LEGACY)
set(BEAT_BACKEND_CXX_DIR "/usr/local/beat")
# CMake setup
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if (COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif (COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
# Retrieve the dependencies
find_package(Boost REQUIRED)
# Setup the search paths
include_directories(
"${BEAT_BACKEND_CXX_DIR}/include"
"${Boost_INCLUDE_DIRS}"
)
link_directories(
"${BEAT_BACKEND_CXX_DIR}/bin"
)
# List the source files
set(HEADERS "algorithm.h"
"beat_setup.h"
"user_single_integer_1.h"
)
set(SRCS "algorithm.cpp"
"beat_setup.cpp"
"user_single_integer_1.cpp"
)