coral
A C++ library for distributed co-simulation
execution.hpp
Go to the documentation of this file.
1 
10 #ifndef CORAL_PROTOCOL_EXECUTION_HPP
11 #define CORAL_PROTOCOL_EXECUTION_HPP
12 
13 #include <cstdint>
14 #include <vector>
15 #include "google/protobuf/message_lite.h"
16 #include "zmq.hpp"
17 #include "execution.pb.h"
18 
19 
20 namespace coral
21 {
22 namespace protocol
23 {
24 
29 namespace execution
30 {
31 
32 
41  uint16_t protocolVersion);
42 
43 
52  uint16_t protocolVersion,
53  const google::protobuf::MessageLite& body);
54 
62  const std::string& reason = std::string());
63 
64 
70 void CreateMessage(
72  coralproto::execution::MessageType type);
73 
74 
80 void CreateMessage(
82  coralproto::execution::MessageType type,
83  const google::protobuf::MessageLite& body);
84 
85 
93  coralproto::execution::ErrorInfo::Code code,
94  const std::string& details = std::string());
95 
96 
104  coralproto::execution::ErrorInfo::Code code,
105  const std::string& details = std::string());
106 
107 
117 uint16_t ParseMessageType(const zmq::message_t& header);
118 
119 
127 uint16_t NonErrorMessageType(const std::vector<zmq::message_t>& message);
128 
129 
138 {
139 public:
140  // Constructor for DENIED messages.
141  explicit RemoteErrorException(const std::string& deniedReason);
142 
143  // Constructor for ERROR messages.
144  explicit RemoteErrorException(const coralproto::execution::ErrorInfo& errorInfo);
145 };
146 
147 
161 uint16_t ParseHelloMessage(const std::vector<zmq::message_t>& message);
162 
163 
164 }}} // namespace
165 #endif // header guard
Exception which signifies that the remote end sent a DENIED or ERROR message.
Definition: execution.hpp:137
uint16_t NonErrorMessageType(const std::vector< zmq::message_t > &message)
Parses the first two bytes of the message as an uint16_t, and throws an exception if it is an ERROR m...
void CreateDeniedMessage(std::vector< zmq::message_t > &message, const std::string &reason=std::string())
Fills &#39;message&#39; with a DENIED message with the given reason string.
void CreateErrorMessage(std::vector< zmq::message_t > &message, coralproto::execution::ErrorInfo::Code code, const std::string &details=std::string())
Fills message with an ERROR message.
STL class.
uint16_t ParseHelloMessage(const std::vector< zmq::message_t > &message)
Parses HELLO or DENIED messages.
Definition: variable_io.hpp:28
uint16_t ParseMessageType(const zmq::message_t &header)
Parses the first two bytes of header as an uint16_t.
void CreateMessage(std::vector< zmq::message_t > &message, coralproto::execution::MessageType type)
Fills message with a body-less message of the given type.
void CreateFatalErrorMessage(std::vector< zmq::message_t > &message, coralproto::execution::ErrorInfo::Code code, const std::string &details=std::string())
Fills message with a FATAL_ERROR message.
void CreateHelloMessage(std::vector< zmq::message_t > &message, uint16_t protocolVersion)
Fills message with a body-less HELLO message that requests the given protocol version.