diff --git a/src/config.cc b/src/config.cc index 072dfb201c13bfef0ab3a4d98cbfab37ad759290..cd38d6d27f3f58bb99e474c4306ca25bcd957c1e 100644 --- a/src/config.cc +++ b/src/config.cc @@ -56,7 +56,7 @@ Config::Config(std::string_view filename) : dict_(filename), // Setup configs input_type_(ToInputType(dict_.Get("input"))), - scone_address_(dict_.Get("scone_host"), dict_.Get("scone_port"), dict_.Get("scone_board")), + scone_address_(dict_.Get<SconeAddress>("scone_address")), dma_device_(dict_.Get("dma_dev")), port_(dict_.Get<int>("port")), num_threads_(dict_.Get<uint32_t>("threads")), diff --git a/src/config.h b/src/config.h index 0c5d366607c7fc2502a49fc66940c3518a60e2df..0a7673dc15bb2b30d4e1f7cfc979db97545b56d9 100644 --- a/src/config.h +++ b/src/config.h @@ -13,6 +13,23 @@ #include "log.h" +struct SconeAddress { + std::string host; + std::string port; + std::string board; + + SconeAddress() = default; + SconeAddress(std::string_view h, std::string_view p, std::string_view b) + : host(h), port(p), board(b) { + assert(!host.empty() && !port.empty() && !board.empty()); + } + + friend std::ostream &operator<<(std::ostream &os, const SconeAddress &scone) { + os << scone.host << ":" << scone.port << "/" << scone.board; + return os; + } +}; + class StreamConfig { public: const std::string processor_name_; @@ -100,6 +117,9 @@ class ConfigMap { return StreamConfig(Get<std::string>("processor_type", v), Get<std::string>("primitive_type", v), Get<uint32_t>("source_id", v), Get<uint32_t>("tcp_dest_port", v)); + } else if constexpr (std::is_same_v<T, struct SconeAddress>) { + return SconeAddress(Get<std::string>("host", v), Get<std::string>("port", v), + Get<std::string>("board", v)); } else { std::string str(v.asString()); if constexpr (std::is_same_v<T, std::string>) @@ -135,8 +155,6 @@ class ConfigMap { } }; -class StreamConfig; - class Config { ConfigMap dict_; @@ -144,23 +162,6 @@ class Config { enum class InputType { WZDMA, FILEDMA, TCPIP, MICRONDMA, FILE }; enum class ProcessorType { PASS_THROUGH, GMT, CALO, BRIL }; - struct SconeAddress { - std::string host; - std::string port; - std::string board; - - SconeAddress() = default; - SconeAddress(std::string_view h, std::string_view p, std::string_view b) - : host(h), port(p), board(b) { - assert(!host.empty() && !port.empty() && !board.empty()); - } - - friend std::ostream &operator<<(std::ostream &os, const SconeAddress &scone) { - os << scone.host << ":" << scone.port << "/" << scone.board; - return os; - } - }; - explicit Config(std::string_view filename); void print() const; const StreamConfig &GetStreamConfigById(uint32_t stream_id) const;