forked from Research/WhisperCom
41 lines
1.2 KiB
C++
41 lines
1.2 KiB
C++
#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/.
|
|
*/
|
|
/** @file */
|
|
/** @copyright 2021 MPLv2 */
|
|
#include <Whisper/Network/Encoding.hpp>
|
|
#include <Tree/tree.hpp>
|
|
#include <memory>
|
|
|
|
/**
|
|
* @brief This is the main namespace for all whisper-com related datatypes and classed.
|
|
*/
|
|
namespace Whisper
|
|
{
|
|
|
|
|
|
class Transmittable : public std::enable_shared_from_this<Whisper::Transmittable>
|
|
{
|
|
private:
|
|
std::shared_ptr<Whisper::Network::Encoding> encoding_;
|
|
|
|
public:
|
|
Transmittable() : encoding_(nullptr) {}
|
|
~Transmittable() {encoding_=nullptr;}
|
|
void setEncoding(std::shared_ptr<Whisper::Network::Encoding> encoding) {encoding_=encoding;}
|
|
std::shared_ptr<Whisper::Network::Encoding> encoding() { return encoding_;}
|
|
bool hasEnconding() { return encoding_ != nullptr;}
|
|
|
|
virtual std::shared_ptr<std::vector<std::uint8_t>> encode() = 0;
|
|
virtual void decode(std::shared_ptr<std::vector<std::uint8_t>> data) = 0;
|
|
virtual std::shared_ptr<Tree::BaseNode> getPayload() = 0;
|
|
|
|
|
|
}; // Transmittable
|
|
|
|
|
|
|
|
}; // namespace Whisper
|