Fawkes API  Fawkes Development Version
InterfaceMessageType Class Reference

InterfaceMessageType representation for JSON transfer. More...

#include <InterfaceMessageType.h>

Public Member Functions

 InterfaceMessageType ()
 Constructor. More...
 
 InterfaceMessageType (const std::string &json)
 Constructor from JSON. More...
 
 InterfaceMessageType (const rapidjson::Value &v)
 Constructor from JSON. More...
 
virtual ~InterfaceMessageType ()
 Destructor. More...
 
virtual std::string to_json (bool pretty=false) const
 Render object to JSON. More...
 
virtual void to_json_value (rapidjson::Document &d, rapidjson::Value &v) const
 Render object to JSON. More...
 
virtual void from_json (const std::string &json)
 Retrieve data from JSON string. More...
 
virtual void from_json_value (const rapidjson::Value &v)
 Retrieve data from JSON string. More...
 
virtual void validate (bool subcall=false) const
 Validate if all required fields have been set. More...
 
std::optional< std::string > name () const
 Get name value. More...
 
void set_name (const std::string &name)
 Set name value. More...
 
std::vector< std::shared_ptr< InterfaceFieldType > > fields () const
 Get fields value. More...
 
void set_fields (const std::vector< std::shared_ptr< InterfaceFieldType >> &fields)
 Set fields value. More...
 
void addto_fields (const std::shared_ptr< InterfaceFieldType > &&fields)
 Add element to fields array. More...
 
void addto_fields (const std::shared_ptr< InterfaceFieldType > &fields)
 Add element to fields array. More...
 
void addto_fields (const InterfaceFieldType &&fields)
 Add element to fields array. More...
 

Static Public Member Functions

static std::string api_version ()
 Get version of implemented API. More...
 

Detailed Description

InterfaceMessageType representation for JSON transfer.

Definition at line 28 of file InterfaceMessageType.h.

Constructor & Destructor Documentation

◆ InterfaceMessageType() [1/3]

InterfaceMessageType::InterfaceMessageType ( )

Constructor.

Definition at line 23 of file InterfaceMessageType.cpp.

◆ InterfaceMessageType() [2/3]

InterfaceMessageType::InterfaceMessageType ( const std::string &  json)

Constructor from JSON.

Parameters
jsonJSON string to initialize from

Definition at line 27 of file InterfaceMessageType.cpp.

References from_json().

◆ InterfaceMessageType() [3/3]

InterfaceMessageType::InterfaceMessageType ( const rapidjson::Value &  v)

Constructor from JSON.

Parameters
vRapidJSON value object to initialize from.

Definition at line 32 of file InterfaceMessageType.cpp.

References from_json_value().

◆ ~InterfaceMessageType()

InterfaceMessageType::~InterfaceMessageType ( )
virtual

Destructor.

Definition at line 37 of file InterfaceMessageType.cpp.

Member Function Documentation

◆ addto_fields() [1/3]

void InterfaceMessageType::addto_fields ( const InterfaceFieldType &&  fields)
inline

Add element to fields array.

Parameters
fieldsnew value

Definition at line 146 of file InterfaceMessageType.h.

References fields().

◆ addto_fields() [2/3]

void InterfaceMessageType::addto_fields ( const std::shared_ptr< InterfaceFieldType > &&  fields)
inline

Add element to fields array.

Parameters
fieldsnew value

Definition at line 128 of file InterfaceMessageType.h.

References fields().

◆ addto_fields() [3/3]

void InterfaceMessageType::addto_fields ( const std::shared_ptr< InterfaceFieldType > &  fields)
inline

Add element to fields array.

The move-semantics version (std::move) should be preferred.

Parameters
fieldsnew value

Definition at line 138 of file InterfaceMessageType.h.

References fields().

◆ api_version()

static std::string InterfaceMessageType::api_version ( )
inlinestatic

Get version of implemented API.

Returns
string representation of version

Definition at line 50 of file InterfaceMessageType.h.

◆ fields()

std::vector<std::shared_ptr<InterfaceFieldType> > InterfaceMessageType::fields ( ) const
inline

Get fields value.

Returns
fields value

Definition at line 111 of file InterfaceMessageType.h.

Referenced by addto_fields(), and set_fields().

◆ from_json()

void InterfaceMessageType::from_json ( const std::string &  json)
virtual

Retrieve data from JSON string.

Parameters
jsonJSON representation suitable for this object. Will allow partial assignment and not validate automaticaly.
See also
validate()

Definition at line 84 of file InterfaceMessageType.cpp.

References from_json_value().

Referenced by InterfaceMessageType().

◆ from_json_value()

void InterfaceMessageType::from_json_value ( const rapidjson::Value &  v)
virtual

Retrieve data from JSON string.

Parameters
vRapidJSON value suitable for this object. Will allow partial assignment and not validate automaticaly.
See also
validate()

Definition at line 93 of file InterfaceMessageType.cpp.

References InterfaceFieldType::from_json_value().

Referenced by from_json(), InterfaceInfo::from_json_value(), and InterfaceMessageType().

◆ name()

std::optional<std::string> InterfaceMessageType::name ( ) const
inline

Get name value.

Returns
name value

Definition at line 94 of file InterfaceMessageType.h.

Referenced by set_name().

◆ set_fields()

void InterfaceMessageType::set_fields ( const std::vector< std::shared_ptr< InterfaceFieldType >> &  fields)
inline

Set fields value.

Parameters
fieldsnew value

Definition at line 120 of file InterfaceMessageType.h.

References fields().

◆ set_name()

void InterfaceMessageType::set_name ( const std::string &  name)
inline

Set name value.

Parameters
namenew value

Definition at line 103 of file InterfaceMessageType.h.

References name().

◆ to_json()

std::string InterfaceMessageType::to_json ( bool  pretty = false) const
virtual

Render object to JSON.

Parameters
prettytrue to enable pretty printing (readable spacing)
Returns
JSON string

Definition at line 42 of file InterfaceMessageType.cpp.

References to_json_value().

◆ to_json_value()

void InterfaceMessageType::to_json_value ( rapidjson::Document &  d,
rapidjson::Value &  v 
) const
virtual

Render object to JSON.

Parameters
dRapidJSON document to retrieve allocator from
vRapidJSON value to add data to

Definition at line 61 of file InterfaceMessageType.cpp.

Referenced by to_json().

◆ validate()

void InterfaceMessageType::validate ( bool  subcall = false) const
virtual

Validate if all required fields have been set.

Parameters
subcalltrue if this is called from another class, e.g., a sub-class or array holder. Will modify the kind of exception thrown.
Exceptions
std::vector<std::string>thrown if required information is missing and subcall is set to true. Contains a list of missing fields.
std::runtime_errorinformative message describing the missing fields

Definition at line 112 of file InterfaceMessageType.cpp.


The documentation for this class was generated from the following files: