Goby3 3.6.1
2026.09.15
Loading...
Searching...
No Matches
interface.h
Go to the documentation of this file.
1// Copyright 2026:
2// GobySoft, LLC (2013-)
3// Community contributors (see AUTHORS file)
4// File authors:
5// Toby Schneider <toby@gobysoft.org>
6//
7//
8// This file is part of the Goby Underwater Autonomy Project Libraries
9// ("The Goby Libraries").
10//
11// The Goby Libraries are free software: you can redistribute them and/or modify
12// them under the terms of the GNU Lesser General Public License as published by
13// the Free Software Foundation, either version 2.1 of the License, or
14// (at your option) any later version.
15//
16// The Goby Libraries are distributed in the hope that they will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU Lesser General Public License for more details.
20//
21// You should have received a copy of the GNU Lesser General Public License
22// along with Goby. If not, see <http://www.gnu.org/licenses/>.
23
24#ifndef GOBY_MIDDLEWARE_LANGUAGES_COMMON_INTERFACE_H
25#define GOBY_MIDDLEWARE_LANGUAGES_COMMON_INTERFACE_H
26
27#include <cstdint> // for uint8_t
28#include <ostream> // for ostream
29#include <string> // for string
30#include <vector> // for vector
31
32#include "goby/middleware/marshalling/interface.h" // for MarshallingScheme, SerializerParserHelper
33
34namespace goby
35{
36namespace middleware
37{
45namespace languages
46{
51enum class PubSubLayer
52{
53 INTERTHREAD = 0,
54 INTERPROCESS = 1,
55 INTERMODULE = 2
56};
57
59inline std::string to_string(PubSubLayer layer)
60{
61 switch (layer)
62 {
63 case PubSubLayer::INTERTHREAD: return "interthread";
64 case PubSubLayer::INTERPROCESS: return "interprocess";
65 case PubSubLayer::INTERMODULE: return "intermodule";
66 }
67 return "unknown";
68}
69
76{
78 std::string type_name;
79 int scheme;
80 std::string group;
81};
82
83inline bool operator==(const Identifier& i1, const Identifier& i2)
84{
85 return i1.layer == i2.layer && i1.type_name == i2.type_name && i1.scheme == i2.scheme &&
86 i1.group == i2.group;
87}
88
89inline bool operator!=(const Identifier& i1, const Identifier& i2) { return !(i1 == i2); }
90
91inline std::ostream& operator<<(std::ostream& os, const Identifier& i)
92{
93 return (os << "layer: " << to_string(i.layer) << ", type_name: \"" << i.type_name
95 << ", group: \"" << i.group << "\"");
96}
97
99template <typename DataType, int scheme>
100std::vector<std::uint8_t> serialize_uint8(const DataType& msg)
101{
102 std::vector<char> out =
104 return std::vector<std::uint8_t>(out.begin(), out.end());
105}
106
107} // namespace languages
108} // namespace middleware
109} // namespace goby
110
111#endif
std::string to_string(PubSubLayer layer)
Converts a PubSubLayer to the layer name used in interface.yml.
Definition interface.h:59
bool operator!=(const Identifier &i1, const Identifier &i2)
Definition interface.h:89
std::vector< std::uint8_t > serialize_uint8(const DataType &msg)
Marshals a message using the given scheme, returning the bytes to hand to the bound language.
Definition interface.h:100
bool operator==(const Identifier &i1, const Identifier &i2)
Definition interface.h:83
PubSubLayer
The publish/subscribe layer used for a given publication or subscription.
Definition interface.h:52
The global namespace for the Goby project.
extern ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ::PROTOBUF_NAMESPACE_ID::MessageOptions, ::PROTOBUF_NAMESPACE_ID::internal::MessageTypeTraits< ::goby::GobyMessageOptions >, 11, false > msg
static std::string to_string(int e)
Convert a known marshalling scheme to a human-readable string or an unknown scheme to the string repr...
Definition interface.h:67
static std::vector< char > serialize(const DataType &)
Given data, produce a vector of bytes.
Definition interface.h:100
Fully identifies a publication or subscription crossing the language boundary.
Definition interface.h:76