2021-02-08 07:13:04 +00:00
|
|
|
/*
|
2021-02-08 07:37:16 +00:00
|
|
|
* Copyright (c) 2018-2020 Atmosphère-NX
|
2021-02-08 07:13:04 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <stratosphere.hpp>
|
|
|
|
#include "htclow_ctrl_packet.hpp"
|
|
|
|
|
|
|
|
namespace ams::htclow::ctrl {
|
|
|
|
|
|
|
|
class HtcctrlPacketFactory;
|
|
|
|
|
|
|
|
class HtcctrlSendBuffer {
|
|
|
|
private:
|
|
|
|
using PacketList = util::IntrusiveListBaseTraits<HtcctrlPacket>::ListType;
|
|
|
|
private:
|
|
|
|
HtcctrlPacketFactory *m_packet_factory;
|
2021-02-09 07:44:30 +00:00
|
|
|
PacketList m_prior_packet_list;
|
|
|
|
PacketList m_posterior_packet_list;
|
|
|
|
private:
|
|
|
|
bool IsPriorPacket(HtcctrlPacketType packet_type) const;
|
|
|
|
bool IsPosteriorPacket(HtcctrlPacketType packet_type) const;
|
2021-02-09 09:05:43 +00:00
|
|
|
|
|
|
|
void CopyPacket(HtcctrlPacketHeader *header, HtcctrlPacketBody *body, int *out_body_size, const HtcctrlPacket &packet);
|
2021-02-08 07:13:04 +00:00
|
|
|
public:
|
2021-02-09 07:44:30 +00:00
|
|
|
HtcctrlSendBuffer(HtcctrlPacketFactory *pf) : m_packet_factory(pf), m_prior_packet_list(), m_posterior_packet_list() { /* ... */ }
|
|
|
|
|
|
|
|
void AddPacket(std::unique_ptr<HtcctrlPacket, HtcctrlPacketDeleter> ptr);
|
2021-02-09 09:05:43 +00:00
|
|
|
void RemovePacket(const HtcctrlPacketHeader &header);
|
|
|
|
|
|
|
|
bool QueryNextPacket(HtcctrlPacketHeader *header, HtcctrlPacketBody *body, int *out_body_size);
|
2021-02-08 07:13:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|