45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
/*
|
||
* BinaryDataRecycler.hh
|
||
*
|
||
* Created on: 8 окт. 2022 г.
|
||
* Author: titov
|
||
*/
|
||
|
||
#ifndef UMLIBRARY_DRIVER_BINARYDATARECYCLER_HH_
|
||
#define UMLIBRARY_DRIVER_BINARYDATARECYCLER_HH_
|
||
|
||
#include "../systemic/IProcess.hh"
|
||
#include "../communication/format/BinaryDataPublisher.hh"
|
||
|
||
#include <memory_resource>
|
||
#include <vector>
|
||
#include <mutex>
|
||
|
||
namespace driver {
|
||
|
||
//!Модуль отложенной обработки бинарных данных.
|
||
class BinaryDataRecycler : public communication::ISubscriberRegistrator,
|
||
public communication::IBinaryDataSubscriber,
|
||
public systemic::IProcess {
|
||
|
||
public:
|
||
BinaryDataRecycler( std::pmr::memory_resource * memory_resource, std::size_t bit_len );
|
||
|
||
void addSubscriber( std::size_t bit_address, std::size_t bit_len, communication::IBinaryDataSubscriber * subscriber ) override;
|
||
void read( const void * data, std::size_t size ) override;
|
||
void process() override;
|
||
|
||
private:
|
||
communication::format::BinaryDataPublisher subscribers; //!Абонент.
|
||
|
||
std::vector< char, std::pmr::polymorphic_allocator<char> > buffer;
|
||
const std::size_t bitsize;
|
||
|
||
std::mutex buffer_lock;
|
||
bool updated;
|
||
};
|
||
|
||
}
|
||
|
||
#endif /* UMLIBRARY_DRIVER_BINARYDATARECYCLER_HH_ */
|