Skip to content

Commit

Permalink
Add Decimation/Interpolation to node class.
Browse files Browse the repository at this point in the history
* A special tag PerformDecimationInterpolation is required for node be
enable decimation/interpolation.
* Add ports_status to simplify port limits checks.
* Add qa_node.cpp for unit tests of node class.
  • Loading branch information
drslebedev committed Jul 27, 2023
1 parent 97e20a7 commit 5db1a26
Show file tree
Hide file tree
Showing 6 changed files with 334 additions and 123 deletions.
34 changes: 21 additions & 13 deletions include/annotated.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ struct Visible {};
*/
struct BlockingIO {};

/**
* @brief Annotates node, indicating to perform decimation/interpolation
*/
struct PerformDecimationInterpolation {};

/**
* @brief Annotates templated node, indicating which port data types are supported.
*/
Expand Down Expand Up @@ -133,19 +138,23 @@ struct Annotated {

template<typename U>
Annotated &
operator=(const U &sv) noexcept requires std::is_same_v<T, std::string> && std::is_same_v<U, std::string_view> {
operator=(const U &sv) noexcept
requires std::is_same_v<T, std::string> && std::is_same_v<U, std::string_view>
{
value = std::string(sv); // Convert from std::string_view to std::string and assign
return *this;
}

operator std::string_view() const noexcept requires std::is_same_v<T, std::string> {
operator std::string_view() const noexcept
requires std::is_same_v<T, std::string>
{
return std::string_view(value); // Convert from std::string to std::string_view
}

// meta-information
static constexpr std::string_view
description() noexcept {
return std::string_view{description_};
return std::string_view{ description_ };
}

static constexpr std::string_view
Expand Down Expand Up @@ -189,14 +198,13 @@ struct unwrap_if_wrapped<fair::graph::Annotated<U, str, Args...>> {
* @brief A type trait class that extracts the underlying type `T` from an `Annotated` instance.
* If the given type is not an `Annotated`, it returns the type itself.
*/
template<typename T>
using unwrap_if_wrapped_t = typename unwrap_if_wrapped<T>::type;
template<typename T>
using unwrap_if_wrapped_t = typename unwrap_if_wrapped<T>::type;

} // namespace fair::graph

template<typename... Ts>
struct fair::meta::typelist<fair::graph::SupportedTypes<Ts...>> : fair::meta::typelist<Ts...> {
};
struct fair::meta::typelist<fair::graph::SupportedTypes<Ts...>> : fair::meta::typelist<Ts...> {};

#ifdef FMT_FORMAT_H_

Expand All @@ -222,12 +230,12 @@ struct fmt::formatter<fair::graph::Annotated<T, description, Arguments...>> {
};

namespace gr {
template<typename T, fair::meta::fixed_string description, typename... Arguments>
inline std::ostream &
operator<<(std::ostream &os, const fair::graph::Annotated<T, description, Arguments...> &v) {
// TODO: add switch for printing only brief and/or meta-information
return os << fmt::format("{}", v.value);
}
template<typename T, fair::meta::fixed_string description, typename... Arguments>
inline std::ostream &
operator<<(std::ostream &os, const fair::graph::Annotated<T, description, Arguments...> &v) {
// TODO: add switch for printing only brief and/or meta-information
return os << fmt::format("{}", v.value);
}
} // namespace gr

#endif // FMT_FORMAT_H_
Expand Down
Loading

0 comments on commit 5db1a26

Please sign in to comment.