ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
CrestBaseResponse Class Referenceabstract

#include <CrestModel.h>

Inheritance diagram for CrestBaseResponse:
Collaboration diagram for CrestBaseResponse:

Public Member Functions

virtual ~CrestBaseResponse ()=default
 
json to_json () const
 
void load_from_json (const json &j)
 
virtual const char * getFormat () const =0
 
virtual int64_t getSize () const =0
 

Public Attributes

std::optional< std::string > datatype
 
std::optional< RespPagepage
 
std::optional< GenericMapfilter
 

Detailed Description

Definition at line 40 of file CrestModel.h.

Constructor & Destructor Documentation

◆ ~CrestBaseResponse()

virtual CrestBaseResponse::~CrestBaseResponse ( )
virtualdefault

Member Function Documentation

◆ getFormat()

virtual const char* CrestBaseResponse::getFormat ( ) const
pure virtual

◆ getSize()

virtual int64_t CrestBaseResponse::getSize ( ) const
pure virtual

◆ load_from_json()

void CrestBaseResponse::load_from_json ( const json j)

Definition at line 85 of file CrestModel.cxx.

86 {
87  if (j.contains("datatype"))
88  datatype = j.value("datatype", "");
89  // Check for the presence of "page" key and create an optional
90  if (j.contains("page"))
91  {
92  if (!j["page"].is_null())
93  {
94  page = std::make_optional((RespPage::from_json(j["page"])));
95  }
96  }
97 
98  // Check for the presence of "filter" key and create an optional
99  filter = j.contains("filter") ? std::make_optional(GenericMap::from_json(j["filter"])) : std::nullopt;
100 }

◆ to_json()

json CrestBaseResponse::to_json ( ) const

Definition at line 54 of file CrestModel.cxx.

55 {
56  json result = {};
57  if (datatype.has_value())
58  result["datatype"] = datatype.value();
59  result["format"] = getFormat();
60  result["size"] = getSize();
61 
62  // Check if the 'page' optional contains a value
63  if (page.has_value())
64  {
65  // Check if the value of 'page' is not null
66  if (!page.value().to_json().is_null())
67  {
68  result["page"] = page.value().to_json();
69  }
70  }
71 
72  // Check if the 'filter' optional contains a value
73  if (filter.has_value())
74  {
75  // Check if the value of 'filter' is not null
76  if (!filter.value().to_json().is_null())
77  {
78  result["filter"] = filter.value().to_json();
79  }
80  }
81 
82  return result;
83 }

Member Data Documentation

◆ datatype

std::optional<std::string> CrestBaseResponse::datatype

Definition at line 45 of file CrestModel.h.

◆ filter

std::optional<GenericMap> CrestBaseResponse::filter

Definition at line 47 of file CrestModel.h.

◆ page

std::optional<RespPage> CrestBaseResponse::page

Definition at line 46 of file CrestModel.h.


The documentation for this class was generated from the following files:
get_generator_info.result
result
Definition: get_generator_info.py:21
RespPage::from_json
static RespPage from_json(const json &j)
Definition: CrestModel.cxx:20
json
nlohmann::json json
Definition: HistogramDef.cxx:9
CrestBaseResponse::getSize
virtual int64_t getSize() const =0
CrestBaseResponse::filter
std::optional< GenericMap > filter
Definition: CrestModel.h:47
CrestBaseResponse::getFormat
virtual const char * getFormat() const =0
CrestBaseResponse::datatype
std::optional< std::string > datatype
Definition: CrestModel.h:45
CrestBaseResponse::page
std::optional< RespPage > page
Definition: CrestModel.h:46
GenericMap::from_json
static GenericMap from_json(const json &j)
Definition: CrestModel.cxx:41