56 lines
1.5 KiB
C++
56 lines
1.5 KiB
C++
/*
|
|
* This file is part of openauto project.
|
|
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
|
*
|
|
* openauto is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
|
|
* openauto is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <QIODevice>
|
|
#include <mutex>
|
|
#include <boost/circular_buffer.hpp>
|
|
#include "aasdk/Common/Data.hpp"
|
|
|
|
namespace openauto
|
|
{
|
|
namespace projection
|
|
{
|
|
|
|
class SequentialBuffer: public QIODevice
|
|
{
|
|
public:
|
|
SequentialBuffer();
|
|
bool isSequential() const override;
|
|
qint64 size() const override;
|
|
qint64 pos() const override;
|
|
bool seek(qint64 pos) override;
|
|
bool atEnd() const override;
|
|
bool reset() override;
|
|
bool canReadLine() const override;
|
|
qint64 bytesAvailable() const override;
|
|
bool open(OpenMode mode) override;
|
|
|
|
protected:
|
|
qint64 readData(char *data, qint64 maxlen) override;
|
|
qint64 writeData(const char *data, qint64 len) override;
|
|
|
|
private:
|
|
boost::circular_buffer<aasdk::common::Data::value_type> data_;
|
|
mutable std::mutex mutex_;
|
|
};
|
|
|
|
}
|
|
}
|