Atmosphere/libraries/libstratosphere/include/stratosphere/tipc/tipc_handles.hpp

96 lines
2.7 KiB
C++
Raw Normal View History

/*
* Copyright (c) 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 <stratosphere/tipc/tipc_common.hpp>
#include <stratosphere/tipc/tipc_out.hpp>
#include <stratosphere/tipc/tipc_pointer_and_size.hpp>
namespace ams::tipc {
2021-10-12 07:20:21 +00:00
/* TODO: How do InHandles work in tipc? No examples to work off of. */
class CopyHandle {
private:
CopyHandle();
};
2021-10-12 07:20:21 +00:00
class MoveHandle {
private:
MoveHandle();
};
template<>
2021-10-12 07:20:21 +00:00
class Out<CopyHandle> {
private:
2021-10-12 07:20:21 +00:00
os::NativeHandle * const m_ptr;
public:
2021-10-12 07:20:21 +00:00
ALWAYS_INLINE Out(os::NativeHandle *p) : m_ptr(p) { /* ... */ }
2021-10-12 07:20:21 +00:00
ALWAYS_INLINE void SetValue(os::NativeHandle v) const {
*m_ptr = v;
}
2021-10-12 07:20:21 +00:00
ALWAYS_INLINE const os::NativeHandle &GetValue() const {
return *m_ptr;
}
2021-10-12 07:20:21 +00:00
ALWAYS_INLINE os::NativeHandle *GetPointer() const {
return m_ptr;
}
2021-10-12 07:20:21 +00:00
/* Convenience operators. */
ALWAYS_INLINE os::NativeHandle &operator*() const {
return *m_ptr;
}
2021-10-12 07:20:21 +00:00
ALWAYS_INLINE os::NativeHandle *operator->() const {
return m_ptr;
}
};
template<>
2021-10-12 07:20:21 +00:00
class Out<MoveHandle> {
private:
2021-10-12 07:20:21 +00:00
os::NativeHandle * const m_ptr;
public:
2021-10-12 07:20:21 +00:00
ALWAYS_INLINE Out(os::NativeHandle *p) : m_ptr(p) { /* ... */ }
2021-10-12 07:20:21 +00:00
ALWAYS_INLINE void SetValue(os::NativeHandle v) const {
*m_ptr = v;
}
2021-10-12 07:20:21 +00:00
ALWAYS_INLINE const os::NativeHandle &GetValue() const {
return *m_ptr;
}
2021-10-12 07:20:21 +00:00
ALWAYS_INLINE os::NativeHandle *GetPointer() const {
return m_ptr;
}
2021-10-12 07:20:21 +00:00
/* Convenience operators. */
ALWAYS_INLINE os::NativeHandle &operator*() const {
return *m_ptr;
}
2021-10-12 07:20:21 +00:00
ALWAYS_INLINE os::NativeHandle *operator->() const {
return m_ptr;
}
};
using OutMoveHandle = tipc::Out<tipc::MoveHandle>;
using OutCopyHandle = tipc::Out<tipc::CopyHandle>;
}