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

Agent control structure. More...

#include <jsondef.h>

Collaboration diagram for agentstruc:

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

bool client = true
 Client initialized? More...
 
socket_channel sub
 Subscription channel (for Client) More...
 
bool server = true
 Server initialized? More...
 
size_t ifcnt = 0
 Number of network interfaces. More...
 
socket_channel pub [10]
 Publication channels for each interface (for Server) More...
 
socket_channel req
 Request channel (for Server) More...
 
int32_t pid = 0
 Agent process ID. More...
 
double aprd = 0.
 Activity period in seconds. More...
 
uint16_t stateflag = 0
 Agent Running State Flag. More...
 
vector< agent_request_entryreqs
 Agent request list. More...
 
beatstruc beat
 Heartbeat. More...
 

Detailed Description

Agent control structure.

Member Function Documentation

json11::Json agentstruc::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
1035  {
1036 // vector<uint16_t> v_pub = vector<uint16_t>(pub, pub+AGENTMAXIF);
1037  return json11::Json::object {
1038  { "client" , client },
1039 //TODO? { "sub" , sub },
1040  { "server" , server },
1041  { "ifcnt" , static_cast<int>(ifcnt) },
1042 // { "pub" , v_pub },
1043 // { "req" , req },
1044  { "pid" , pid },
1045  { "aprd" , aprd },
1046  { "stateflag" , stateflag },
1047 // { "reqs" , reqs },
1048  { "beat" , beat }
1049  };
1050  }
std::map< std::string, Json > object
Definition: json11.hpp:88
uint16_t stateflag
Agent Running State Flag.
Definition: jsondef.h:1025
bool client
Client initialized?
Definition: jsondef.h:1009
double aprd
Activity period in seconds.
Definition: jsondef.h:1023
int32_t pid
Agent process ID.
Definition: jsondef.h:1021
beatstruc beat
Heartbeat.
Definition: jsondef.h:1029
size_t ifcnt
Number of network interfaces.
Definition: jsondef.h:1015
bool server
Server initialized?
Definition: jsondef.h:1013
void agentstruc::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
1058  {
1059  string error;
1060  json11::Json p = json11::Json::parse(s,error);
1061  if(error.empty()) {
1062  if(!p["client"].is_null()) { client = p["client"].bool_value(); }
1063 //TODO? if(!p["sub"].is_null()) sub.from_json(p["sub"].dump());
1064  if(!p["server"].is_null()) { server = p["server"].bool_value(); }
1065  if(!p["ifcnt"].is_null()) { ifcnt = static_cast<size_t>(p["ifcnt"].number_value()); }
1066  auto p_pub = p["pub"].array_items();
1067 // if(!p["pub"].is_null()) {
1068 // for(size_t i = 0; i < p_pub.size(); ++i) {
1069 // if(!p["pub"][i].is_null()) pub[i].from_json(p["pub"][i].dump());
1070 // }
1071 // }
1072 // if(!p["req"].is_null()) req.from_json(p["req"].dump());
1073  if(!p["pid"].is_null()) { pid = p["pid"].int_value(); }
1074  if(!p["aprd"].is_null()) { aprd = p["aprd"].number_value(); }
1075  if(!p["stateflag"].is_null()) { stateflag = p["stateflag"].int_value(); }
1076 // if(!p["reqs"].is_null()) {
1077 // for(size_t i = 0; i < reqs.size(); ++i) {
1078 // if(!p["reqs"][i].is_null()) reqs[i].from_json(p["reqs"][i].dump());
1079 // }
1080 // }
1081  if(!p["beat"].is_null()) { beat.from_json(p["beat"].dump()); }
1082  } else {
1083  cerr<<"ERROR: <"<<error<<">"<<endl;
1084  }
1085  return;
1086  }
Definition: json11.hpp:79
uint16_t stateflag
Agent Running State Flag.
Definition: jsondef.h:1025
void from_json(const string &s)
Set class contents from JSON string.
Definition: jsondef.h:980
bool client
Client initialized?
Definition: jsondef.h:1009
double aprd
Activity period in seconds.
Definition: jsondef.h:1023
static double * p
Definition: gauss_jackson_test.cpp:42
int32_t pid
Agent process ID.
Definition: jsondef.h:1021
static Json parse(const std::string &in, std::string &err, JsonParse strategy=JsonParse::STANDARD)
static void dump(NullStruct, string &out)
Definition: json11.cpp:53
beatstruc beat
Heartbeat.
Definition: jsondef.h:1029
bool bool_value() const
Definition: json11.cpp:282
const array & array_items() const
Definition: json11.cpp:284
size_t ifcnt
Number of network interfaces.
Definition: jsondef.h:1015
int int_value() const
Definition: json11.cpp:281
double number_value() const
Definition: json11.cpp:280
bool server
Server initialized?
Definition: jsondef.h:1013

Member Data Documentation

bool agentstruc::client = true

Client initialized?

socket_channel agentstruc::sub

Subscription channel (for Client)

bool agentstruc::server = true

Server initialized?

size_t agentstruc::ifcnt = 0

Number of network interfaces.

socket_channel agentstruc::pub[10]

Publication channels for each interface (for Server)

socket_channel agentstruc::req

Request channel (for Server)

int32_t agentstruc::pid = 0

Agent process ID.

double agentstruc::aprd = 0.

Activity period in seconds.

uint16_t agentstruc::stateflag = 0

Agent Running State Flag.

vector<agent_request_entry> agentstruc::reqs

Agent request list.

beatstruc agentstruc::beat

Heartbeat.


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