ifw-daq  3.0.0-pre2
IFW Data Acquisition modules
Classes | Typedefs | Enumerations | Functions | Variables
daq::json Namespace Reference

Classes

struct  KeywordFilter
 
struct  KeywordTransform
 
struct  FitsKeywordsSource
 
struct  FitsFileSource
 
struct  DpSpecError
 
struct  DpSpec
 Close representation of the JSON structure but with stronger types. More...
 
struct  Location
 Describes parsed location string into its components "host" and "path". More...
 
struct  SchemaError
 JSON Schema error. More...
 
struct  StartDaqV2SpecError
 
struct  StartDaqV2Spec
 Structure with a close mapping from JSON representation in the StartDaqV2 MAL request. More...
 
class  TestParseLocation
 
class  TestParseDpSpec
 
class  TestParseStartDaqV2Spec
 

Typedefs

using KeywordRuleTypes = std::variant< KeywordFilter, KeywordTransform >
 
using KeywordRules = std::vector< KeywordRuleTypes >
 
using ErrorType = StartDaqV2SpecError
 

Enumerations

enum class  InitialKeywords { All , User , None }
 

Functions

bool operator== (KeywordFilter const &lhs, KeywordFilter const &rhs) noexcept
 
bool operator== (KeywordTransform const &lhs, KeywordTransform const &rhs) noexcept
 
bool operator== (FitsKeywordsSource const &lhs, FitsKeywordsSource const &rhs) noexcept
 
bool operator== (FitsFileSource const &lhs, FitsFileSource const &rhs) noexcept
 
FitsKeywordsSource ParseFitsKeywordsSource (Json const &json, JsonPointer const &breadcrumb)
 
FitsFileSource ParseFitsFileSource (Json const &json, JsonPointer const &breadcrumb)
 
KeywordFilter ParseKeywordFilter (Json const &json, JsonPointer const &breadcrumb)
 
KeywordTransform ParseKeywordTransform (Json const &json, JsonPointer const &breadcrumb)
 
InitialKeywords ParseInitialKeywords (nlohmann::json const &json, nlohmann::json_pointer< nlohmann::json > const &breadcrumb)
 
KeywordRules ParseKeywordRules (Json const &json, JsonPointer const &breadcrumb)
 
void to_json (nlohmann::json &out, KeywordFilter const &s)
 
void to_json (nlohmann::json &out, KeywordTransform const &s)
 
void to_json (nlohmann::json &out, KeywordRuleTypes const &s)
 
void to_json (nlohmann::json &out, FitsKeywordsSource const &s)
 
void to_json (nlohmann::json &out, FitsFileSource const &s)
 
DpSpec::Target ParseTarget (Json const &json, JsonPointer const &breadcrumb)
 
DpSpec::SourceTypes ParseSource (Json const &json, JsonPointer const &breadcrumb)
 
DpSpec ParseDpSpec (nlohmann::json const &spec)
 Parse JSON to construct the DpSpec structure. More...
 
Location ParseSourceLocation (std::string const &location)
 Parse location string from DpSpec into component parts. More...
 
void to_json (nlohmann::json &j, DpSpec const &s)
 
void to_json (nlohmann::json &j, DpSpec::Target const &s)
 
void to_json (nlohmann::json &j, DpSpec::SourceTypes const &s)
 
KeywordFilter ParseKeywordFilter (nlohmann::json const &json, nlohmann::json_pointer< nlohmann::json > const &breadcrumb)
 
KeywordTransform ParseKeywordTransform (nlohmann::json const &json, nlohmann::json_pointer< nlohmann::json > const &breadcrumb)
 
KeywordRules ParseKeywordRules (nlohmann::json const &json, nlohmann::json_pointer< nlohmann::json > const &breadcrumb)
 
FitsKeywordsSource ParseFitsKeywordsSource (nlohmann::json const &json, nlohmann::json_pointer< nlohmann::json > const &breadcrumb)
 
FitsFileSource ParseFitsFileSource (nlohmann::json const &json, nlohmann::json_pointer< nlohmann::json > const &breadcrumb)
 
bool operator== (StartDaqV2Spec::PrimaryDataSource const &lhs, StartDaqV2Spec::PrimaryDataSource const &rhs) noexcept
 
bool operator== (StartDaqV2Spec::MetadataSource const &lhs, StartDaqV2Spec::MetadataSource const &rhs) noexcept
 
bool operator== (StartDaqV2Spec::MergeTarget const &lhs, StartDaqV2Spec::MergeTarget const &rhs) noexcept
 
bool operator== (StartDaqV2Spec const &lhs, StartDaqV2Spec const &rhs) noexcept
 
StartDaqV2Spec ParseStartDaqV2Spec (nlohmann::json const &json)
 Parse StartDaqSpec. More...
 
void to_json (nlohmann::json &json, StartDaqV2Spec const &spec)
 Serialize to JSON. More...
 
void ParseDataSource (StartDaqV2Spec::DataSource &out, Json const &json, JsonPointer const &breadcrumb)
 Parse the common parts of PrimaryDataSource and MetadataSource. More...
 
void to_json (nlohmann::json &out, StartDaqV2Spec::DataSource const &s)
 
void to_json (nlohmann::json &out, StartDaqV2Spec::PrimaryDataSource const &s)
 
void to_json (nlohmann::json &out, StartDaqV2Spec::MetadataSource const &s)
 
void to_json (nlohmann::json &out, StartDaqV2Spec::DataSourceTypes const &s)
 
void to_json (nlohmann::json &out, StartDaqV2Spec::MergeTarget const &t)
 
 TEST_F (TestParseLocation, ParseSucceeds)
 
 TEST_F (TestParseLocation, ParseFails)
 
 TEST_F (TestParseDpSpec, ParseSucceeds)
 
 TEST_F (TestParseDpSpec, ParseSucceedsWithOptionalTarget)
 
 TEST_F (TestParseDpSpec, ParseSucceedsWithOptionalSources)
 
 TEST_F (TestParseDpSpec, ParseSucceedsWithOptionalSourcesEmpty)
 
 TEST_F (TestParseDpSpec, ParseFailsWithMissingId)
 
 TEST_F (TestParseDpSpec, ParseFailsWithMissingFileId)
 
 TEST_F (TestParseDpSpec, ParseFailsWithFileIdWrongType)
 
 TEST_F (TestParseDpSpec, ParseFailsWithKeywordsBadType)
 
 TEST_F (TestParseDpSpec, ParseFailsWithKeywordsNotDefined)
 
 TEST_F (TestParseDpSpec, ParseSucceedsWithKeywordRulesNotDefined)
 
 TEST_F (TestParseDpSpec, ParseFailsWithMissingSources)
 
 TEST_F (TestParseDpSpec, ParseFailsWithUnknownSourceType)
 
 TEST_F (TestParseDpSpec, ParseFailsWithUnknownSourceTypeNotObject)
 
 TEST_F (TestParseDpSpec, ParseFailsWithUnknownSourcesWrongType)
 
 TEST_F (TestParseStartDaqV2Spec, RoundTripParsing)
 
 TEST_F (TestParseStartDaqV2Spec, SuccessfulTemplate)
 

Variables

daq::json::TestParseStartDaqV2Spec _json
 
nlohmann::json m_spec
 

Class Documentation

◆ daq::json::KeywordFilter

struct daq::json::KeywordFilter

Definition at line 38 of file commonSpecTypes.hpp.

Class Members
vector< string > selection_patterns

◆ daq::json::KeywordTransform

struct daq::json::KeywordTransform

Definition at line 42 of file commonSpecTypes.hpp.

Class Members
string format
string regex
vector< string > selection_patterns

◆ daq::json::FitsKeywordsSource

struct daq::json::FitsKeywordsSource

Definition at line 54 of file commonSpecTypes.hpp.

Class Members
optional< InitialKeywords > initial_keywords
KeywordRules keyword_rules
KeywordVector keywords
string source_name

◆ daq::json::FitsFileSource

struct daq::json::FitsFileSource

Definition at line 62 of file commonSpecTypes.hpp.

Class Members
optional< InitialKeywords > initial_keywords
KeywordRules keyword_rules
string location
string source_name

◆ daq::json::DpSpec

struct daq::json::DpSpec

Close representation of the JSON structure but with stronger types.

Definition at line 30 of file dpSpec.hpp.

Class Members
typedef variant< FitsKeywordsSource, FitsFileSource > SourceTypes
Class Members
string id
vector< SourceTypes > sources
Target target

◆ daq::json::StartDaqV2Spec

struct daq::json::StartDaqV2Spec

Structure with a close mapping from JSON representation in the StartDaqV2 MAL request.

Parts of this will end up being used in CreateDataProductSpecification(), like the keyword rules.

Definition at line 33 of file startDaqV2.hpp.

Class Members
typedef variant< PrimaryDataSource, MetadataSource, FitsKeywordsSource, FitsFileSource > DataSourceTypes
Class Members
optional< milliseconds > await_completion_interval
string file_prefix
string id
optional< MergeTarget > merge_target
vector< DataSourceTypes > sources

Typedef Documentation

◆ ErrorType

Definition at line 20 of file startDaqV2.cpp.

◆ KeywordRules

using daq::json::KeywordRules = typedef std::vector<KeywordRuleTypes>

Definition at line 52 of file commonSpecTypes.hpp.

◆ KeywordRuleTypes

Definition at line 51 of file commonSpecTypes.hpp.

Enumeration Type Documentation

◆ InitialKeywords

Enumerator
All 

Keep all keywords (useful for in-place merge)

User 

Keep only user-keywords.

None 

Keeps nothing (useful for disabling keyword copying)

Definition at line 21 of file commonSpecTypes.hpp.

Function Documentation

◆ operator==() [1/8]

bool daq::json::operator== ( FitsFileSource const &  lhs,
FitsFileSource const &  rhs 
)
noexcept

Definition at line 34 of file commonSpecTypes.cpp.

◆ operator==() [2/8]

bool daq::json::operator== ( FitsKeywordsSource const &  lhs,
FitsKeywordsSource const &  rhs 
)
noexcept

Definition at line 29 of file commonSpecTypes.cpp.

◆ operator==() [3/8]

bool daq::json::operator== ( KeywordFilter const &  lhs,
KeywordFilter const &  rhs 
)
noexcept

Definition at line 20 of file commonSpecTypes.cpp.

◆ operator==() [4/8]

bool daq::json::operator== ( KeywordTransform const &  lhs,
KeywordTransform const &  rhs 
)
noexcept

Definition at line 24 of file commonSpecTypes.cpp.

◆ operator==() [5/8]

bool daq::json::operator== ( StartDaqV2Spec const &  lhs,
StartDaqV2Spec const &  rhs 
)
noexcept

Definition at line 134 of file startDaqV2.cpp.

◆ operator==() [6/8]

bool daq::json::operator== ( StartDaqV2Spec::MergeTarget const &  lhs,
StartDaqV2Spec::MergeTarget const &  rhs 
)
noexcept

Definition at line 129 of file startDaqV2.cpp.

◆ operator==() [7/8]

bool daq::json::operator== ( StartDaqV2Spec::MetadataSource const &  lhs,
StartDaqV2Spec::MetadataSource const &  rhs 
)
noexcept

Definition at line 123 of file startDaqV2.cpp.

◆ operator==() [8/8]

bool daq::json::operator== ( StartDaqV2Spec::PrimaryDataSource const &  lhs,
StartDaqV2Spec::PrimaryDataSource const &  rhs 
)
noexcept

Definition at line 117 of file startDaqV2.cpp.

◆ ParseDataSource()

void daq::json::ParseDataSource ( StartDaqV2Spec::DataSource out,
Json const &  json,
JsonPointer const &  breadcrumb 
)

Parse the common parts of PrimaryDataSource and MetadataSource.

{
  "sourceName": <str>,
  "rrUri": <str>,
  "keywordRules": [<keywordrules]
}

Definition at line 31 of file startDaqV2.cpp.

◆ ParseDpSpec()

DpSpec daq::json::ParseDpSpec ( nlohmann::json const &  spec)

Parse JSON to construct the DpSpec structure.

Parameters
specData Product Specification to parse.
Exceptions
DpSpecErrorif JSON structure is invalid. Exception may be nested.

Definition at line 47 of file dpSpec.cpp.

◆ ParseFitsFileSource() [1/2]

FitsFileSource daq::json::ParseFitsFileSource ( Json const &  json,
JsonPointer const &  breadcrumb 
)

Definition at line 60 of file commonSpecTypes.cpp.

◆ ParseFitsFileSource() [2/2]

FitsFileSource daq::json::ParseFitsFileSource ( nlohmann::json const &  json,
nlohmann::json_pointer< nlohmann::json > const &  breadcrumb 
)

◆ ParseFitsKeywordsSource() [1/2]

FitsKeywordsSource daq::json::ParseFitsKeywordsSource ( Json const &  json,
JsonPointer const &  breadcrumb 
)

Definition at line 39 of file commonSpecTypes.cpp.

◆ ParseFitsKeywordsSource() [2/2]

FitsKeywordsSource daq::json::ParseFitsKeywordsSource ( nlohmann::json const &  json,
nlohmann::json_pointer< nlohmann::json > const &  breadcrumb 
)

◆ ParseInitialKeywords()

InitialKeywords daq::json::ParseInitialKeywords ( nlohmann::json const &  json,
nlohmann::json_pointer< nlohmann::json > const &  breadcrumb 
)

Definition at line 96 of file commonSpecTypes.cpp.

◆ ParseKeywordFilter() [1/2]

KeywordFilter daq::json::ParseKeywordFilter ( Json const &  json,
JsonPointer const &  breadcrumb 
)

Definition at line 72 of file commonSpecTypes.cpp.

◆ ParseKeywordFilter() [2/2]

KeywordFilter daq::json::ParseKeywordFilter ( nlohmann::json const &  json,
nlohmann::json_pointer< nlohmann::json > const &  breadcrumb 
)

◆ ParseKeywordRules() [1/2]

KeywordRules daq::json::ParseKeywordRules ( Json const &  json,
JsonPointer const &  breadcrumb 
)

Definition at line 114 of file commonSpecTypes.cpp.

◆ ParseKeywordRules() [2/2]

KeywordRules daq::json::ParseKeywordRules ( nlohmann::json const &  json,
nlohmann::json_pointer< nlohmann::json > const &  breadcrumb 
)

◆ ParseKeywordTransform() [1/2]

KeywordTransform daq::json::ParseKeywordTransform ( Json const &  json,
JsonPointer const &  breadcrumb 
)

Definition at line 83 of file commonSpecTypes.cpp.

◆ ParseKeywordTransform() [2/2]

KeywordTransform daq::json::ParseKeywordTransform ( nlohmann::json const &  json,
nlohmann::json_pointer< nlohmann::json > const &  breadcrumb 
)

◆ ParseSource()

DpSpec::SourceTypes daq::json::ParseSource ( Json const &  json,
JsonPointer const &  breadcrumb 
)

Definition at line 34 of file dpSpec.cpp.

◆ ParseSourceLocation()

Location daq::json::ParseSourceLocation ( std::string const &  location)

Parse location string from DpSpec into component parts.

Location string use the format host:path, e.g. 10.0.0.1:/path/to/file with host being optional.

Definition at line 90 of file dpSpec.cpp.

◆ ParseStartDaqV2Spec()

StartDaqV2Spec daq::json::ParseStartDaqV2Spec ( nlohmann::json const &  json)

Parse StartDaqSpec.

Exceptions
StartDaqV2SpecErroron invalid schema.

Definition at line 46 of file startDaqV2.cpp.

◆ ParseTarget()

DpSpec::Target daq::json::ParseTarget ( Json const &  json,
JsonPointer const &  breadcrumb 
)

Definition at line 20 of file dpSpec.cpp.

◆ TEST_F() [1/18]

daq::json::TEST_F ( TestParseDpSpec  ,
ParseFailsWithFileIdWrongType   
)

Definition at line 241 of file testDpSpec.cpp.

◆ TEST_F() [2/18]

daq::json::TEST_F ( TestParseDpSpec  ,
ParseFailsWithKeywordsBadType   
)

Definition at line 248 of file testDpSpec.cpp.

◆ TEST_F() [3/18]

daq::json::TEST_F ( TestParseDpSpec  ,
ParseFailsWithKeywordsNotDefined   
)

Definition at line 255 of file testDpSpec.cpp.

◆ TEST_F() [4/18]

daq::json::TEST_F ( TestParseDpSpec  ,
ParseFailsWithMissingFileId   
)

Definition at line 235 of file testDpSpec.cpp.

◆ TEST_F() [5/18]

daq::json::TEST_F ( TestParseDpSpec  ,
ParseFailsWithMissingId   
)

Definition at line 229 of file testDpSpec.cpp.

◆ TEST_F() [6/18]

daq::json::TEST_F ( TestParseDpSpec  ,
ParseFailsWithMissingSources   
)

Definition at line 265 of file testDpSpec.cpp.

◆ TEST_F() [7/18]

daq::json::TEST_F ( TestParseDpSpec  ,
ParseFailsWithUnknownSourcesWrongType   
)

Definition at line 287 of file testDpSpec.cpp.

◆ TEST_F() [8/18]

daq::json::TEST_F ( TestParseDpSpec  ,
ParseFailsWithUnknownSourceType   
)

Definition at line 273 of file testDpSpec.cpp.

◆ TEST_F() [9/18]

daq::json::TEST_F ( TestParseDpSpec  ,
ParseFailsWithUnknownSourceTypeNotObject   
)

Definition at line 280 of file testDpSpec.cpp.

◆ TEST_F() [10/18]

daq::json::TEST_F ( TestParseDpSpec  ,
ParseSucceeds   
)

Definition at line 175 of file testDpSpec.cpp.

◆ TEST_F() [11/18]

daq::json::TEST_F ( TestParseDpSpec  ,
ParseSucceedsWithKeywordRulesNotDefined   
)

Definition at line 260 of file testDpSpec.cpp.

◆ TEST_F() [12/18]

daq::json::TEST_F ( TestParseDpSpec  ,
ParseSucceedsWithOptionalSources   
)

Definition at line 219 of file testDpSpec.cpp.

◆ TEST_F() [13/18]

daq::json::TEST_F ( TestParseDpSpec  ,
ParseSucceedsWithOptionalSourcesEmpty   
)

Definition at line 224 of file testDpSpec.cpp.

◆ TEST_F() [14/18]

daq::json::TEST_F ( TestParseDpSpec  ,
ParseSucceedsWithOptionalTarget   
)

Definition at line 214 of file testDpSpec.cpp.

◆ TEST_F() [15/18]

daq::json::TEST_F ( TestParseLocation  ,
ParseFails   
)

Definition at line 48 of file testDpSpec.cpp.

◆ TEST_F() [16/18]

daq::json::TEST_F ( TestParseLocation  ,
ParseSucceeds   
)

Definition at line 20 of file testDpSpec.cpp.

◆ TEST_F() [17/18]

daq::json::TEST_F ( TestParseStartDaqV2Spec  ,
RoundTripParsing   
)

Definition at line 103 of file testStartDaqV2.cpp.

◆ TEST_F() [18/18]

daq::json::TEST_F ( TestParseStartDaqV2Spec  ,
SuccessfulTemplate   
)

Definition at line 112 of file testStartDaqV2.cpp.

◆ to_json() [1/14]

void daq::json::to_json ( nlohmann::json &  j,
DpSpec const &  s 
)

Definition at line 129 of file dpSpec.cpp.

◆ to_json() [2/14]

void daq::json::to_json ( nlohmann::json &  j,
DpSpec::SourceTypes const &  s 
)

Definition at line 142 of file dpSpec.cpp.

◆ to_json() [3/14]

void daq::json::to_json ( nlohmann::json &  j,
DpSpec::Target const &  s 
)

Definition at line 134 of file dpSpec.cpp.

◆ to_json() [4/14]

void daq::json::to_json ( nlohmann::json &  json,
StartDaqV2Spec const &  spec 
)

Serialize to JSON.

Parameters
json
specSpecification to serialize

Definition at line 174 of file startDaqV2.cpp.

◆ to_json() [5/14]

void daq::json::to_json ( nlohmann::json &  out,
FitsFileSource const &  s 
)

Definition at line 165 of file commonSpecTypes.cpp.

◆ to_json() [6/14]

void daq::json::to_json ( nlohmann::json &  out,
FitsKeywordsSource const &  s 
)

Definition at line 153 of file commonSpecTypes.cpp.

◆ to_json() [7/14]

void daq::json::to_json ( nlohmann::json &  out,
KeywordFilter const &  s 
)

Definition at line 135 of file commonSpecTypes.cpp.

◆ to_json() [8/14]

void daq::json::to_json ( nlohmann::json &  out,
KeywordRuleTypes const &  s 
)

Definition at line 148 of file commonSpecTypes.cpp.

◆ to_json() [9/14]

void daq::json::to_json ( nlohmann::json &  out,
KeywordTransform const &  s 
)

Definition at line 140 of file commonSpecTypes.cpp.

◆ to_json() [10/14]

void daq::json::to_json ( nlohmann::json &  out,
StartDaqV2Spec::DataSource const &  s 
)

Definition at line 141 of file startDaqV2.cpp.

◆ to_json() [11/14]

void daq::json::to_json ( nlohmann::json &  out,
StartDaqV2Spec::DataSourceTypes const &  s 
)

Definition at line 164 of file startDaqV2.cpp.

◆ to_json() [12/14]

void daq::json::to_json ( nlohmann::json &  out,
StartDaqV2Spec::MergeTarget const &  t 
)

Definition at line 169 of file startDaqV2.cpp.

◆ to_json() [13/14]

void daq::json::to_json ( nlohmann::json &  out,
StartDaqV2Spec::MetadataSource const &  s 
)

Definition at line 158 of file startDaqV2.cpp.

◆ to_json() [14/14]

void daq::json::to_json ( nlohmann::json &  out,
StartDaqV2Spec::PrimaryDataSource const &  s 
)

Definition at line 152 of file startDaqV2.cpp.

Variable Documentation

◆ _json

◆ m_spec

nlohmann::json daq::json::m_spec

Definition at line 100 of file testStartDaqV2.cpp.