strat: use m_ for member variables
This commit is contained in:
@@ -24,23 +24,23 @@ namespace ams::ddsf {
|
||||
NON_COPYABLE(DeviceCodeEntry);
|
||||
NON_MOVEABLE(DeviceCodeEntry);
|
||||
private:
|
||||
ams::DeviceCode device_code = ams::InvalidDeviceCode;
|
||||
IDevice *device = nullptr;
|
||||
ams::DeviceCode m_device_code = ams::InvalidDeviceCode;
|
||||
IDevice *m_device = nullptr;
|
||||
public:
|
||||
constexpr DeviceCodeEntry(ams::DeviceCode dc, IDevice *dev) : device_code(dc), device(dev) {
|
||||
constexpr DeviceCodeEntry(ams::DeviceCode dc, IDevice *dev) : m_device_code(dc), m_device(dev) {
|
||||
AMS_ASSERT(dev != nullptr);
|
||||
}
|
||||
|
||||
constexpr ams::DeviceCode GetDeviceCode() const {
|
||||
return this->device_code;
|
||||
return m_device_code;
|
||||
}
|
||||
|
||||
constexpr IDevice &GetDevice() {
|
||||
return *this->device;
|
||||
return *m_device;
|
||||
}
|
||||
|
||||
constexpr const IDevice &GetDevice() const {
|
||||
return *this->device;
|
||||
return *m_device;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -48,15 +48,15 @@ namespace ams::ddsf {
|
||||
NON_COPYABLE(DeviceCodeEntryHolder);
|
||||
NON_MOVEABLE(DeviceCodeEntryHolder);
|
||||
private:
|
||||
util::IntrusiveListNode list_node;
|
||||
util::TypedStorage<DeviceCodeEntry> entry_storage;
|
||||
bool is_constructed;
|
||||
util::IntrusiveListNode m_list_node;
|
||||
util::TypedStorage<DeviceCodeEntry> m_entry_storage;
|
||||
bool m_is_constructed;
|
||||
public:
|
||||
using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&DeviceCodeEntryHolder::list_node>;
|
||||
using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&DeviceCodeEntryHolder::m_list_node>;
|
||||
using List = typename ListTraits::ListType;
|
||||
friend class util::IntrusiveList<DeviceCodeEntryHolder, util::IntrusiveListMemberTraitsDeferredAssert<&DeviceCodeEntryHolder::list_node>>;
|
||||
friend class util::IntrusiveList<DeviceCodeEntryHolder, util::IntrusiveListMemberTraitsDeferredAssert<&DeviceCodeEntryHolder::m_list_node>>;
|
||||
public:
|
||||
DeviceCodeEntryHolder() : list_node(), entry_storage(), is_constructed(false) {
|
||||
DeviceCodeEntryHolder() : m_list_node(), m_entry_storage(), m_is_constructed(false) {
|
||||
/* ... */
|
||||
}
|
||||
|
||||
@@ -75,34 +75,34 @@ namespace ams::ddsf {
|
||||
}
|
||||
|
||||
bool IsLinkedToList() const {
|
||||
return this->list_node.IsLinked();
|
||||
return m_list_node.IsLinked();
|
||||
}
|
||||
|
||||
DeviceCodeEntry &Construct(DeviceCode dc, IDevice *dev) {
|
||||
AMS_ASSERT(!this->IsConstructed());
|
||||
DeviceCodeEntry *entry = util::ConstructAt(this->entry_storage, dc, dev);
|
||||
this->is_constructed = true;
|
||||
DeviceCodeEntry *entry = util::ConstructAt(m_entry_storage, dc, dev);
|
||||
m_is_constructed = true;
|
||||
return *entry;
|
||||
}
|
||||
|
||||
bool IsConstructed() const {
|
||||
return this->is_constructed;
|
||||
return m_is_constructed;
|
||||
}
|
||||
|
||||
void Destroy() {
|
||||
AMS_ASSERT(this->IsConstructed());
|
||||
util::DestroyAt(this->entry_storage);
|
||||
this->is_constructed = false;
|
||||
util::DestroyAt(m_entry_storage);
|
||||
m_is_constructed = false;
|
||||
}
|
||||
|
||||
DeviceCodeEntry &Get() {
|
||||
AMS_ASSERT(this->IsConstructed());
|
||||
return GetReference(this->entry_storage);
|
||||
return GetReference(m_entry_storage);
|
||||
}
|
||||
|
||||
const DeviceCodeEntry &Get() const {
|
||||
AMS_ASSERT(this->IsConstructed());
|
||||
return GetReference(this->entry_storage);
|
||||
return GetReference(m_entry_storage);
|
||||
}
|
||||
};
|
||||
static_assert(DeviceCodeEntryHolder::ListTraits::IsValid());
|
||||
|
||||
@@ -25,33 +25,33 @@ namespace ams::ddsf {
|
||||
|
||||
class DeviceCodeEntryManager {
|
||||
private:
|
||||
ams::MemoryResource *memory_resource;
|
||||
ddsf::DeviceCodeEntryHolder::List entry_list;
|
||||
mutable os::SdkMutex entry_list_lock;
|
||||
ams::MemoryResource *m_memory_resource;
|
||||
ddsf::DeviceCodeEntryHolder::List m_entry_list;
|
||||
mutable os::SdkMutex m_entry_list_lock;
|
||||
private:
|
||||
void DestroyAllEntries() {
|
||||
auto it = this->entry_list.begin();
|
||||
while (it != this->entry_list.end()) {
|
||||
auto it = m_entry_list.begin();
|
||||
while (it != m_entry_list.end()) {
|
||||
ddsf::DeviceCodeEntryHolder *entry = std::addressof(*it);
|
||||
it = this->entry_list.erase(it);
|
||||
it = m_entry_list.erase(it);
|
||||
|
||||
AMS_ASSERT(entry->IsConstructed());
|
||||
if (entry->IsConstructed()) {
|
||||
entry->Destroy();
|
||||
}
|
||||
|
||||
this->memory_resource->Deallocate(entry, sizeof(*entry));
|
||||
m_memory_resource->Deallocate(entry, sizeof(*entry));
|
||||
}
|
||||
}
|
||||
public:
|
||||
DeviceCodeEntryManager(ams::MemoryResource *mr) : memory_resource(mr), entry_list(), entry_list_lock() { /* ... */ }
|
||||
DeviceCodeEntryManager(ams::MemoryResource *mr) : m_memory_resource(mr), m_entry_list(), m_entry_list_lock() { /* ... */ }
|
||||
|
||||
~DeviceCodeEntryManager() {
|
||||
this->DestroyAllEntries();
|
||||
}
|
||||
|
||||
void Reset() {
|
||||
std::scoped_lock lk(this->entry_list_lock);
|
||||
std::scoped_lock lk(m_entry_list_lock);
|
||||
this->DestroyAllEntries();
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace ams::ddsf {
|
||||
|
||||
template<typename F>
|
||||
int ForEachEntry(F f) {
|
||||
return impl::ForEach(this->entry_list_lock, this->entry_list, [&](DeviceCodeEntryHolder &holder) -> bool {
|
||||
return impl::ForEach(m_entry_list_lock, m_entry_list, [&](DeviceCodeEntryHolder &holder) -> bool {
|
||||
AMS_ASSERT(holder.IsConstructed());
|
||||
return f(holder.Get());
|
||||
});
|
||||
@@ -74,7 +74,7 @@ namespace ams::ddsf {
|
||||
|
||||
template<typename F>
|
||||
int ForEachEntry(F f) const {
|
||||
return impl::ForEach(this->entry_list_lock, this->entry_list, [&](const DeviceCodeEntryHolder &holder) -> bool {
|
||||
return impl::ForEach(m_entry_list_lock, m_entry_list, [&](const DeviceCodeEntryHolder &holder) -> bool {
|
||||
AMS_ASSERT(holder.IsConstructed());
|
||||
return f(holder.Get());
|
||||
});
|
||||
|
||||
@@ -28,41 +28,41 @@ namespace ams::ddsf {
|
||||
private:
|
||||
struct LoopControlCommandParameters;
|
||||
private:
|
||||
bool is_initialized;
|
||||
bool is_looping;
|
||||
os::SdkConditionVariable is_looping_cv;
|
||||
os::MultiWaitType multi_wait;
|
||||
os::ThreadType *loop_thread;
|
||||
os::Event loop_control_event;
|
||||
os::MultiWaitHolderType loop_control_event_holder;
|
||||
LoopControlCommandParameters *loop_control_command_params;
|
||||
os::LightEvent loop_control_command_done_event;
|
||||
os::SdkMutex loop_control_lock;
|
||||
bool m_is_initialized;
|
||||
bool m_is_looping;
|
||||
os::SdkConditionVariable m_is_looping_cv;
|
||||
os::MultiWaitType m_multi_wait;
|
||||
os::ThreadType *m_loop_thread;
|
||||
os::Event m_loop_control_event;
|
||||
os::MultiWaitHolderType m_loop_control_event_holder;
|
||||
LoopControlCommandParameters *m_loop_control_command_params;
|
||||
os::LightEvent m_loop_control_command_done_event;
|
||||
os::SdkMutex m_loop_control_lock;
|
||||
private:
|
||||
void ProcessControlCommand(LoopControlCommandParameters *params);
|
||||
void ProcessControlCommandImpl(LoopControlCommandParameters *params);
|
||||
public:
|
||||
EventHandlerManager()
|
||||
: is_initialized(false), is_looping(false), is_looping_cv(), multi_wait(),
|
||||
loop_thread(), loop_control_event(os::EventClearMode_AutoClear), loop_control_event_holder(),
|
||||
loop_control_command_params(), loop_control_command_done_event(os::EventClearMode_AutoClear),
|
||||
loop_control_lock()
|
||||
: m_is_initialized(false), m_is_looping(false), m_is_looping_cv(), m_multi_wait(),
|
||||
m_loop_thread(), m_loop_control_event(os::EventClearMode_AutoClear), m_loop_control_event_holder(),
|
||||
m_loop_control_command_params(), m_loop_control_command_done_event(os::EventClearMode_AutoClear),
|
||||
m_loop_control_lock()
|
||||
{
|
||||
this->Initialize();
|
||||
}
|
||||
|
||||
~EventHandlerManager() {
|
||||
if (this->is_looping) {
|
||||
if (m_is_looping) {
|
||||
AMS_ASSERT(!this->IsRunningOnLoopThread());
|
||||
this->RequestStop();
|
||||
}
|
||||
if (this->is_initialized) {
|
||||
if (m_is_initialized) {
|
||||
this->Finalize();
|
||||
}
|
||||
}
|
||||
|
||||
bool IsRunningOnLoopThread() const { return this->loop_thread == os::GetCurrentThread(); }
|
||||
bool IsLooping() const { return this->is_looping; }
|
||||
bool IsRunningOnLoopThread() const { return m_loop_thread == os::GetCurrentThread(); }
|
||||
bool IsLooping() const { return m_is_looping; }
|
||||
|
||||
void Initialize();
|
||||
void Finalize();
|
||||
|
||||
@@ -32,57 +32,57 @@ namespace ams::ddsf {
|
||||
public:
|
||||
AMS_DDSF_CASTABLE_ROOT_TRAITS(ams::ddsf::IDevice);
|
||||
private:
|
||||
util::IntrusiveListNode list_node;
|
||||
IDriver *driver;
|
||||
ISession::List session_list;
|
||||
mutable os::SdkMutex session_list_lock;
|
||||
bool is_exclusive_write;
|
||||
util::IntrusiveListNode m_list_node;
|
||||
IDriver *m_driver;
|
||||
ISession::List m_session_list;
|
||||
mutable os::SdkMutex m_session_list_lock;
|
||||
bool m_is_exclusive_write;
|
||||
public:
|
||||
using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&IDevice::list_node>;
|
||||
using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&IDevice::m_list_node>;
|
||||
using List = typename ListTraits::ListType;
|
||||
friend class util::IntrusiveList<IDevice, util::IntrusiveListMemberTraitsDeferredAssert<&IDevice::list_node>>;
|
||||
friend class util::IntrusiveList<IDevice, util::IntrusiveListMemberTraitsDeferredAssert<&IDevice::m_list_node>>;
|
||||
private:
|
||||
Result AttachSession(ISession *session) {
|
||||
AMS_ASSERT(session != nullptr);
|
||||
std::scoped_lock lk(this->session_list_lock);
|
||||
std::scoped_lock lk(m_session_list_lock);
|
||||
|
||||
/* Check if we're allowed to attach the session. */
|
||||
if (this->is_exclusive_write && session->CheckExclusiveWrite()) {
|
||||
for (const auto &attached : this->session_list) {
|
||||
if (m_is_exclusive_write && session->CheckExclusiveWrite()) {
|
||||
for (const auto &attached : m_session_list) {
|
||||
R_UNLESS(!attached.CheckAccess(AccessMode_Write), ddsf::ResultAccessModeDenied());
|
||||
}
|
||||
}
|
||||
|
||||
/* Attach the session. */
|
||||
this->session_list.push_back(*session);
|
||||
m_session_list.push_back(*session);
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
void DetachSession(ISession *session) {
|
||||
AMS_ASSERT(session != nullptr);
|
||||
std::scoped_lock lk(this->session_list_lock);
|
||||
this->session_list.erase(this->session_list.iterator_to(*session));
|
||||
std::scoped_lock lk(m_session_list_lock);
|
||||
m_session_list.erase(m_session_list.iterator_to(*session));
|
||||
}
|
||||
|
||||
void AttachDriver(IDriver *drv) {
|
||||
AMS_ASSERT(drv != nullptr);
|
||||
AMS_ASSERT(!this->IsDriverAttached());
|
||||
this->driver = drv;
|
||||
m_driver = drv;
|
||||
AMS_ASSERT(this->IsDriverAttached());
|
||||
}
|
||||
|
||||
void DetachDriver() {
|
||||
AMS_ASSERT(this->IsDriverAttached());
|
||||
this->driver = nullptr;
|
||||
m_driver = nullptr;
|
||||
AMS_ASSERT(!this->IsDriverAttached());
|
||||
}
|
||||
public:
|
||||
IDevice(bool exclusive_write) : list_node(), driver(nullptr), session_list(), session_list_lock(), is_exclusive_write(exclusive_write) {
|
||||
this->session_list.clear();
|
||||
IDevice(bool exclusive_write) : m_list_node(), m_driver(nullptr), m_session_list(), m_session_list_lock(), m_is_exclusive_write(exclusive_write) {
|
||||
m_session_list.clear();
|
||||
}
|
||||
protected:
|
||||
~IDevice() {
|
||||
this->session_list.clear();
|
||||
m_session_list.clear();
|
||||
}
|
||||
public:
|
||||
void AddTo(List &list) {
|
||||
@@ -94,45 +94,45 @@ namespace ams::ddsf {
|
||||
}
|
||||
|
||||
bool IsLinkedToList() const {
|
||||
return this->list_node.IsLinked();
|
||||
return m_list_node.IsLinked();
|
||||
}
|
||||
|
||||
IDriver &GetDriver() {
|
||||
AMS_ASSERT(this->IsDriverAttached());
|
||||
return *this->driver;
|
||||
return *m_driver;
|
||||
}
|
||||
|
||||
const IDriver &GetDriver() const {
|
||||
AMS_ASSERT(this->IsDriverAttached());
|
||||
return *this->driver;
|
||||
return *m_driver;
|
||||
}
|
||||
|
||||
bool IsDriverAttached() const {
|
||||
return this->driver != nullptr;
|
||||
return m_driver != nullptr;
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
Result ForEachSession(F f, bool return_on_fail) {
|
||||
return impl::ForEach(this->session_list_lock, this->session_list, f, return_on_fail);
|
||||
return impl::ForEach(m_session_list_lock, m_session_list, f, return_on_fail);
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
Result ForEachSession(F f, bool return_on_fail) const {
|
||||
return impl::ForEach(this->session_list_lock, this->session_list, f, return_on_fail);
|
||||
return impl::ForEach(m_session_list_lock, m_session_list, f, return_on_fail);
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
int ForEachSession(F f) {
|
||||
return impl::ForEach(this->session_list_lock, this->session_list, f);
|
||||
return impl::ForEach(m_session_list_lock, m_session_list, f);
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
int ForEachSession(F f) const {
|
||||
return impl::ForEach(this->session_list_lock, this->session_list, f);
|
||||
return impl::ForEach(m_session_list_lock, m_session_list, f);
|
||||
}
|
||||
|
||||
bool HasAnyOpenSession() const {
|
||||
return !this->session_list.empty();
|
||||
return !m_session_list.empty();
|
||||
}
|
||||
};
|
||||
static_assert(IDevice::ListTraits::IsValid());
|
||||
|
||||
@@ -27,21 +27,21 @@ namespace ams::ddsf {
|
||||
public:
|
||||
AMS_DDSF_CASTABLE_ROOT_TRAITS(ams::ddsf::IDriver);
|
||||
private:
|
||||
util::IntrusiveListNode list_node;
|
||||
IDevice::List device_list;
|
||||
mutable os::SdkMutex device_list_lock;
|
||||
util::IntrusiveListNode m_list_node;
|
||||
IDevice::List m_device_list;
|
||||
mutable os::SdkMutex m_device_list_lock;
|
||||
public:
|
||||
using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&IDriver::list_node>;
|
||||
using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&IDriver::m_list_node>;
|
||||
using List = typename ListTraits::ListType;
|
||||
friend class util::IntrusiveList<IDriver, util::IntrusiveListMemberTraitsDeferredAssert<&IDriver::list_node>>;
|
||||
friend class util::IntrusiveList<IDriver, util::IntrusiveListMemberTraitsDeferredAssert<&IDriver::m_list_node>>;
|
||||
private:
|
||||
public:
|
||||
IDriver() : list_node(), device_list(), device_list_lock() {
|
||||
this->device_list.clear();
|
||||
IDriver() : m_list_node(), m_device_list(), m_device_list_lock() {
|
||||
m_device_list.clear();
|
||||
}
|
||||
protected:
|
||||
~IDriver() {
|
||||
this->device_list.clear();
|
||||
m_device_list.clear();
|
||||
}
|
||||
public:
|
||||
void AddTo(List &list) {
|
||||
@@ -53,45 +53,45 @@ namespace ams::ddsf {
|
||||
}
|
||||
|
||||
bool IsLinkedToList() const {
|
||||
return this->list_node.IsLinked();
|
||||
return m_list_node.IsLinked();
|
||||
}
|
||||
|
||||
bool HasAnyDevice() const {
|
||||
return !this->device_list.empty();
|
||||
return !m_device_list.empty();
|
||||
}
|
||||
|
||||
void RegisterDevice(IDevice *dev) {
|
||||
AMS_ASSERT(dev != nullptr);
|
||||
std::scoped_lock lk(this->device_list_lock);
|
||||
std::scoped_lock lk(m_device_list_lock);
|
||||
dev->AttachDriver(this);
|
||||
this->device_list.push_back(*dev);
|
||||
m_device_list.push_back(*dev);
|
||||
}
|
||||
|
||||
void UnregisterDevice(IDevice *dev) {
|
||||
AMS_ASSERT(dev != nullptr);
|
||||
std::scoped_lock lk(this->device_list_lock);
|
||||
this->device_list.erase(this->device_list.iterator_to(*dev));
|
||||
std::scoped_lock lk(m_device_list_lock);
|
||||
m_device_list.erase(m_device_list.iterator_to(*dev));
|
||||
dev->DetachDriver();
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
Result ForEachDevice(F f, bool return_on_fail) {
|
||||
return impl::ForEach(this->device_list_lock, this->device_list, f, return_on_fail);
|
||||
return impl::ForEach(m_device_list_lock, m_device_list, f, return_on_fail);
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
Result ForEachDevice(F f, bool return_on_fail) const {
|
||||
return impl::ForEach(this->device_list_lock, this->device_list, f, return_on_fail);
|
||||
return impl::ForEach(m_device_list_lock, m_device_list, f, return_on_fail);
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
int ForEachDevice(F f) {
|
||||
return impl::ForEach(this->device_list_lock, this->device_list, f);
|
||||
return impl::ForEach(m_device_list_lock, m_device_list, f);
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
int ForEachDevice(F f) const {
|
||||
return impl::ForEach(this->device_list_lock, this->device_list, f);
|
||||
return impl::ForEach(m_device_list_lock, m_device_list, f);
|
||||
}
|
||||
};
|
||||
static_assert(IDriver::ListTraits::IsValid());
|
||||
|
||||
@@ -26,22 +26,22 @@ namespace ams::ddsf {
|
||||
NON_MOVEABLE(IEventHandler);
|
||||
friend class EventHandlerManager;
|
||||
private:
|
||||
os::MultiWaitHolderType holder;
|
||||
uintptr_t user_data;
|
||||
bool is_initialized;
|
||||
bool is_registered;
|
||||
os::MultiWaitHolderType m_holder;
|
||||
uintptr_t m_user_data;
|
||||
bool m_is_initialized;
|
||||
bool m_is_registered;
|
||||
private:
|
||||
void Link(os::MultiWaitType *multi_wait) {
|
||||
AMS_ASSERT(this->IsInitialized());
|
||||
AMS_ASSERT(!this->IsRegistered());
|
||||
AMS_ASSERT(multi_wait != nullptr);
|
||||
os::LinkMultiWaitHolder(multi_wait, std::addressof(this->holder));
|
||||
os::LinkMultiWaitHolder(multi_wait, std::addressof(m_holder));
|
||||
}
|
||||
|
||||
void Unlink() {
|
||||
AMS_ASSERT(this->IsInitialized());
|
||||
AMS_ASSERT(this->IsRegistered());
|
||||
os::UnlinkMultiWaitHolder(std::addressof(this->holder));
|
||||
os::UnlinkMultiWaitHolder(std::addressof(m_holder));
|
||||
}
|
||||
|
||||
static IEventHandler &ToEventHandler(os::MultiWaitHolderType *holder) {
|
||||
@@ -51,7 +51,7 @@ namespace ams::ddsf {
|
||||
return event_handler;
|
||||
}
|
||||
public:
|
||||
IEventHandler() : holder(), user_data(0), is_initialized(false), is_registered(false) { /* ... */ }
|
||||
IEventHandler() : m_holder(), m_user_data(0), m_is_initialized(false), m_is_registered(false) { /* ... */ }
|
||||
|
||||
~IEventHandler() {
|
||||
if (this->IsRegistered()) {
|
||||
@@ -62,28 +62,28 @@ namespace ams::ddsf {
|
||||
}
|
||||
}
|
||||
|
||||
bool IsInitialized() const { return this->is_initialized; }
|
||||
bool IsRegistered() const { return this->is_registered; }
|
||||
bool IsInitialized() const { return m_is_initialized; }
|
||||
bool IsRegistered() const { return m_is_registered; }
|
||||
|
||||
uintptr_t GetUserData() const { return this->user_data; }
|
||||
void SetUserData(uintptr_t d) { this->user_data = d; }
|
||||
uintptr_t GetUserData() const { return m_user_data; }
|
||||
void SetUserData(uintptr_t d) { m_user_data = d; }
|
||||
|
||||
template<typename T>
|
||||
void Initialize(T *object) {
|
||||
AMS_ASSERT(object != nullptr);
|
||||
AMS_ASSERT(!this->IsInitialized());
|
||||
os::InitializeMultiWaitHolder(std::addressof(this->holder), object);
|
||||
os::SetMultiWaitHolderUserData(std::addressof(this->holder), reinterpret_cast<uintptr_t>(this));
|
||||
this->is_initialized = true;
|
||||
this->is_registered = false;
|
||||
os::InitializeMultiWaitHolder(std::addressof(m_holder), object);
|
||||
os::SetMultiWaitHolderUserData(std::addressof(m_holder), reinterpret_cast<uintptr_t>(this));
|
||||
m_is_initialized = true;
|
||||
m_is_registered = false;
|
||||
}
|
||||
|
||||
void Finalize() {
|
||||
AMS_ASSERT(this->IsInitialized());
|
||||
AMS_ASSERT(!this->IsRegistered());
|
||||
os::FinalizeMultiWaitHolder(std::addressof(this->holder));
|
||||
this->is_initialized = false;
|
||||
this->is_registered = false;
|
||||
os::FinalizeMultiWaitHolder(std::addressof(m_holder));
|
||||
m_is_initialized = false;
|
||||
m_is_registered = false;
|
||||
}
|
||||
protected:
|
||||
virtual void HandleEvent() = 0;
|
||||
|
||||
@@ -33,30 +33,30 @@ namespace ams::ddsf {
|
||||
public:
|
||||
AMS_DDSF_CASTABLE_ROOT_TRAITS(ams::ddsf::IDevice);
|
||||
private:
|
||||
util::IntrusiveListNode list_node;
|
||||
IDevice *device;
|
||||
AccessMode access_mode;
|
||||
util::IntrusiveListNode m_list_node;
|
||||
IDevice *m_device;
|
||||
AccessMode m_access_mode;
|
||||
public:
|
||||
using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&ISession::list_node>;
|
||||
using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&ISession::m_list_node>;
|
||||
using List = typename ListTraits::ListType;
|
||||
friend class util::IntrusiveList<ISession, util::IntrusiveListMemberTraitsDeferredAssert<&ISession::list_node>>;
|
||||
friend class util::IntrusiveList<ISession, util::IntrusiveListMemberTraitsDeferredAssert<&ISession::m_list_node>>;
|
||||
private:
|
||||
void AttachDevice(IDevice *dev, AccessMode mode) {
|
||||
AMS_ASSERT(dev != nullptr);
|
||||
AMS_ASSERT(!this->IsOpen());
|
||||
this->device = dev;
|
||||
this->access_mode = mode;
|
||||
m_device = dev;
|
||||
m_access_mode = mode;
|
||||
AMS_ASSERT(this->IsOpen());
|
||||
}
|
||||
|
||||
void DetachDevice() {
|
||||
AMS_ASSERT(this->IsOpen());
|
||||
this->device = nullptr;
|
||||
this->access_mode = AccessMode_None;
|
||||
m_device = nullptr;
|
||||
m_access_mode = AccessMode_None;
|
||||
AMS_ASSERT(!this->IsOpen());
|
||||
}
|
||||
public:
|
||||
ISession() : list_node(), device(nullptr), access_mode() { /* ... */ }
|
||||
ISession() : m_list_node(), m_device(nullptr), m_access_mode() { /* ... */ }
|
||||
protected:
|
||||
~ISession() { this->DetachDevice(); AMS_ASSERT(!this->IsOpen()); }
|
||||
public:
|
||||
@@ -69,26 +69,26 @@ namespace ams::ddsf {
|
||||
}
|
||||
|
||||
bool IsLinkedToList() const {
|
||||
return this->list_node.IsLinked();
|
||||
return m_list_node.IsLinked();
|
||||
}
|
||||
|
||||
IDevice &GetDevice() {
|
||||
AMS_ASSERT(this->IsOpen());
|
||||
return *this->device;
|
||||
return *m_device;
|
||||
}
|
||||
|
||||
const IDevice &GetDevice() const {
|
||||
AMS_ASSERT(this->IsOpen());
|
||||
return *this->device;
|
||||
return *m_device;
|
||||
}
|
||||
|
||||
bool IsOpen() const {
|
||||
return this->device != nullptr;
|
||||
return m_device != nullptr;
|
||||
}
|
||||
|
||||
bool CheckAccess(AccessMode mode) const {
|
||||
AMS_ASSERT(this->IsOpen());
|
||||
return ((~this->access_mode) & mode) == 0;
|
||||
return ((~m_access_mode) & mode) == 0;
|
||||
}
|
||||
|
||||
bool CheckExclusiveWrite() const {
|
||||
|
||||
@@ -37,21 +37,21 @@ namespace ams::ddsf::impl {
|
||||
|
||||
class TypeTag {
|
||||
private:
|
||||
const char * const class_name;
|
||||
const TypeTag * const base;
|
||||
const char * const m_class_name;
|
||||
const TypeTag * const m_base;
|
||||
public:
|
||||
#if !(defined(AMS_BUILD_FOR_DEBUGGING) || defined(AMS_BUILD_FOR_AUDITING))
|
||||
constexpr TypeTag() : class_name(nullptr), base(nullptr) { /* ... */}
|
||||
constexpr TypeTag(const TypeTag &b) : class_name(nullptr), base(std::addressof(b)) { AMS_ASSERT(this != this->base); }
|
||||
constexpr TypeTag() : m_class_name(nullptr), m_base(nullptr) { /* ... */}
|
||||
constexpr TypeTag(const TypeTag &b) : m_class_name(nullptr), m_base(std::addressof(b)) { AMS_ASSERT(this != m_base); }
|
||||
|
||||
constexpr TypeTag(const char *c) : class_name(nullptr), base(nullptr) { AMS_UNUSED(c); }
|
||||
constexpr TypeTag(const char *c, const TypeTag &b) : class_name(nullptr), base(std::addressof(b)) { AMS_UNUSED(c); AMS_ASSERT(this != this->base); }
|
||||
constexpr TypeTag(const char *c) : m_class_name(nullptr), m_base(nullptr) { AMS_UNUSED(c); }
|
||||
constexpr TypeTag(const char *c, const TypeTag &b) : m_class_name(nullptr), m_base(std::addressof(b)) { AMS_UNUSED(c); AMS_ASSERT(this != m_base); }
|
||||
#else
|
||||
constexpr TypeTag(const char *c) : class_name(c), base(nullptr) { /* ... */ }
|
||||
constexpr TypeTag(const char *c, const TypeTag &b) : class_name(c), base(std::addressof(b)) { AMS_ASSERT(this != this->base); }
|
||||
constexpr TypeTag(const char *c) : m_class_name(c), m_base(nullptr) { /* ... */ }
|
||||
constexpr TypeTag(const char *c, const TypeTag &b) : m_class_name(c), m_base(std::addressof(b)) { AMS_ASSERT(this != m_base); }
|
||||
#endif
|
||||
|
||||
constexpr const char * GetClassName() const { return this->class_name; }
|
||||
constexpr const char * GetClassName() const { return m_class_name; }
|
||||
|
||||
constexpr bool Is(const TypeTag &rhs) const { return this == std::addressof(rhs); }
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace ams::ddsf::impl {
|
||||
if (cur == std::addressof(rhs)) {
|
||||
return true;
|
||||
}
|
||||
cur = cur->base;
|
||||
cur = cur->m_base;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user