ADD: some initial compiling infrastructure

This commit is contained in:
Dominik Meyer 2023-07-25 16:35:12 +02:00
parent 1f9eb2f6f8
commit df04dcee00
No known key found for this signature in database
GPG Key ID: B4C312B600606B64
18 changed files with 11816 additions and 0 deletions

102
CMakeLists.txt Normal file
View File

@ -0,0 +1,102 @@
cmake_minimum_required (VERSION 3.25 FATAL_ERROR)
project (whisperCom VERSION 0.0.1 LANGUAGES CXX C)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
#
# Options for compiling whisperCom
#
option(TEST_WHISPERCOM "Turn running of whisperCom specific tests on/off. Default: on" ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
#
# some stuff required inclusion
#
include(doxygen)
include(compdb)
include(protobuf)
IF(${TEST_WHISPERCOM})
include(CTest)
ENDIF()
#
# enable building documentation
#
build_docs(PROCESS_DOXYFILE DOXYFILE_PATH "docs/Doxyfile.in" )
#
# External required projects
#
IF(NOT TARGET Catch2 AND ${TEST_WHISPERCOM})
add_subdirectory(libs/Catch2 EXCLUDE_FROM_ALL)
include(libs/Catch2/extras/Catch.cmake)
ENDIF()
IF(NOT TARGET loguru)
add_library(loguru STATIC libs/loguru/loguru.cpp libs/loguru/loguru.hpp)
target_include_directories(loguru PUBLIC libs/loguru)
target_compile_options(loguru PUBLIC -DLOGURU_WITH_STREAMS=1)
set_property(TARGET loguru PROPERTY POSITION_INDEPENDENT_CODE 1)
target_link_libraries(loguru PUBLIC dl)
ENDIF()
IF(NOT TARGET libzmq)
set(BUILD_STATIC ON CACHE BOOL "enable building zmq as static library")
set(ENABLE_DRAFTS ON CACHE BOOL "enable zmq drafts")
set(ENABLE_RADIX_TREE ON CACHE BOOL "enable ENABLE_RADIX_TREE drafts")
set(ENABLE_WS ON CACHE BOOL "enable websocket support")
set(WITH_OPENPGM ON CACHE BOOL "enable pgm protocol")
set(WITH_LIBSODIUM ON CACHE BOOL "enable static libsodium support")
set(WITH_LIBSODIUM_STATIC ON CACHE BOOL "enable static libsodium support")
set(ENABLE_CURVE ON CACHE BOOL "enable curve cryptography in libsodium support")
set(ZMQ_BUILD_TESTS OFF CACHE BOOL "disable zmq tests")
set(OPENPGM_PKGCONFIG_NAME openpgm-5.3)
add_subdirectory(libs/libzmq EXCLUDE_FROM_ALL)
ENDIF()
IF(NOT TARGET cppzmq-static)
set(CPPZMQ_BUILD_TESTS OFF CACHE BOOL "disbale cppzmq tests")
add_subdirectory(libs/cppzmq EXCLUDE_FROM_ALL)
ENDIF()
IF(NOT TARGET protobuf)
SET(protobuf_BUILD_TESTS OFF CACHE BOOL "disable protobuf tests")
SET(protobuf_BUILD_SHARED_LIBS OFF CACHE BOOL "disable shared libraries")
#SET(WITH_PROTOC ON CACHE BOOL "enable building of protoc")
add_subdirectory(libs/protobuf EXCLUDE_FROM_ALL)
ENDIF()
# we are building with c++20
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
protobuf_generate_cpp(PROTO_PATH proto CPP_PATH proto HPP_PATH proto)
SET(WHISPERCOM_SOURCES
proto/RouterMessage.pb.cc
proto/Message.pb.cc
proto/TestMessage.pb.cc
include/WhisperCom/Router.hpp
src/WhisperCom/Router.cpp
include/WhisperCom/Service.hpp
src/WhisperCom/Service.cpp
)
add_library(whisperCom STATIC ${WHISPERCOM_SOURCES})
target_link_libraries(whisperCom loguru cppzmq-static protobuf::libprotobuf ${CMAKE_THREAD_LIBS_INIT} )
target_include_directories(whisperCom
PUBLIC
include
proto
PRIVATE
src
)
add_dependencies(whisperCom protoc)
add_executable(wctest src/main.cpp)
target_link_libraries(wctest whisperCom)
add_executable(wcListener src/Listener.cpp)
target_link_libraries(wcListener whisperCom)

8443
compile_commands.json Normal file

File diff suppressed because it is too large Load Diff

23
docs/Doxyfile.in Normal file
View File

@ -0,0 +1,23 @@
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = @PROJECT_NAME@
PROJECT_NUMBER = "@GIT_BRANCH@ @GIT_COMMIT_HASH@"
PROJECT_BRIEF = "library implementing a local and remote publish subscribe system without broker"
OUTPUT_DIRECTORY = @CMAKE_CURRENT_BINARY_DIR@/doxygen/
OUTPUT_LANGUAGE = English
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = NO
MULTILINE_CPP_IS_BRIEF = NO
TAB_SIZE = 4
MARKDOWN_SUPPORT = YES
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
INPUT = @CMAKE_CURRENT_SOURCE_DIR@/README.md @CMAKE_CURRENT_SOURCE_DIR@/src/ @CMAKE_CURRENT_SOURCE_DIR@/tests/ @CMAKE_CURRENT_SOURCE_DIR@/docs @CMAKE_CURRENT_SOURCE_DIR@/include
INPUT_ENCODING = UTF-8
FILE_PATTERNS = *.hpp *.cpp *.md
USE_MDFILE_AS_MAINPAGE = README.md
RECURSIVE = YES

View File

@ -0,0 +1,90 @@
#pragma once
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#include "zmq.hpp"
#include <condition_variable>
#include <cstdint>
#include <memory>
#include <mutex>
#include <thread>
#include <map>
#include <vector>
/**
* @brief main namespace of WhisperCom
*
*/
namespace WhisperCom
{
class Router
{
private:
/// is the router ready
bool isReady_;
/// local zmq url
std::string localUrl_;
/// url for the radio socket
std::string radiolUrl_;
/// url for the dish socket
std::string dishUrl_;
/// zeromq context
zmq::context_t zmqContext_;
/// local, system internal socket for connecting services
zmq::socket_t localSocket_;
/// external socket for listening
zmq::socket_t listening_;
/// external socket for transmitting
zmq::socket_t transmitting_;
zmq::socket_t dummySocket_;
/// thread for running local processing in
std::unique_ptr<std::thread> localProcesing_;
/// is the local processing thread running?
std::atomic<bool> isLocalProcessingRunning_;
/// stop the local processing thread
std::atomic<bool> stopLocalProcessing_;
/// map of connected clients and the last seen time
std::map<std::uint32_t, std::uint32_t> localClients_;
///mutex to protect localClients_
std::mutex mutexLocalClients_;
/// map of clients subscribed to a specific topic
std::map<std::string,std::vector<std::uint32_t>> subscription_;
/// mutex to protect subscription_
std::mutex mutexSubscription_;
void processLocalMessages_();
void processLocalMessage_(zmq::message_t &msg);
void processExternalMessage_(const zmq::message_t &msg);
public:
Router(const std::string localUrl, const std::string radioUrl, const std::string dishUrl);
Router() : Router("ipc:///tmp/whispercom", "udp://239.0.0.1:40000", "udp://*:40000"){}
~Router();
void start();
void stop();
bool isReady() const {return isReady_;}
}; // class Router
}; //namespace WhisperCom

View File

@ -0,0 +1,90 @@
#pragma once
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#include "RouterMessage.pb.h"
#include "WhisperCom/Router.hpp"
#include "zmq.hpp"
#include <atomic>
#include <chrono>
#include <memory>
#include <mutex>
#include <queue>
/**
* @brief main namespace of WhisperCom
*
*/
namespace WhisperCom
{
class Service
{
private:
/// the local url to connect to
std::string localUrl_;
/// the radio url to use within the router
std::string radioUrl_;
/// the dish url to use within the router
std::string dishUrl_;
/// a WhisperComm router for relaying messages off the computer
std::unique_ptr<WhisperCom::Router> router_;
/// context for zeromq
zmq::context_t zmqContext_;
/// socket for communication with the router
zmq::socket_t socket_;
/// time of last keepalive
std::atomic<std::chrono::steady_clock::time_point> lastKeepAlive_;
/// number of seconds without message to assume router dead
std::uint32_t routerDeadTimeOut_;
/// number of seconds to transmit and request q keepalive
std::uint32_t keepaliveTime_;
void keepalive_();
std::unique_ptr<std::thread> keepaliveThread_;
std::atomic<bool> stopKeepAlive_;
std::atomic<bool> isKeepAliveRunning_;
void receive_();
std::unique_ptr<std::thread> receiveThread_;
std::atomic<bool> stopReceive_;
std::atomic<bool> isReceiveRunning_;
std::queue<std::shared_ptr<WhisperCom::Protobuf::Message>> messageQueue_;
std::mutex mutexMessageQueue_;
std::condition_variable condWaitMessageQueue_;
void processMessage_(const zmq::message_t &msg);
void verifyRouter_();
public:
Service(const std::string localUrl, const std::string radioUrl,const std::string dishUrl, std::uint32_t routerDeadTimeout=10,std::uint32_t keepaliveTime=2);
Service()
: Service("ipc:///tmp/whispercom", "udp://239.0.0.1:40000", "udp://239.0.0.1:40000") {}
~Service();
void subscribe(const std::string &topic);
void unsubscribe(const std::string &topic);
void unsubscribeAll();
bool hasMessages() {std::lock_guard<std::mutex> guard{mutexMessageQueue_}; return messageQueue_.size();}
bool waitForMessage(std::chrono::milliseconds timeout);
bool waitForMessage(std::chrono::milliseconds timeout, std::shared_ptr<WhisperCom::Protobuf::Message> message);
std::shared_ptr<WhisperCom::Protobuf::Message> getMessage();
bool sendMessage(const std::string &topic, WhisperCom::Protobuf::Message &data);
void stop();
}; // class Service
}; // namespace WhisperCom

367
proto/Message.pb.cc Normal file
View File

@ -0,0 +1,367 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: Message.proto
#include "Message.pb.h"
#include <algorithm>
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/extension_set.h"
#include "google/protobuf/wire_format_lite.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/generated_message_reflection.h"
#include "google/protobuf/reflection_ops.h"
#include "google/protobuf/wire_format.h"
#include "google/protobuf/generated_message_tctable_impl.h"
// @@protoc_insertion_point(includes)
// Must be included last.
#include "google/protobuf/port_def.inc"
PROTOBUF_PRAGMA_INIT_SEG
namespace _pb = ::google::protobuf;
namespace _pbi = ::google::protobuf::internal;
namespace _fl = ::google::protobuf::internal::field_layout;
namespace WhisperCom {
namespace Protobuf {
template <typename>
PROTOBUF_CONSTEXPR Message::Message(::_pbi::ConstantInitialized)
: _impl_{
/*decltype(_impl_._has_bits_)*/ {},
/*decltype(_impl_._cached_size_)*/ {},
/*decltype(_impl_.payload_)*/ nullptr,
/*decltype(_impl_.type_)*/ 0u,
} {}
struct MessageDefaultTypeInternal {
PROTOBUF_CONSTEXPR MessageDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~MessageDefaultTypeInternal() {}
union {
Message _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MessageDefaultTypeInternal _Message_default_instance_;
} // namespace Protobuf
} // namespace WhisperCom
static ::_pb::Metadata file_level_metadata_Message_2eproto[1];
static constexpr const ::_pb::EnumDescriptor**
file_level_enum_descriptors_Message_2eproto = nullptr;
static constexpr const ::_pb::ServiceDescriptor**
file_level_service_descriptors_Message_2eproto = nullptr;
const ::uint32_t TableStruct_Message_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(
protodesc_cold) = {
PROTOBUF_FIELD_OFFSET(::WhisperCom::Protobuf::Message, _impl_._has_bits_),
PROTOBUF_FIELD_OFFSET(::WhisperCom::Protobuf::Message, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
~0u, // no _inlined_string_donated_
~0u, // no _split_
~0u, // no sizeof(Split)
PROTOBUF_FIELD_OFFSET(::WhisperCom::Protobuf::Message, _impl_.type_),
PROTOBUF_FIELD_OFFSET(::WhisperCom::Protobuf::Message, _impl_.payload_),
~0u,
0,
};
static const ::_pbi::MigrationSchema
schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{0, 10, -1, sizeof(::WhisperCom::Protobuf::Message)},
};
static const ::_pb::Message* const file_default_instances[] = {
&::WhisperCom::Protobuf::_Message_default_instance_._instance,
};
const char descriptor_table_protodef_Message_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
"\n\rMessage.proto\022\023WhisperCom.Protobuf\032\031go"
"ogle/protobuf/any.proto\">\n\007Message\022\014\n\004ty"
"pe\030\001 \001(\r\022%\n\007payload\030\002 \001(\0132\024.google.proto"
"buf.Anyb\006proto3"
};
static const ::_pbi::DescriptorTable* const descriptor_table_Message_2eproto_deps[1] =
{
&::descriptor_table_google_2fprotobuf_2fany_2eproto,
};
static ::absl::once_flag descriptor_table_Message_2eproto_once;
const ::_pbi::DescriptorTable descriptor_table_Message_2eproto = {
false,
false,
135,
descriptor_table_protodef_Message_2eproto,
"Message.proto",
&descriptor_table_Message_2eproto_once,
descriptor_table_Message_2eproto_deps,
1,
1,
schemas,
file_default_instances,
TableStruct_Message_2eproto::offsets,
file_level_metadata_Message_2eproto,
file_level_enum_descriptors_Message_2eproto,
file_level_service_descriptors_Message_2eproto,
};
// This function exists to be marked as weak.
// It can significantly speed up compilation by breaking up LLVM's SCC
// in the .pb.cc translation units. Large translation units see a
// reduction of more than 35% of walltime for optimized builds. Without
// the weak attribute all the messages in the file, including all the
// vtables and everything they use become part of the same SCC through
// a cycle like:
// GetMetadata -> descriptor table -> default instances ->
// vtables -> GetMetadata
// By adding a weak function here we break the connection from the
// individual vtables back into the descriptor table.
PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_Message_2eproto_getter() {
return &descriptor_table_Message_2eproto;
}
// Force running AddDescriptors() at dynamic initialization time.
PROTOBUF_ATTRIBUTE_INIT_PRIORITY2
static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_Message_2eproto(&descriptor_table_Message_2eproto);
namespace WhisperCom {
namespace Protobuf {
// ===================================================================
class Message::_Internal {
public:
using HasBits = decltype(std::declval<Message>()._impl_._has_bits_);
static constexpr ::int32_t kHasBitsOffset =
8 * PROTOBUF_FIELD_OFFSET(Message, _impl_._has_bits_);
static const ::google::protobuf::Any& payload(const Message* msg);
static void set_has_payload(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
};
const ::google::protobuf::Any& Message::_Internal::payload(const Message* msg) {
return *msg->_impl_.payload_;
}
void Message::clear_payload() {
if (_impl_.payload_ != nullptr) _impl_.payload_->Clear();
_impl_._has_bits_[0] &= ~0x00000001u;
}
Message::Message(::google::protobuf::Arena* arena)
: ::google::protobuf::Message(arena) {
SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:WhisperCom.Protobuf.Message)
}
Message::Message(const Message& from) : ::google::protobuf::Message() {
Message* const _this = this;
(void)_this;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){from._impl_._has_bits_},
/*decltype(_impl_._cached_size_)*/ {},
decltype(_impl_.payload_){nullptr},
decltype(_impl_.type_){},
};
_internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>(
from._internal_metadata_);
if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) {
_this->_impl_.payload_ = new ::google::protobuf::Any(*from._impl_.payload_);
}
_this->_impl_.type_ = from._impl_.type_;
// @@protoc_insertion_point(copy_constructor:WhisperCom.Protobuf.Message)
}
inline void Message::SharedCtor(::_pb::Arena* arena) {
(void)arena;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){},
/*decltype(_impl_._cached_size_)*/ {},
decltype(_impl_.payload_){nullptr},
decltype(_impl_.type_){0u},
};
}
Message::~Message() {
// @@protoc_insertion_point(destructor:WhisperCom.Protobuf.Message)
_internal_metadata_.Delete<::google::protobuf::UnknownFieldSet>();
SharedDtor();
}
inline void Message::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
if (this != internal_default_instance()) delete _impl_.payload_;
}
void Message::SetCachedSize(int size) const {
_impl_._cached_size_.Set(size);
}
PROTOBUF_NOINLINE void Message::Clear() {
// @@protoc_insertion_point(message_clear_start:WhisperCom.Protobuf.Message)
::uint32_t cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
if (cached_has_bits & 0x00000001u) {
ABSL_DCHECK(_impl_.payload_ != nullptr);
_impl_.payload_->Clear();
}
_impl_.type_ = 0u;
_impl_._has_bits_.Clear();
_internal_metadata_.Clear<::google::protobuf::UnknownFieldSet>();
}
const char* Message::_InternalParse(
const char* ptr, ::_pbi::ParseContext* ctx) {
ptr = ::_pbi::TcParser::ParseLoop(this, ptr, ctx, &_table_.header);
return ptr;
}
PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
const ::_pbi::TcParseTable<1, 2, 1, 0, 2> Message::_table_ = {
{
PROTOBUF_FIELD_OFFSET(Message, _impl_._has_bits_),
0, // no _extensions_
2, 8, // max_field_number, fast_idx_mask
offsetof(decltype(_table_), field_lookup_table),
4294967292, // skipmap
offsetof(decltype(_table_), field_entries),
2, // num_field_entries
1, // num_aux_entries
offsetof(decltype(_table_), aux_entries),
&_Message_default_instance_._instance,
::_pbi::TcParser::GenericFallback, // fallback
}, {{
// .google.protobuf.Any payload = 2;
{::_pbi::TcParser::FastMtS1,
{18, 0, 0, PROTOBUF_FIELD_OFFSET(Message, _impl_.payload_)}},
// uint32 type = 1;
{::_pbi::TcParser::SingularVarintNoZag1<::uint32_t, offsetof(Message, _impl_.type_), 63>(),
{8, 63, 0, PROTOBUF_FIELD_OFFSET(Message, _impl_.type_)}},
}}, {{
65535, 65535
}}, {{
// uint32 type = 1;
{PROTOBUF_FIELD_OFFSET(Message, _impl_.type_), -1, 0,
(0 | ::_fl::kFcSingular | ::_fl::kUInt32)},
// .google.protobuf.Any payload = 2;
{PROTOBUF_FIELD_OFFSET(Message, _impl_.payload_), _Internal::kHasBitsOffset + 0, 0,
(0 | ::_fl::kFcOptional | ::_fl::kMessage | ::_fl::kTvTable)},
}}, {{
{::_pbi::TcParser::GetTable<::google::protobuf::Any>()},
}}, {{
}},
};
::uint8_t* Message::_InternalSerialize(
::uint8_t* target,
::google::protobuf::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:WhisperCom.Protobuf.Message)
::uint32_t cached_has_bits = 0;
(void)cached_has_bits;
// uint32 type = 1;
if (this->_internal_type() != 0) {
target = stream->EnsureSpace(target);
target = ::_pbi::WireFormatLite::WriteUInt32ToArray(
1, this->_internal_type(), target);
}
cached_has_bits = _impl_._has_bits_[0];
// .google.protobuf.Any payload = 2;
if (cached_has_bits & 0x00000001u) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessage(2, _Internal::payload(this),
_Internal::payload(this).GetCachedSize(), target, stream);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target =
::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:WhisperCom.Protobuf.Message)
return target;
}
::size_t Message::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:WhisperCom.Protobuf.Message)
::size_t total_size = 0;
::uint32_t cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// .google.protobuf.Any payload = 2;
cached_has_bits = _impl_._has_bits_[0];
if (cached_has_bits & 0x00000001u) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
*_impl_.payload_);
}
// uint32 type = 1;
if (this->_internal_type() != 0) {
total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(
this->_internal_type());
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
}
const ::google::protobuf::Message::ClassData Message::_class_data_ = {
::google::protobuf::Message::CopyWithSourceCheck,
Message::MergeImpl
};
const ::google::protobuf::Message::ClassData*Message::GetClassData() const { return &_class_data_; }
void Message::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) {
auto* const _this = static_cast<Message*>(&to_msg);
auto& from = static_cast<const Message&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:WhisperCom.Protobuf.Message)
ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) {
_this->_internal_mutable_payload()->::google::protobuf::Any::MergeFrom(
from._internal_payload());
}
if (from._internal_type() != 0) {
_this->_internal_set_type(from._internal_type());
}
_this->_internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>(from._internal_metadata_);
}
void Message::CopyFrom(const Message& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:WhisperCom.Protobuf.Message)
if (&from == this) return;
Clear();
MergeFrom(from);
}
PROTOBUF_NOINLINE bool Message::IsInitialized() const {
return true;
}
void Message::InternalSwap(Message* other) {
using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
::google::protobuf::internal::memswap<
PROTOBUF_FIELD_OFFSET(Message, _impl_.type_)
+ sizeof(Message::_impl_.type_)
- PROTOBUF_FIELD_OFFSET(Message, _impl_.payload_)>(
reinterpret_cast<char*>(&_impl_.payload_),
reinterpret_cast<char*>(&other->_impl_.payload_));
}
::google::protobuf::Metadata Message::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_Message_2eproto_getter, &descriptor_table_Message_2eproto_once,
file_level_metadata_Message_2eproto[0]);
}
// @@protoc_insertion_point(namespace_scope)
} // namespace Protobuf
} // namespace WhisperCom
namespace google {
namespace protobuf {
template<> PROTOBUF_NOINLINE ::WhisperCom::Protobuf::Message*
Arena::CreateMaybeMessage< ::WhisperCom::Protobuf::Message >(Arena* arena) {
return Arena::CreateMessageInternal< ::WhisperCom::Protobuf::Message >(arena);
}
} // namespace protobuf
} // namespace google
// @@protoc_insertion_point(global_scope)
#include "google/protobuf/port_undef.inc"

389
proto/Message.pb.h Normal file
View File

@ -0,0 +1,389 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: Message.proto
#ifndef GOOGLE_PROTOBUF_INCLUDED_Message_2eproto_2epb_2eh
#define GOOGLE_PROTOBUF_INCLUDED_Message_2eproto_2epb_2eh
#include <limits>
#include <string>
#include <type_traits>
#include "google/protobuf/port_def.inc"
#if PROTOBUF_VERSION < 4023000
#error "This file was generated by a newer version of protoc which is"
#error "incompatible with your Protocol Buffer headers. Please update"
#error "your headers."
#endif // PROTOBUF_VERSION
#if 4023000 < PROTOBUF_MIN_PROTOC_VERSION
#error "This file was generated by an older version of protoc which is"
#error "incompatible with your Protocol Buffer headers. Please"
#error "regenerate this file with a newer version of protoc."
#endif // PROTOBUF_MIN_PROTOC_VERSION
#include "google/protobuf/port_undef.inc"
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/arena.h"
#include "google/protobuf/arenastring.h"
#include "google/protobuf/generated_message_tctable_decl.h"
#include "google/protobuf/generated_message_util.h"
#include "google/protobuf/metadata_lite.h"
#include "google/protobuf/generated_message_reflection.h"
#include "google/protobuf/message.h"
#include "google/protobuf/repeated_field.h" // IWYU pragma: export
#include "google/protobuf/extension_set.h" // IWYU pragma: export
#include "google/protobuf/unknown_field_set.h"
#include "google/protobuf/any.pb.h"
// @@protoc_insertion_point(includes)
// Must be included last.
#include "google/protobuf/port_def.inc"
#define PROTOBUF_INTERNAL_EXPORT_Message_2eproto
namespace google {
namespace protobuf {
namespace internal {
class AnyMetadata;
} // namespace internal
} // namespace protobuf
} // namespace google
// Internal implementation detail -- do not use these members.
struct TableStruct_Message_2eproto {
static const ::uint32_t offsets[];
};
extern const ::google::protobuf::internal::DescriptorTable
descriptor_table_Message_2eproto;
namespace WhisperCom {
namespace Protobuf {
class Message;
struct MessageDefaultTypeInternal;
extern MessageDefaultTypeInternal _Message_default_instance_;
} // namespace Protobuf
} // namespace WhisperCom
namespace google {
namespace protobuf {
template <>
::WhisperCom::Protobuf::Message* Arena::CreateMaybeMessage<::WhisperCom::Protobuf::Message>(Arena*);
} // namespace protobuf
} // namespace google
namespace WhisperCom {
namespace Protobuf {
// ===================================================================
// -------------------------------------------------------------------
class Message final :
public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:WhisperCom.Protobuf.Message) */ {
public:
inline Message() : Message(nullptr) {}
~Message() override;
template<typename = void>
explicit PROTOBUF_CONSTEXPR Message(::google::protobuf::internal::ConstantInitialized);
Message(const Message& from);
Message(Message&& from) noexcept
: Message() {
*this = ::std::move(from);
}
inline Message& operator=(const Message& from) {
CopyFrom(from);
return *this;
}
inline Message& operator=(Message&& from) noexcept {
if (this == &from) return *this;
if (GetOwningArena() == from.GetOwningArena()
#ifdef PROTOBUF_FORCE_COPY_IN_MOVE
&& GetOwningArena() != nullptr
#endif // !PROTOBUF_FORCE_COPY_IN_MOVE
) {
InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance);
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>();
}
static const ::google::protobuf::Descriptor* descriptor() {
return GetDescriptor();
}
static const ::google::protobuf::Descriptor* GetDescriptor() {
return default_instance().GetMetadata().descriptor;
}
static const ::google::protobuf::Reflection* GetReflection() {
return default_instance().GetMetadata().reflection;
}
static const Message& default_instance() {
return *internal_default_instance();
}
static inline const Message* internal_default_instance() {
return reinterpret_cast<const Message*>(
&_Message_default_instance_);
}
static constexpr int kIndexInFileMessages =
0;
friend void swap(Message& a, Message& b) {
a.Swap(&b);
}
inline void Swap(Message* other) {
if (other == this) return;
#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
if (GetOwningArena() != nullptr &&
GetOwningArena() == other->GetOwningArena()) {
#else // PROTOBUF_FORCE_COPY_IN_SWAP
if (GetOwningArena() == other->GetOwningArena()) {
#endif // !PROTOBUF_FORCE_COPY_IN_SWAP
InternalSwap(other);
} else {
::google::protobuf::internal::GenericSwap(this, other);
}
}
void UnsafeArenaSwap(Message* other) {
if (other == this) return;
ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
// implements Message ----------------------------------------------
Message* New(::google::protobuf::Arena* arena = nullptr) const final {
return CreateMaybeMessage<Message>(arena);
}
using ::google::protobuf::Message::CopyFrom;
void CopyFrom(const Message& from);
using ::google::protobuf::Message::MergeFrom;
void MergeFrom( const Message& from) {
Message::MergeImpl(*this, from);
}
private:
static void MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg);
public:
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::google::protobuf::internal::ParseContext* ctx) final;
::uint8_t* _InternalSerialize(
::uint8_t* target, ::google::protobuf::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
void SharedCtor(::google::protobuf::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(Message* other);
private:
friend class ::google::protobuf::internal::AnyMetadata;
static ::absl::string_view FullMessageName() {
return "WhisperCom.Protobuf.Message";
}
protected:
explicit Message(::google::protobuf::Arena* arena);
public:
static const ClassData _class_data_;
const ::google::protobuf::Message::ClassData*GetClassData() const final;
::google::protobuf::Metadata GetMetadata() const final;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
enum : int {
kPayloadFieldNumber = 2,
kTypeFieldNumber = 1,
};
// .google.protobuf.Any payload = 2;
bool has_payload() const;
void clear_payload() ;
const ::google::protobuf::Any& payload() const;
PROTOBUF_NODISCARD ::google::protobuf::Any* release_payload();
::google::protobuf::Any* mutable_payload();
void set_allocated_payload(::google::protobuf::Any* value);
void unsafe_arena_set_allocated_payload(::google::protobuf::Any* value);
::google::protobuf::Any* unsafe_arena_release_payload();
private:
const ::google::protobuf::Any& _internal_payload() const;
::google::protobuf::Any* _internal_mutable_payload();
public:
// uint32 type = 1;
void clear_type() ;
::uint32_t type() const;
void set_type(::uint32_t value);
private:
::uint32_t _internal_type() const;
void _internal_set_type(::uint32_t value);
public:
// @@protoc_insertion_point(class_scope:WhisperCom.Protobuf.Message)
private:
class _Internal;
friend class ::google::protobuf::internal::TcParser;
static const ::google::protobuf::internal::TcParseTable<1, 2, 1, 0, 2> _table_;
template <typename T> friend class ::google::protobuf::Arena::InternalHelper;
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
struct Impl_ {
::google::protobuf::internal::HasBits<1> _has_bits_;
mutable ::google::protobuf::internal::CachedSize _cached_size_;
::google::protobuf::Any* payload_;
::uint32_t type_;
};
union { Impl_ _impl_; };
friend struct ::TableStruct_Message_2eproto;
};
// ===================================================================
// ===================================================================
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
// -------------------------------------------------------------------
// Message
// uint32 type = 1;
inline void Message::clear_type() {
_impl_.type_ = 0u;
}
inline ::uint32_t Message::type() const {
// @@protoc_insertion_point(field_get:WhisperCom.Protobuf.Message.type)
return _internal_type();
}
inline void Message::set_type(::uint32_t value) {
_internal_set_type(value);
// @@protoc_insertion_point(field_set:WhisperCom.Protobuf.Message.type)
}
inline ::uint32_t Message::_internal_type() const {
return _impl_.type_;
}
inline void Message::_internal_set_type(::uint32_t value) {
;
_impl_.type_ = value;
}
// .google.protobuf.Any payload = 2;
inline bool Message::has_payload() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
PROTOBUF_ASSUME(!value || _impl_.payload_ != nullptr);
return value;
}
inline const ::google::protobuf::Any& Message::_internal_payload() const {
const ::google::protobuf::Any* p = _impl_.payload_;
return p != nullptr ? *p : reinterpret_cast<const ::google::protobuf::Any&>(::google::protobuf::_Any_default_instance_);
}
inline const ::google::protobuf::Any& Message::payload() const {
// @@protoc_insertion_point(field_get:WhisperCom.Protobuf.Message.payload)
return _internal_payload();
}
inline void Message::unsafe_arena_set_allocated_payload(::google::protobuf::Any* value) {
if (GetArenaForAllocation() == nullptr) {
delete reinterpret_cast<::google::protobuf::MessageLite*>(_impl_.payload_);
}
_impl_.payload_ = reinterpret_cast<::google::protobuf::Any*>(value);
if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000001u;
} else {
_impl_._has_bits_[0] &= ~0x00000001u;
}
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:WhisperCom.Protobuf.Message.payload)
}
inline ::google::protobuf::Any* Message::release_payload() {
_impl_._has_bits_[0] &= ~0x00000001u;
::google::protobuf::Any* released = _impl_.payload_;
_impl_.payload_ = nullptr;
#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE
auto* old = reinterpret_cast<::google::protobuf::MessageLite*>(released);
released = ::google::protobuf::internal::DuplicateIfNonNull(released);
if (GetArenaForAllocation() == nullptr) {
delete old;
}
#else // PROTOBUF_FORCE_COPY_IN_RELEASE
if (GetArenaForAllocation() != nullptr) {
released = ::google::protobuf::internal::DuplicateIfNonNull(released);
}
#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE
return released;
}
inline ::google::protobuf::Any* Message::unsafe_arena_release_payload() {
// @@protoc_insertion_point(field_release:WhisperCom.Protobuf.Message.payload)
_impl_._has_bits_[0] &= ~0x00000001u;
::google::protobuf::Any* temp = _impl_.payload_;
_impl_.payload_ = nullptr;
return temp;
}
inline ::google::protobuf::Any* Message::_internal_mutable_payload() {
_impl_._has_bits_[0] |= 0x00000001u;
if (_impl_.payload_ == nullptr) {
auto* p = CreateMaybeMessage<::google::protobuf::Any>(GetArenaForAllocation());
_impl_.payload_ = reinterpret_cast<::google::protobuf::Any*>(p);
}
return _impl_.payload_;
}
inline ::google::protobuf::Any* Message::mutable_payload() {
::google::protobuf::Any* _msg = _internal_mutable_payload();
// @@protoc_insertion_point(field_mutable:WhisperCom.Protobuf.Message.payload)
return _msg;
}
inline void Message::set_allocated_payload(::google::protobuf::Any* value) {
::google::protobuf::Arena* message_arena = GetArenaForAllocation();
if (message_arena == nullptr) {
delete reinterpret_cast<::google::protobuf::MessageLite*>(_impl_.payload_);
}
if (value != nullptr) {
::google::protobuf::Arena* submessage_arena =
::google::protobuf::Arena::InternalGetOwningArena(reinterpret_cast<::google::protobuf::MessageLite*>(value));
if (message_arena != submessage_arena) {
value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena);
}
_impl_._has_bits_[0] |= 0x00000001u;
} else {
_impl_._has_bits_[0] &= ~0x00000001u;
}
_impl_.payload_ = reinterpret_cast<::google::protobuf::Any*>(value);
// @@protoc_insertion_point(field_set_allocated:WhisperCom.Protobuf.Message.payload)
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif // __GNUC__
// @@protoc_insertion_point(namespace_scope)
} // namespace Protobuf
} // namespace WhisperCom
// @@protoc_insertion_point(global_scope)
#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_INCLUDED_Message_2eproto_2epb_2eh

8
proto/Message.proto Normal file
View File

@ -0,0 +1,8 @@
syntax = "proto3";
import "google/protobuf/any.proto";
package WhisperCom.Protobuf;
message Message {
uint32 type = 1;
google.protobuf.Any payload = 2;
}

443
proto/RouterMessage.pb.cc Normal file
View File

@ -0,0 +1,443 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: RouterMessage.proto
#include "RouterMessage.pb.h"
#include <algorithm>
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/extension_set.h"
#include "google/protobuf/wire_format_lite.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/generated_message_reflection.h"
#include "google/protobuf/reflection_ops.h"
#include "google/protobuf/wire_format.h"
#include "google/protobuf/generated_message_tctable_impl.h"
// @@protoc_insertion_point(includes)
// Must be included last.
#include "google/protobuf/port_def.inc"
PROTOBUF_PRAGMA_INIT_SEG
namespace _pb = ::google::protobuf;
namespace _pbi = ::google::protobuf::internal;
namespace _fl = ::google::protobuf::internal::field_layout;
namespace WhisperCom {
namespace Protobuf {
template <typename>
PROTOBUF_CONSTEXPR RouterMessage::RouterMessage(::_pbi::ConstantInitialized)
: _impl_{
/*decltype(_impl_._has_bits_)*/ {},
/*decltype(_impl_._cached_size_)*/ {},
/*decltype(_impl_.topic_)*/ {
&::_pbi::fixed_address_empty_string,
::_pbi::ConstantInitialized{},
},
/*decltype(_impl_.msg_)*/ nullptr,
/*decltype(_impl_.type_)*/ 0,
} {}
struct RouterMessageDefaultTypeInternal {
PROTOBUF_CONSTEXPR RouterMessageDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~RouterMessageDefaultTypeInternal() {}
union {
RouterMessage _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 RouterMessageDefaultTypeInternal _RouterMessage_default_instance_;
} // namespace Protobuf
} // namespace WhisperCom
static ::_pb::Metadata file_level_metadata_RouterMessage_2eproto[1];
static const ::_pb::EnumDescriptor* file_level_enum_descriptors_RouterMessage_2eproto[1];
static constexpr const ::_pb::ServiceDescriptor**
file_level_service_descriptors_RouterMessage_2eproto = nullptr;
const ::uint32_t TableStruct_RouterMessage_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(
protodesc_cold) = {
PROTOBUF_FIELD_OFFSET(::WhisperCom::Protobuf::RouterMessage, _impl_._has_bits_),
PROTOBUF_FIELD_OFFSET(::WhisperCom::Protobuf::RouterMessage, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
~0u, // no _inlined_string_donated_
~0u, // no _split_
~0u, // no sizeof(Split)
PROTOBUF_FIELD_OFFSET(::WhisperCom::Protobuf::RouterMessage, _impl_.type_),
PROTOBUF_FIELD_OFFSET(::WhisperCom::Protobuf::RouterMessage, _impl_.msg_),
PROTOBUF_FIELD_OFFSET(::WhisperCom::Protobuf::RouterMessage, _impl_.topic_),
~0u,
0,
~0u,
};
static const ::_pbi::MigrationSchema
schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{0, 11, -1, sizeof(::WhisperCom::Protobuf::RouterMessage)},
};
static const ::_pb::Message* const file_default_instances[] = {
&::WhisperCom::Protobuf::_RouterMessage_default_instance_._instance,
};
const char descriptor_table_protodef_RouterMessage_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
"\n\023RouterMessage.proto\022\023WhisperCom.Protob"
"uf\032\031google/protobuf/any.proto\032\rMessage.p"
"roto\"\177\n\rRouterMessage\0224\n\004type\030\001 \001(\0162&.Wh"
"isperCom.Protobuf.RouterMessageType\022)\n\003m"
"sg\030\002 \001(\0132\034.WhisperCom.Protobuf.Message\022\r"
"\n\005topic\030\003 \001(\t*\203\001\n\021RouterMessageType\022\013\n\007U"
"NKNOWN\020\000\022\010\n\004JOIN\020\001\022\t\n\005LEAVE\020\002\022\010\n\004DATA\020\003\022"
"\r\n\tKEEPALIVE\020\004\022\r\n\tSUBSCRIBE\020\005\022\017\n\013UNSUBSC"
"RIBE\020\006\022\023\n\017UNSUBSCRIBE_ALL\020\007b\006proto3"
};
static const ::_pbi::DescriptorTable* const descriptor_table_RouterMessage_2eproto_deps[2] =
{
&::descriptor_table_Message_2eproto,
&::descriptor_table_google_2fprotobuf_2fany_2eproto,
};
static ::absl::once_flag descriptor_table_RouterMessage_2eproto_once;
const ::_pbi::DescriptorTable descriptor_table_RouterMessage_2eproto = {
false,
false,
355,
descriptor_table_protodef_RouterMessage_2eproto,
"RouterMessage.proto",
&descriptor_table_RouterMessage_2eproto_once,
descriptor_table_RouterMessage_2eproto_deps,
2,
1,
schemas,
file_default_instances,
TableStruct_RouterMessage_2eproto::offsets,
file_level_metadata_RouterMessage_2eproto,
file_level_enum_descriptors_RouterMessage_2eproto,
file_level_service_descriptors_RouterMessage_2eproto,
};
// This function exists to be marked as weak.
// It can significantly speed up compilation by breaking up LLVM's SCC
// in the .pb.cc translation units. Large translation units see a
// reduction of more than 35% of walltime for optimized builds. Without
// the weak attribute all the messages in the file, including all the
// vtables and everything they use become part of the same SCC through
// a cycle like:
// GetMetadata -> descriptor table -> default instances ->
// vtables -> GetMetadata
// By adding a weak function here we break the connection from the
// individual vtables back into the descriptor table.
PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_RouterMessage_2eproto_getter() {
return &descriptor_table_RouterMessage_2eproto;
}
// Force running AddDescriptors() at dynamic initialization time.
PROTOBUF_ATTRIBUTE_INIT_PRIORITY2
static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_RouterMessage_2eproto(&descriptor_table_RouterMessage_2eproto);
namespace WhisperCom {
namespace Protobuf {
const ::google::protobuf::EnumDescriptor* RouterMessageType_descriptor() {
::google::protobuf::internal::AssignDescriptors(&descriptor_table_RouterMessage_2eproto);
return file_level_enum_descriptors_RouterMessage_2eproto[0];
}
bool RouterMessageType_IsValid(int value) {
switch (value) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
return true;
default:
return false;
}
}
// ===================================================================
class RouterMessage::_Internal {
public:
using HasBits = decltype(std::declval<RouterMessage>()._impl_._has_bits_);
static constexpr ::int32_t kHasBitsOffset =
8 * PROTOBUF_FIELD_OFFSET(RouterMessage, _impl_._has_bits_);
static const ::WhisperCom::Protobuf::Message& msg(const RouterMessage* msg);
static void set_has_msg(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
};
const ::WhisperCom::Protobuf::Message& RouterMessage::_Internal::msg(const RouterMessage* msg) {
return *msg->_impl_.msg_;
}
void RouterMessage::clear_msg() {
if (_impl_.msg_ != nullptr) _impl_.msg_->Clear();
_impl_._has_bits_[0] &= ~0x00000001u;
}
RouterMessage::RouterMessage(::google::protobuf::Arena* arena)
: ::google::protobuf::Message(arena) {
SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:WhisperCom.Protobuf.RouterMessage)
}
RouterMessage::RouterMessage(const RouterMessage& from) : ::google::protobuf::Message() {
RouterMessage* const _this = this;
(void)_this;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){from._impl_._has_bits_},
/*decltype(_impl_._cached_size_)*/ {},
decltype(_impl_.topic_){},
decltype(_impl_.msg_){nullptr},
decltype(_impl_.type_){},
};
_internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>(
from._internal_metadata_);
_impl_.topic_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.topic_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_topic().empty()) {
_this->_impl_.topic_.Set(from._internal_topic(), _this->GetArenaForAllocation());
}
if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) {
_this->_impl_.msg_ = new ::WhisperCom::Protobuf::Message(*from._impl_.msg_);
}
_this->_impl_.type_ = from._impl_.type_;
// @@protoc_insertion_point(copy_constructor:WhisperCom.Protobuf.RouterMessage)
}
inline void RouterMessage::SharedCtor(::_pb::Arena* arena) {
(void)arena;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){},
/*decltype(_impl_._cached_size_)*/ {},
decltype(_impl_.topic_){},
decltype(_impl_.msg_){nullptr},
decltype(_impl_.type_){0},
};
_impl_.topic_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.topic_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
RouterMessage::~RouterMessage() {
// @@protoc_insertion_point(destructor:WhisperCom.Protobuf.RouterMessage)
_internal_metadata_.Delete<::google::protobuf::UnknownFieldSet>();
SharedDtor();
}
inline void RouterMessage::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.topic_.Destroy();
if (this != internal_default_instance()) delete _impl_.msg_;
}
void RouterMessage::SetCachedSize(int size) const {
_impl_._cached_size_.Set(size);
}
PROTOBUF_NOINLINE void RouterMessage::Clear() {
// @@protoc_insertion_point(message_clear_start:WhisperCom.Protobuf.RouterMessage)
::uint32_t cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
_impl_.topic_.ClearToEmpty();
cached_has_bits = _impl_._has_bits_[0];
if (cached_has_bits & 0x00000001u) {
ABSL_DCHECK(_impl_.msg_ != nullptr);
_impl_.msg_->Clear();
}
_impl_.type_ = 0;
_impl_._has_bits_.Clear();
_internal_metadata_.Clear<::google::protobuf::UnknownFieldSet>();
}
const char* RouterMessage::_InternalParse(
const char* ptr, ::_pbi::ParseContext* ctx) {
ptr = ::_pbi::TcParser::ParseLoop(this, ptr, ctx, &_table_.header);
return ptr;
}
PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
const ::_pbi::TcParseTable<2, 3, 1, 47, 2> RouterMessage::_table_ = {
{
PROTOBUF_FIELD_OFFSET(RouterMessage, _impl_._has_bits_),
0, // no _extensions_
3, 24, // max_field_number, fast_idx_mask
offsetof(decltype(_table_), field_lookup_table),
4294967288, // skipmap
offsetof(decltype(_table_), field_entries),
3, // num_field_entries
1, // num_aux_entries
offsetof(decltype(_table_), aux_entries),
&_RouterMessage_default_instance_._instance,
::_pbi::TcParser::GenericFallback, // fallback
}, {{
{::_pbi::TcParser::MiniParse, {}},
// .WhisperCom.Protobuf.RouterMessageType type = 1;
{::_pbi::TcParser::SingularVarintNoZag1<::uint32_t, offsetof(RouterMessage, _impl_.type_), 63>(),
{8, 63, 0, PROTOBUF_FIELD_OFFSET(RouterMessage, _impl_.type_)}},
// .WhisperCom.Protobuf.Message msg = 2;
{::_pbi::TcParser::FastMtS1,
{18, 0, 0, PROTOBUF_FIELD_OFFSET(RouterMessage, _impl_.msg_)}},
// string topic = 3;
{::_pbi::TcParser::FastUS1,
{26, 63, 0, PROTOBUF_FIELD_OFFSET(RouterMessage, _impl_.topic_)}},
}}, {{
65535, 65535
}}, {{
// .WhisperCom.Protobuf.RouterMessageType type = 1;
{PROTOBUF_FIELD_OFFSET(RouterMessage, _impl_.type_), -1, 0,
(0 | ::_fl::kFcSingular | ::_fl::kOpenEnum)},
// .WhisperCom.Protobuf.Message msg = 2;
{PROTOBUF_FIELD_OFFSET(RouterMessage, _impl_.msg_), _Internal::kHasBitsOffset + 0, 0,
(0 | ::_fl::kFcOptional | ::_fl::kMessage | ::_fl::kTvTable)},
// string topic = 3;
{PROTOBUF_FIELD_OFFSET(RouterMessage, _impl_.topic_), -1, 0,
(0 | ::_fl::kFcSingular | ::_fl::kUtf8String | ::_fl::kRepAString)},
}}, {{
{::_pbi::TcParser::GetTable<::WhisperCom::Protobuf::Message>()},
}}, {{
"\41\0\0\5\0\0\0\0"
"WhisperCom.Protobuf.RouterMessage"
"topic"
}},
};
::uint8_t* RouterMessage::_InternalSerialize(
::uint8_t* target,
::google::protobuf::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:WhisperCom.Protobuf.RouterMessage)
::uint32_t cached_has_bits = 0;
(void)cached_has_bits;
// .WhisperCom.Protobuf.RouterMessageType type = 1;
if (this->_internal_type() != 0) {
target = stream->EnsureSpace(target);
target = ::_pbi::WireFormatLite::WriteEnumToArray(
1, this->_internal_type(), target);
}
cached_has_bits = _impl_._has_bits_[0];
// .WhisperCom.Protobuf.Message msg = 2;
if (cached_has_bits & 0x00000001u) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessage(2, _Internal::msg(this),
_Internal::msg(this).GetCachedSize(), target, stream);
}
// string topic = 3;
if (!this->_internal_topic().empty()) {
const std::string& _s = this->_internal_topic();
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
_s.data(), static_cast<int>(_s.length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "WhisperCom.Protobuf.RouterMessage.topic");
target = stream->WriteStringMaybeAliased(3, _s, target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target =
::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:WhisperCom.Protobuf.RouterMessage)
return target;
}
::size_t RouterMessage::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:WhisperCom.Protobuf.RouterMessage)
::size_t total_size = 0;
::uint32_t cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// string topic = 3;
if (!this->_internal_topic().empty()) {
total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize(
this->_internal_topic());
}
// .WhisperCom.Protobuf.Message msg = 2;
cached_has_bits = _impl_._has_bits_[0];
if (cached_has_bits & 0x00000001u) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
*_impl_.msg_);
}
// .WhisperCom.Protobuf.RouterMessageType type = 1;
if (this->_internal_type() != 0) {
total_size += 1 +
::_pbi::WireFormatLite::EnumSize(this->_internal_type());
}