Commit 82077a7a authored by Alejandro Homs Puron's avatar Alejandro Homs Puron Committed by Generic Bliss account for Control Software
Browse files

[CORE] Add lima::hw::config to control & acquisition:

* Validate the requirements of the HW config concept
parent 9d611723
......@@ -39,6 +39,10 @@ namespace concepts
constexpr auto has_acq_params =
boost::hana::is_valid([](auto t) -> boost::hana::type<typename decltype(t)::type::acq_params_t> {});
// Type should define acq_info_t nested type
constexpr auto has_acq_info =
boost::hana::is_valid([](auto t) -> boost::hana::type<typename decltype(t)::type::acq_info_t> {});
// Type should define data_t nested type
constexpr auto has_data_type =
boost::hana::is_valid([](auto t) -> boost::hana::type<typename decltype(t)::type::data_t> {});
......@@ -86,18 +90,5 @@ namespace concepts
constexpr auto has_nb_images_acquired =
boost::hana::is_valid([](auto t) -> decltype(boost::hana::traits::declval(t).nb_images_acquired()) {});
/// Everything that is common to the control and acquisition parts of the camera.
/// As of now, it is mostly defining types.
template <typename Config>
struct config
{
// Concept checking
static_assert(has_properties(boost::hana::type_c<Config>), "Config requires properties nested type");
static_assert(has_init_params(boost::hana::type_c<Config>), "Config requires init_params_t nested type");
static_assert(has_acq_params(boost::hana::type_c<Config>), "Config requires acq_params_t nested type");
static_assert(has_data_type(boost::hana::type_c<Config>), "Config requires data_t static member");
static_assert(has_capabilities(boost::hana::type_c<Config>), "Config requires capabilities static member");
};
} // namespace concepts
} // namespace lima
......@@ -6,6 +6,8 @@
#pragma once
#include <lima/hw/config.hpp>
namespace lima
{
namespace hw
......@@ -14,9 +16,7 @@ namespace hw
class acquisition
{
// Concept checking
// TODO: Add more concept checking
using config_t = Config;
using config_t = config<Config>;
public:
using data_t = typename config_t::data_t;
......
......@@ -24,17 +24,20 @@ namespace hw
/// Everything that is common to the control and acquisition parts of the camera.
/// As of now, it is mostly defining types.
template <typename Config>
struct config
struct config : Config
{
using base_t = Config;
// Concept checking
static_assert(concepts::has_properties(boost::hana::type_c<Config>), "Config requires properties nested type");
static_assert(concepts::has_init_params(boost::hana::type_c<Config>),
"Config requires init_params nested type");
static_assert(concepts::has_acq_params(boost::hana::type_c<Config>), "Config requires params nested type");
static_assert(concepts::has_data_type(boost::hana::type_c<Config>), "Config requires data static member");
public:
using base_t = Config;
"Config requires init_params_t nested type");
static_assert(concepts::has_acq_params(boost::hana::type_c<Config>),
"Config requires acq_params_t nested type");
static_assert(concepts::has_acq_info(boost::hana::type_c<Config>), "Config requires acq_info_t nested type");
static_assert(concepts::has_data_type(boost::hana::type_c<Config>), "Config requires data_t static member");
// static_assert(concepts::has_capabilities(boost::hana::type_c<Config>),
// "Config requires capabilities static member");
/// Define the input data type
using data_t = typename Config::data_t;
......@@ -43,7 +46,6 @@ namespace hw
using init_params_t = typename Config::init_params_t;
using acq_params_t = typename Config::acq_params_t;
using acq_info_t = typename Config::acq_info_t;
using acquisition_uid_t = uuid;
};
} // namespace hw
......
......@@ -14,6 +14,7 @@
#include <boost/mpi.hpp>
#include <lima/hw/info.hpp>
#include <lima/hw/config.hpp>
namespace lima
{
......@@ -23,9 +24,7 @@ namespace hw
class control
{
// Concept checking
// TODO: Add more concept checking
using config_t = Config;
using config_t = config<Config>;
public:
using init_params_t = typename config_t::init_params_t;
......
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