Squashed 'libs/CommService/' content from commit 7ccc0fc

git-subtree-dir: libs/CommService
git-subtree-split: 7ccc0fce88bbc5969df060058cf0fb57abe3bcf9
This commit is contained in:
Henry Winkel
2022-09-15 09:53:53 +02:00
commit cc67e4840f
799 changed files with 179487 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
#include <CommService/Convert.hpp>
#include <CommService/Message.hpp>
#include <CommService/PayLoads/Join.hpp>
#include <CommService/transmittable.hpp>
#include <cstring>
#include <vector>
#include <sstream>
#include <loguru.hpp>
namespace CommService {
namespace PayLoads {
/**
* @brief Constructor for generationg a HotPlugJoin object from a received std::vector<unsiged char>
*
* @param v - the std::vector<unsigned char> representing a message object
*/
Join::Join(std::vector<unsigned char> v)
{
/*
* parse the vector
*/
std::memcpy(networkLayerAddress,v.data(),16);
v.erase(v.begin(), v.begin()+sizeof(networkLayerAddress));
transportLayerAddress=Convert::fromByteArrayToSimple<std::uint32_t>(v);
v.erase(v.begin(), v.begin()+sizeof(transportLayerAddress));
}
/**
* @brief converts the whole Payload information into a byte vector
*
* @param payload - returns the byte vector by call by reference
*/
std::vector<unsigned char> Join::toByteVector() const
{
std::vector<unsigned char> bytes;
std::vector<unsigned char> convert;
bytes.resize(16);
std::memcpy(bytes.data(),networkLayerAddress,16);
convert=Convert::fromSimpleToByteArray(transportLayerAddress);
bytes.insert(std::end(bytes), std::begin(convert), std::end(convert));
return bytes;
}
};
};