coral
A C++ library for distributed co-simulation
domain.hpp
Go to the documentation of this file.
1 
10 #ifndef CORAL_PROTOCOL_DOMAIN_HPP
11 #define CORAL_PROTOCOL_DOMAIN_HPP
12 
13 #include <string>
14 #include <vector>
15 #include "zmq.hpp"
16 #include "google/protobuf/message_lite.h"
17 
18 
19 namespace coral
20 {
21 namespace protocol
22 {
27 namespace domain
28 {
29 
30 
31 const uint16_t MAX_PROTOCOL_VERSION = 0;
32 
33 
34 void SubscribeToReports(zmq::socket_t& subSocket);
35 
36 
37 enum MessageType
38 {
39  MSG_SLAVEPROVIDER_HELLO,
40  MSG_UPDATE_AVAILABLE,
41  MSG_GET_SLAVE_LIST,
42  MSG_SLAVE_LIST,
43  MSG_INSTANTIATE_SLAVE,
44  MSG_INSTANTIATE_SLAVE_OK,
45  MSG_INSTANTIATE_SLAVE_FAILED
46 };
47 
48 
53 zmq::message_t CreateHeader(MessageType messageType, uint16_t protocolVersion);
54 
55 
66  const std::string& recipient,
67  MessageType messageType,
68  uint16_t protocolVersion);
69 
70 
76  const std::string& recipient,
77  MessageType messageType,
78  uint16_t protocolVersion,
79  const google::protobuf::MessageLite& body);
80 
81 
83 struct Header
84 {
86  uint16_t protocol;
87 
89  MessageType messageType;
90 };
91 
92 
100 Header ParseHeader(const zmq::message_t& headerFrame);
101 
102 
103 }}} // namespace
104 #endif // header guard
MessageType messageType
Message type.
Definition: domain.hpp:89
The information in a message header.
Definition: domain.hpp:83
STL class.
Definition: variable_io.hpp:28
void CreateAddressedMessage(std::vector< zmq::message_t > &message, const std::string &recipient, MessageType messageType, uint16_t protocolVersion)
Creates a body-less addressed message.
Header ParseHeader(const zmq::message_t &headerFrame)
Parses a header frame and returns its contents as a Header object.
zmq::message_t CreateHeader(MessageType messageType, uint16_t protocolVersion)
Creates a message header for the given message type, using the given protocol version.
uint16_t protocol
Protocol version.
Definition: domain.hpp:86