1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-09-19 21:43:44 +01:00
nxdumptool/include/tasks.hpp
Pablo Curiel 06676a0639 tasks: cache application metadata and UMS device info using vectors.
* Tasks are now immediately started by their constructor function.

* Events are now part of the class of each task type, in order to avoid instantiating each one of them and passing them as a constructor argument.

* GetTaskEvent() has been added to each task class, which returns a pointer to the private event. This will be used to subscribe Borealis views to a particular event.

* Title and UMS tasks now both cache application metadata and UMS device info using private vectors. Pointers to these private vectors can now be retrieved using public functions GetApplicationMetadata() and GetUmsDevices(), respectively.
2021-06-10 20:33:11 -04:00

124 lines
3.7 KiB
C++

/*
* tasks.hpp
*
* Copyright (c) 2020-2021, DarkMatterCore <pabloacurielz@gmail.com>.
*
* This file is part of nxdumptool (https://github.com/DarkMatterCore/nxdumptool).
*
* nxdumptool 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.
*
* nxdumptool 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 this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#ifndef __TASKS_HPP__
#define __TASKS_HPP__
#include <borealis.hpp>
#include "core/gamecard.h"
#include "core/title.h"
#include "core/ums.h"
#include "core/usb.h"
namespace nxdt::tasks
{
/* Custom event types used by the tasks defined below. */
typedef brls::Event<GameCardStatus> GameCardStatusEvent;
typedef brls::VoidEvent VoidEvent;
typedef brls::Event<bool> BooleanEvent;
/* Custom vector type used to hold pointers to application metadata entries. */
typedef std::vector<TitleApplicationMetadata*> TitleApplicationMetadataVector;
/* Custom vector type used to hold UMS devices. */
typedef std::vector<UsbHsFsDevice> UmsDeviceVector;
/* Gamecard task. */
class GameCardTask: public brls::RepeatingTask
{
private:
GameCardStatusEvent gc_status_event;
GameCardStatus cur_gc_status = GameCardStatus_NotInserted;
GameCardStatus prev_gc_status = GameCardStatus_NotInserted;
public:
GameCardTask(void);
~GameCardTask(void);
void run(retro_time_t current_time) override;
GameCardStatusEvent* GetTaskEvent(void);
};
/* Title task. */
class TitleTask: public brls::RepeatingTask
{
private:
VoidEvent title_event;
TitleApplicationMetadataVector system_metadata;
TitleApplicationMetadataVector user_metadata;
void PopulateApplicationMetadataVector(bool is_system);
public:
TitleTask(void);
~TitleTask(void);
void run(retro_time_t current_time) override;
VoidEvent* GetTaskEvent(void);
TitleApplicationMetadataVector* GetApplicationMetadata(bool is_system);
};
/* USB Mass Storage task. */
class UmsTask: public brls::RepeatingTask
{
private:
VoidEvent ums_event;
UmsDeviceVector ums_devices;
void PopulateUmsDeviceVector(void);
public:
UmsTask(void);
~UmsTask(void);
void run(retro_time_t current_time) override;
VoidEvent* GetTaskEvent(void);
UmsDeviceVector* GetUmsDevices(void);
};
/* USB host device connection task. */
class UsbHostTask: public brls::RepeatingTask
{
private:
BooleanEvent usb_host_event;
bool cur_usb_host_status = false;
bool prev_usb_host_status = false;
public:
UsbHostTask(void);
~UsbHostTask(void);
void run(retro_time_t current_time) override;
BooleanEvent* GetTaskEvent(void);
};
}
#endif /* __TASKS_HPP__ */