From 50af1fefd53af52255658ce45bc50681c474f785 Mon Sep 17 00:00:00 2001 From: Owen Green Date: Sun, 11 Apr 2021 00:48:54 +0100 Subject: [PATCH] Expand Macros, Fix Repetition: DataSetWr --- include/clients/rt/FluidDataSetWr.hpp | 35 ++++++++++++++++++++------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/include/clients/rt/FluidDataSetWr.hpp b/include/clients/rt/FluidDataSetWr.hpp index e41e867..028fcd4 100644 --- a/include/clients/rt/FluidDataSetWr.hpp +++ b/include/clients/rt/FluidDataSetWr.hpp @@ -19,17 +19,33 @@ namespace fluid { namespace client { +namespace datasetwr { + +enum { kDataSet, kIDPrefix, kIDNumber, kBuffer }; + +constexpr std::initializer_list idNumberDefaults{0, 0}; + +constexpr auto DataSetWrParams = defineParameters( + DataSetClientRef::makeParam("dataSet", "DataSet ID"), + StringParam("idPrefix", "ID Prefix"), + LongArrayParam("idNumber", "ID Counter Offset", idNumberDefaults), + BufferParam("buf", "Data Buffer")); class DataSetWriterClient : public FluidBaseClient, OfflineIn, OfflineOut { - enum { kDataSet, kIDPrefix, kIDNumber, kBuffer }; - static constexpr std::initializer_list idNumberDefaults{0, 0}; public: - FLUID_DECLARE_PARAMS(DataSetClientRef::makeParam("dataSet", "DataSet ID"), - StringParam("idPrefix", "ID Prefix"), - LongArrayParam("idNumber", "ID Counter Offset", - idNumberDefaults), - BufferParam("buf", "Data Buffer")); + using ParamDescType = decltype(DataSetWrParams); + + using ParamSetViewType = ParameterSetView; + std::reference_wrapper mParams; + + void setParams(ParamSetViewType &p) { mParams = p; } + + template auto &get() const { + return mParams.get().template get(); + } + + static constexpr auto &getParameterDescriptors() { return DataSetWrParams; } DataSetWriterClient(ParamSetViewType &p) : mParams(p) {} @@ -43,7 +59,7 @@ public: if (idPrefix.size() == 0 && idNumberArr[0] == 0) return {Result::Status::kError, "No ID supplied"}; - std::string id = idPrefix; + std::string id = idPrefix; if (idNumberArr[0] > 0) id += std::to_string(idNumberArr[1]); @@ -54,8 +70,9 @@ public: return {Result::Status::kError, "No DataSet"}; } }; +} // namespace datasetwr using NRTThreadedDataSetWriter = - NRTThreadingAdaptor>; + NRTThreadingAdaptor>; } // namespace client } // namespace fluid