#pragma once

#include <mutex>
#include <boost/interprocess/sync/interprocess_mutex.hpp>
#include "shared_data_iface.hpp"

class SharedData : public SharedDataIface {
public:
    SharedData() : p_data_{nullptr}, size_{0} {};

    virtual bool Init(uint8_t * p_data, uint32_t size) override;

    virtual bool Write(uint32_t offset_bytes, void * p_data, uint32_t length) override;

    virtual bool Read(uint32_t offset_bytes, void * p_data, uint32_t length) override;
    
    virtual uint32_t Size() const override { return size_; }

private:
    boost::interprocess::interprocess_mutex mutex_;
    uint8_t * p_data_;
    uint32_t size_;
};