ifw-daq  3.0.0-pre2
IFW Data Acquisition modules
startDaqV2.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  * @ingroup daq_libjson
4  * @copyright
5  * (c) Copyright ESO 2022
6  * All Rights Reserved
7  * ESO (eso.org) is an Intergovernmental Organisation, and therefore special legal conditions apply.
8  */
9 #ifndef DAQ_STARTDAQV2_HPP
10 #define DAQ_STARTDAQV2_HPP
11 #include <chrono>
12 #include <optional>
13 #include <variant>
14 #include <vector>
15 
16 #include <nlohmann/json.hpp>
17 
19 #include <daq/json/schemaError.hpp>
20 
21 namespace daq::json {
22 
24  using SchemaError::SchemaError;
25 };
26 
27 /**
28  * Structure with a close mapping from JSON representation in the StartDaqV2 MAL request.
29  *
30  * Parts of this will end up being used in `CreateDataProductSpecification()`, like the keyword
31  * rules.
32  */
34  struct DataSource {
35  std::string source_name;
36  std::string rr_uri;
37  std::optional<InitialKeywords> initial_keywords;
39  };
40  struct PrimaryDataSource final : DataSource {};
41  struct MetadataSource final : DataSource {};
42 
44  std::variant<PrimaryDataSource, MetadataSource, FitsKeywordsSource, FitsFileSource>;
45 
46  struct MergeTarget {
47  std::string source_name;
48  };
49 
50  std::string id;
51  std::vector<DataSourceTypes> sources;
52  std::optional<MergeTarget> merge_target;
53  std::optional<std::chrono::milliseconds> await_completion_interval;
54  std::string file_prefix;
55 };
56 
58  StartDaqV2Spec::PrimaryDataSource const& rhs) noexcept;
60  StartDaqV2Spec::MetadataSource const& rhs) noexcept;
62  StartDaqV2Spec::MergeTarget const& rhs) noexcept;
63 
64 bool operator==(StartDaqV2Spec const& lhs, StartDaqV2Spec const& rhs) noexcept;
65 
66 /**
67  * Parse StartDaqSpec
68  *
69  * @throw StartDaqV2SpecError on invalid schema.
70  */
71 StartDaqV2Spec ParseStartDaqV2Spec(nlohmann::json const& json);
72 
73 /**
74  * Serialize to JSON
75  *
76  * @param json
77  * @param spec Specification to serialize
78  */
79 void to_json(nlohmann::json& json, StartDaqV2Spec const& spec); // NOLINT
80 
81 } // namespace daq::json
82 
83 #endif // DAQ_STARTDAQV2_HPP
std::optional< MergeTarget > merge_target
Definition: startDaqV2.hpp:52
std::vector< KeywordRuleTypes > KeywordRules
std::optional< std::chrono::milliseconds > await_completion_interval
Definition: startDaqV2.hpp:53
bool operator==(KeywordFilter const &lhs, KeywordFilter const &rhs) noexcept
std::variant< PrimaryDataSource, MetadataSource, FitsKeywordsSource, FitsFileSource > DataSourceTypes
Definition: startDaqV2.hpp:44
StartDaqV2Spec ParseStartDaqV2Spec(nlohmann::json const &json)
Parse StartDaqSpec.
Definition: startDaqV2.cpp:46
void to_json(nlohmann::json &out, KeywordFilter const &s)
std::vector< DataSourceTypes > sources
Definition: startDaqV2.hpp:51
Structure with a close mapping from JSON representation in the StartDaqV2 MAL request.
Definition: startDaqV2.hpp:33
JSON Schema error.
Definition: schemaError.hpp:18
std::optional< InitialKeywords > initial_keywords
Definition: startDaqV2.hpp:37