Fawkes API  Fawkes Development Version
Plan Class Reference

Plan representation for JSON transfer. More...

#include <Plan.h>

Public Member Functions

 Plan ()
 Constructor. More...
 
 Plan (const std::string &json)
 Constructor from JSON. More...
 
 Plan (const rapidjson::Value &v)
 Constructor from JSON. More...
 
virtual ~Plan ()
 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 > kind () const
 Get kind value. More...
 
void set_kind (const std::string &kind)
 Set kind value. More...
 
std::optional< std::string > apiVersion () const
 Get apiVersion value. More...
 
void set_apiVersion (const std::string &apiVersion)
 Set apiVersion value. More...
 
std::optional< std::string > id () const
 Get id value. More...
 
void set_id (const std::string &id)
 Set id value. More...
 
std::optional< std::string > goal_id () const
 Get goal-id value. More...
 
void set_goal_id (const std::string &goal_id)
 Set goal-id value. More...
 
std::optional< float > cost () const
 Get cost value. More...
 
void set_cost (const float &cost)
 Set cost value. More...
 
std::vector< std::shared_ptr< PlanAction > > actions () const
 Get actions value. More...
 
void set_actions (const std::vector< std::shared_ptr< PlanAction >> &actions)
 Set actions value. More...
 
void addto_actions (const std::shared_ptr< PlanAction > &&actions)
 Add element to actions array. More...
 
void addto_actions (const std::shared_ptr< PlanAction > &actions)
 Add element to actions array. More...
 
void addto_actions (const PlanAction &&actions)
 Add element to actions array. More...
 

Static Public Member Functions

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

Detailed Description

Plan representation for JSON transfer.

Definition at line 28 of file Plan.h.

Constructor & Destructor Documentation

◆ Plan() [1/3]

Plan::Plan ( )

Constructor.

Definition at line 23 of file Plan.cpp.

◆ Plan() [2/3]

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

Constructor from JSON.

Parameters
jsonJSON string to initialize from

Definition at line 27 of file Plan.cpp.

References from_json().

◆ Plan() [3/3]

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

Constructor from JSON.

Parameters
vRapidJSON value object to initialize from.

Definition at line 32 of file Plan.cpp.

References from_json_value().

◆ ~Plan()

Plan::~Plan ( )
virtual

Destructor.

Definition at line 37 of file Plan.cpp.

Member Function Documentation

◆ actions()

std::vector<std::shared_ptr<PlanAction> > Plan::actions ( ) const
inline

Get actions value.

Returns
actions value

Definition at line 179 of file Plan.h.

Referenced by addto_actions(), and set_actions().

◆ addto_actions() [1/3]

void Plan::addto_actions ( const std::shared_ptr< PlanAction > &&  actions)
inline

Add element to actions array.

Parameters
actionsnew value

Definition at line 196 of file Plan.h.

References actions().

◆ addto_actions() [2/3]

void Plan::addto_actions ( const std::shared_ptr< PlanAction > &  actions)
inline

Add element to actions array.

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

Parameters
actionsnew value

Definition at line 206 of file Plan.h.

References actions().

◆ addto_actions() [3/3]

void Plan::addto_actions ( const PlanAction &&  actions)
inline

Add element to actions array.

Parameters
actionsnew value

Definition at line 214 of file Plan.h.

References actions().

◆ api_version()

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

Get version of implemented API.

Returns
string representation of version

Definition at line 50 of file Plan.h.

◆ apiVersion()

std::optional<std::string> Plan::apiVersion ( ) const
inline

Get apiVersion value.

Returns
apiVersion value

Definition at line 111 of file Plan.h.

Referenced by set_apiVersion().

◆ cost()

std::optional<float> Plan::cost ( ) const
inline

Get cost value.

Returns
cost value

Definition at line 162 of file Plan.h.

Referenced by set_cost().

◆ from_json()

void Plan::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 104 of file Plan.cpp.

References from_json_value().

Referenced by Plan().

◆ from_json_value()

void Plan::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 113 of file Plan.cpp.

References PlanAction::from_json_value().

Referenced by from_json(), and Plan().

◆ goal_id()

std::optional<std::string> Plan::goal_id ( ) const
inline

Get goal-id value.

Returns
goal-id value

Definition at line 145 of file Plan.h.

Referenced by set_goal_id().

◆ id()

std::optional<std::string> Plan::id ( ) const
inline

Get id value.

Returns
id value

Definition at line 128 of file Plan.h.

Referenced by set_id().

◆ kind()

std::optional<std::string> Plan::kind ( ) const
inline

Get kind value.

Returns
kind value

Definition at line 94 of file Plan.h.

Referenced by set_kind().

◆ set_actions()

void Plan::set_actions ( const std::vector< std::shared_ptr< PlanAction >> &  actions)
inline

Set actions value.

Parameters
actionsnew value

Definition at line 188 of file Plan.h.

References actions().

◆ set_apiVersion()

void Plan::set_apiVersion ( const std::string &  apiVersion)
inline

Set apiVersion value.

Parameters
apiVersionnew value

Definition at line 120 of file Plan.h.

References apiVersion().

◆ set_cost()

void Plan::set_cost ( const float &  cost)
inline

Set cost value.

Parameters
costnew value

Definition at line 171 of file Plan.h.

References cost().

◆ set_goal_id()

void Plan::set_goal_id ( const std::string &  goal_id)
inline

Set goal-id value.

Parameters
goal_idnew value

Definition at line 154 of file Plan.h.

References goal_id().

◆ set_id()

void Plan::set_id ( const std::string &  id)
inline

Set id value.

Parameters
idnew value

Definition at line 137 of file Plan.h.

References id().

◆ set_kind()

void Plan::set_kind ( const std::string &  kind)
inline

Set kind value.

Parameters
kindnew value

Definition at line 103 of file Plan.h.

References kind().

◆ to_json()

std::string Plan::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 Plan.cpp.

References to_json_value().

◆ to_json_value()

void Plan::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 Plan.cpp.

Referenced by to_json().

◆ validate()

void Plan::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 144 of file Plan.cpp.


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