COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
portstruc Struct Reference

Port structure. More...

#include <jsondef.h>

Collaboration diagram for portstruc:

Public Member Functions

json11::Json to_json () const
 Convert class contents to JSON object. More...
 
void from_json (const string &s)
 Set class contents from JSON string. More...
 

Public Attributes

PORT_TYPE type = PORT_TYPE_NONE
 Type of I/O as listed in PORT_TYPE. More...
 
char name [COSMOS_MAX_DATA+1] = ""
 

Detailed Description

Port structure.

Contains information about I/O ports available to devices. The allstruc::portidx entry in each device structure indicates which of these ports a device will use.

Member Function Documentation

json11::Json portstruc::to_json ( ) const
inline

Convert class contents to JSON object.

Returns a json11 JSON object of the class

Returns
A json11 JSON object containing every member variable within the class
1369  {
1370  return json11::Json::object {
1371  { "type" , type },
1372  { "name" , name }
1373  };
1374  }
std::map< std::string, Json > object
Definition: json11.hpp:88
PORT_TYPE type
Type of I/O as listed in PORT_TYPE.
Definition: jsondef.h:1360
char name[COSMOS_MAX_DATA+1]
Definition: jsondef.h:1363
void portstruc::from_json ( const string &  s)
inline

Set class contents from JSON string.

Parses the provided JSON-formatted string and sets the class data. String should be formatted like the string returned from to_json()

Parameters
sJSON-formatted string to set class contents to
Returns
n/a
1382  {
1383  string error;
1384  json11::Json p = json11::Json::parse(s,error);
1385  if(error.empty()) {
1386  if(!p["type"].is_null()) { type = static_cast<PORT_TYPE>(p["type"].int_value()); }
1387  if(!p["name"].is_null()) { strcpy(name, p["name"].string_value().c_str()); }
1388  } else {
1389  cerr<<"ERROR: <"<<error<<">"<<endl;
1390  }
1391  return;
1392  }
Definition: json11.hpp:79
PORT_TYPE
Definition: jsondef.h:644
PORT_TYPE type
Type of I/O as listed in PORT_TYPE.
Definition: jsondef.h:1360
static double * p
Definition: gauss_jackson_test.cpp:42
static Json parse(const std::string &in, std::string &err, JsonParse strategy=JsonParse::STANDARD)
char name[COSMOS_MAX_DATA+1]
Definition: jsondef.h:1363
int int_value() const
Definition: json11.cpp:281

Member Data Documentation

PORT_TYPE portstruc::type = PORT_TYPE_NONE

Type of I/O as listed in PORT_TYPE.

char portstruc::name[COSMOS_MAX_DATA+1] = ""

Name information for port. !! Do not make this string


The documentation for this struct was generated from the following file: