Atmosphere-libs/include/stratosphere/sf/cmif/sf_cmif_domain_api.hpp
Michael Scire 15f3adb8d2 sf: implement service framework enough for ro to work.
This completely re-does the whole interface for ipc servers.
2019-12-07 18:44:32 -08:00

69 lines
2.4 KiB
C++

/*
* Copyright (c) 2018-2019 Atmosphère-NX
*
* 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 "../sf_common.hpp"
#include "sf_cmif_service_object_holder.hpp"
namespace sts::sf::cmif {
struct DomainObjectId {
u32 value;
constexpr void SetValue(u32 new_value) { this->value = new_value; }
};
static_assert(std::is_trivial<DomainObjectId>::value, "DomainObjectId");
inline constexpr bool operator==(const DomainObjectId &lhs, const DomainObjectId &rhs) {
return lhs.value == rhs.value;
}
inline constexpr bool operator!=(const DomainObjectId &lhs, const DomainObjectId &rhs) {
return lhs.value != rhs.value;
}
inline constexpr bool operator<(const DomainObjectId &lhs, const DomainObjectId &rhs) {
return lhs.value < rhs.value;
}
inline constexpr bool operator<=(const DomainObjectId &lhs, const DomainObjectId &rhs) {
return lhs.value <= rhs.value;
}
inline constexpr bool operator>(const DomainObjectId &lhs, const DomainObjectId &rhs) {
return lhs.value > rhs.value;
}
inline constexpr bool operator>=(const DomainObjectId &lhs, const DomainObjectId &rhs) {
return lhs.value >= rhs.value;
}
constexpr inline const DomainObjectId InvalidDomainObjectId = { .value = 0 };
class ServerDomainBase {
public:
virtual Result ReserveIds(DomainObjectId *out_ids, size_t count) = 0;
virtual Result AlterReservedIds(const DomainObjectId *old_reserved_ids, const DomainObjectId *new_reserved_ids, size_t count) = 0;
virtual void UnreserveIds(const DomainObjectId *ids, size_t count) = 0;
virtual void RegisterObject(DomainObjectId id, ServiceObjectHolder &&obj) = 0;
virtual ServiceObjectHolder UnregisterObject(DomainObjectId id) = 0;
virtual ServiceObjectHolder GetObject(DomainObjectId id) = 0;
};
}