2018-01-13 16:22:39 -05:00
|
|
|
// Copyright 2018 yuzu emulator team
|
2017-10-14 22:50:04 -04:00
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-03-17 22:39:29 -04:00
|
|
|
#include <chrono>
|
2018-01-22 13:46:36 -05:00
|
|
|
#include <memory>
|
2018-11-07 02:01:33 -05:00
|
|
|
#include <queue>
|
2018-11-27 09:18:29 -05:00
|
|
|
#include "core/hle/kernel/writable_event.h"
|
2017-10-14 22:50:04 -04:00
|
|
|
#include "core/hle/service/service.h"
|
|
|
|
|
2019-07-11 00:53:55 -04:00
|
|
|
namespace Kernel {
|
|
|
|
class KernelCore;
|
2020-01-26 13:18:13 -05:00
|
|
|
class TransferMemory;
|
|
|
|
} // namespace Kernel
|
2019-07-11 00:53:55 -04:00
|
|
|
|
|
|
|
namespace Service::NVFlinger {
|
2018-01-22 13:46:36 -05:00
|
|
|
class NVFlinger;
|
|
|
|
}
|
|
|
|
|
2019-07-11 00:53:55 -04:00
|
|
|
namespace Service::AM {
|
2017-10-14 22:50:04 -04:00
|
|
|
|
2018-02-02 16:03:40 -05:00
|
|
|
enum SystemLanguage {
|
|
|
|
Japanese = 0,
|
2018-05-25 22:31:54 -04:00
|
|
|
English = 1, // en-US
|
|
|
|
French = 2,
|
|
|
|
German = 3,
|
|
|
|
Italian = 4,
|
|
|
|
Spanish = 5,
|
|
|
|
Chinese = 6,
|
|
|
|
Korean = 7,
|
|
|
|
Dutch = 8,
|
|
|
|
Portuguese = 9,
|
|
|
|
Russian = 10,
|
|
|
|
Taiwanese = 11,
|
|
|
|
BritishEnglish = 12, // en-GB
|
|
|
|
CanadianFrench = 13,
|
|
|
|
LatinAmericanSpanish = 14, // es-419
|
|
|
|
// 4.0.0+
|
|
|
|
SimplifiedChinese = 15,
|
|
|
|
TraditionalChinese = 16,
|
2018-02-02 16:03:40 -05:00
|
|
|
};
|
|
|
|
|
2018-11-07 02:01:33 -05:00
|
|
|
class AppletMessageQueue {
|
|
|
|
public:
|
|
|
|
enum class AppletMessage : u32 {
|
|
|
|
NoMessage = 0,
|
2019-07-06 13:09:27 -04:00
|
|
|
ExitRequested = 4,
|
2018-11-07 02:01:33 -05:00
|
|
|
FocusStateChanged = 15,
|
|
|
|
OperationModeChanged = 30,
|
|
|
|
PerformanceModeChanged = 31,
|
|
|
|
};
|
|
|
|
|
2019-07-11 00:53:55 -04:00
|
|
|
explicit AppletMessageQueue(Kernel::KernelCore& kernel);
|
2018-11-07 02:01:33 -05:00
|
|
|
~AppletMessageQueue();
|
|
|
|
|
2019-11-24 20:15:51 -05:00
|
|
|
const std::shared_ptr<Kernel::ReadableEvent>& GetMesssageRecieveEvent() const;
|
|
|
|
const std::shared_ptr<Kernel::ReadableEvent>& GetOperationModeChangedEvent() const;
|
2018-11-07 02:01:33 -05:00
|
|
|
void PushMessage(AppletMessage msg);
|
|
|
|
AppletMessage PopMessage();
|
|
|
|
std::size_t GetMessageCount() const;
|
|
|
|
void OperationModeChanged();
|
2019-07-06 13:09:27 -04:00
|
|
|
void RequestExit();
|
2018-11-07 02:01:33 -05:00
|
|
|
|
|
|
|
private:
|
2018-11-07 04:12:27 -05:00
|
|
|
std::queue<AppletMessage> messages;
|
2018-11-27 09:18:29 -05:00
|
|
|
Kernel::EventPair on_new_message;
|
|
|
|
Kernel::EventPair on_operation_mode_changed;
|
2018-11-07 02:01:33 -05:00
|
|
|
};
|
|
|
|
|
2018-02-02 16:03:40 -05:00
|
|
|
class IWindowController final : public ServiceFramework<IWindowController> {
|
|
|
|
public:
|
2019-07-11 00:53:55 -04:00
|
|
|
explicit IWindowController(Core::System& system_);
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 21:20:52 -04:00
|
|
|
~IWindowController() override;
|
2018-02-02 16:03:40 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
void GetAppletResourceUserId(Kernel::HLERequestContext& ctx);
|
|
|
|
void AcquireForegroundRights(Kernel::HLERequestContext& ctx);
|
2019-07-11 00:53:55 -04:00
|
|
|
|
|
|
|
Core::System& system;
|
2018-02-02 16:03:40 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class IAudioController final : public ServiceFramework<IAudioController> {
|
|
|
|
public:
|
|
|
|
IAudioController();
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 21:20:52 -04:00
|
|
|
~IAudioController() override;
|
2018-02-22 09:28:15 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
void SetExpectedMasterVolume(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetMainAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetLibraryAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx);
|
2019-03-17 22:39:29 -04:00
|
|
|
void ChangeMainAppletMasterVolume(Kernel::HLERequestContext& ctx);
|
2019-03-17 21:09:25 -04:00
|
|
|
void SetTransparentAudioRate(Kernel::HLERequestContext& ctx);
|
2018-02-22 09:28:15 -05:00
|
|
|
|
2019-03-17 20:47:03 -04:00
|
|
|
static constexpr float min_allowed_volume = 0.0f;
|
|
|
|
static constexpr float max_allowed_volume = 1.0f;
|
|
|
|
|
|
|
|
float main_applet_volume{0.25f};
|
|
|
|
float library_applet_volume{max_allowed_volume};
|
2019-03-17 21:09:25 -04:00
|
|
|
float transparent_volume_rate{min_allowed_volume};
|
2019-03-17 22:39:29 -04:00
|
|
|
|
|
|
|
// Volume transition fade time in nanoseconds.
|
|
|
|
// e.g. If the main applet volume was 0% and was changed to 50%
|
|
|
|
// with a fade of 50ns, then over the course of 50ns,
|
|
|
|
// the volume will gradually fade up to 50%
|
|
|
|
std::chrono::nanoseconds fade_time_ns{0};
|
2018-02-02 16:03:40 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class IDisplayController final : public ServiceFramework<IDisplayController> {
|
|
|
|
public:
|
|
|
|
IDisplayController();
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 21:20:52 -04:00
|
|
|
~IDisplayController() override;
|
2018-02-02 16:03:40 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class IDebugFunctions final : public ServiceFramework<IDebugFunctions> {
|
|
|
|
public:
|
|
|
|
IDebugFunctions();
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 21:20:52 -04:00
|
|
|
~IDebugFunctions() override;
|
2018-02-02 16:03:40 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class ISelfController final : public ServiceFramework<ISelfController> {
|
|
|
|
public:
|
2019-07-11 00:53:55 -04:00
|
|
|
explicit ISelfController(Core::System& system_,
|
|
|
|
std::shared_ptr<NVFlinger::NVFlinger> nvflinger_);
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 21:20:52 -04:00
|
|
|
~ISelfController() override;
|
2018-02-02 16:03:40 -05:00
|
|
|
|
|
|
|
private:
|
2019-07-06 13:41:38 -04:00
|
|
|
void Exit(Kernel::HLERequestContext& ctx);
|
2018-02-02 16:03:40 -05:00
|
|
|
void LockExit(Kernel::HLERequestContext& ctx);
|
|
|
|
void UnlockExit(Kernel::HLERequestContext& ctx);
|
2019-03-26 15:12:09 -04:00
|
|
|
void EnterFatalSection(Kernel::HLERequestContext& ctx);
|
|
|
|
void LeaveFatalSection(Kernel::HLERequestContext& ctx);
|
2018-02-07 07:11:17 -05:00
|
|
|
void GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx);
|
2019-03-26 14:54:03 -04:00
|
|
|
void SetScreenShotPermission(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetOperationModeChangedNotification(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetPerformanceModeChangedNotification(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetFocusHandlingMode(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetRestartMessageEnabled(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetOutOfFocusSuspendingEnabled(Kernel::HLERequestContext& ctx);
|
2018-08-08 00:40:46 -04:00
|
|
|
void SetScreenShotImageOrientation(Kernel::HLERequestContext& ctx);
|
2018-02-02 16:03:40 -05:00
|
|
|
void CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx);
|
2018-05-07 11:27:30 -04:00
|
|
|
void SetHandlesRequestToDisplay(Kernel::HLERequestContext& ctx);
|
2018-08-17 00:23:08 -04:00
|
|
|
void SetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx);
|
2019-07-11 13:02:29 -04:00
|
|
|
void SetAutoSleepDisabled(Kernel::HLERequestContext& ctx);
|
2019-07-11 13:32:20 -04:00
|
|
|
void IsAutoSleepDisabled(Kernel::HLERequestContext& ctx);
|
2019-07-06 15:13:34 -04:00
|
|
|
void GetAccumulatedSuspendedTickValue(Kernel::HLERequestContext& ctx);
|
2019-06-16 05:06:33 -04:00
|
|
|
void GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequestContext& ctx);
|
2018-02-02 16:03:40 -05:00
|
|
|
|
2019-10-04 18:55:37 -04:00
|
|
|
Core::System& system;
|
2018-02-02 16:03:40 -05:00
|
|
|
std::shared_ptr<NVFlinger::NVFlinger> nvflinger;
|
2018-11-27 09:18:29 -05:00
|
|
|
Kernel::EventPair launchable_event;
|
2019-06-16 05:06:33 -04:00
|
|
|
Kernel::EventPair accumulated_suspended_tick_changed_event;
|
|
|
|
|
2018-08-17 00:23:08 -04:00
|
|
|
u32 idle_time_detection_extension = 0;
|
2019-03-26 15:12:09 -04:00
|
|
|
u64 num_fatal_sections_entered = 0;
|
2019-07-11 13:02:29 -04:00
|
|
|
bool is_auto_sleep_disabled = false;
|
2018-02-02 16:03:40 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class ICommonStateGetter final : public ServiceFramework<ICommonStateGetter> {
|
|
|
|
public:
|
2019-06-28 22:46:51 -04:00
|
|
|
explicit ICommonStateGetter(Core::System& system,
|
|
|
|
std::shared_ptr<AppletMessageQueue> msg_queue);
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 21:20:52 -04:00
|
|
|
~ICommonStateGetter() override;
|
2018-02-02 16:03:40 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
enum class FocusState : u8 {
|
|
|
|
InFocus = 1,
|
|
|
|
NotInFocus = 2,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class OperationMode : u8 {
|
|
|
|
Handheld = 0,
|
|
|
|
Docked = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
void GetEventHandle(Kernel::HLERequestContext& ctx);
|
|
|
|
void ReceiveMessage(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetCurrentFocusState(Kernel::HLERequestContext& ctx);
|
2018-08-16 17:20:54 -04:00
|
|
|
void GetDefaultDisplayResolutionChangeEvent(Kernel::HLERequestContext& ctx);
|
2018-02-02 16:03:40 -05:00
|
|
|
void GetOperationMode(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetPerformanceMode(Kernel::HLERequestContext& ctx);
|
2018-08-23 18:31:45 -04:00
|
|
|
void GetBootMode(Kernel::HLERequestContext& ctx);
|
2020-03-26 10:31:45 -04:00
|
|
|
void IsVrModeEnabled(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetVrModeEnabled(Kernel::HLERequestContext& ctx);
|
2020-02-27 11:49:23 -05:00
|
|
|
void SetLcdBacklighOffEnabled(Kernel::HLERequestContext& ctx);
|
2020-03-26 10:31:45 -04:00
|
|
|
void EndVrModeEx(Kernel::HLERequestContext& ctx);
|
2018-09-18 11:10:16 -04:00
|
|
|
void GetDefaultDisplayResolution(Kernel::HLERequestContext& ctx);
|
2019-06-28 22:46:51 -04:00
|
|
|
void SetCpuBoostMode(Kernel::HLERequestContext& ctx);
|
2018-02-02 16:03:40 -05:00
|
|
|
|
2019-06-28 22:46:51 -04:00
|
|
|
Core::System& system;
|
2018-11-07 02:01:33 -05:00
|
|
|
std::shared_ptr<AppletMessageQueue> msg_queue;
|
2020-04-29 07:48:58 -04:00
|
|
|
bool vr_mode_state{};
|
2018-02-02 16:03:40 -05:00
|
|
|
};
|
|
|
|
|
2020-01-26 13:18:13 -05:00
|
|
|
class IStorageImpl {
|
|
|
|
public:
|
|
|
|
virtual ~IStorageImpl();
|
|
|
|
virtual std::vector<u8>& GetData() = 0;
|
|
|
|
virtual const std::vector<u8>& GetData() const = 0;
|
|
|
|
virtual std::size_t GetSize() const = 0;
|
|
|
|
};
|
|
|
|
|
2018-11-09 20:04:07 -05:00
|
|
|
class IStorage final : public ServiceFramework<IStorage> {
|
|
|
|
public:
|
2020-01-26 13:18:13 -05:00
|
|
|
explicit IStorage(std::vector<u8>&& buffer);
|
2018-11-11 16:39:25 -05:00
|
|
|
~IStorage() override;
|
2018-11-09 20:04:07 -05:00
|
|
|
|
2020-01-26 13:18:13 -05:00
|
|
|
std::vector<u8>& GetData() {
|
|
|
|
return impl->GetData();
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::vector<u8>& GetData() const {
|
|
|
|
return impl->GetData();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::size_t GetSize() const {
|
|
|
|
return impl->GetSize();
|
|
|
|
}
|
2018-11-09 20:04:07 -05:00
|
|
|
|
|
|
|
private:
|
2020-01-26 13:18:13 -05:00
|
|
|
void Register();
|
2018-11-09 20:04:07 -05:00
|
|
|
void Open(Kernel::HLERequestContext& ctx);
|
|
|
|
|
2020-01-26 13:18:13 -05:00
|
|
|
std::shared_ptr<IStorageImpl> impl;
|
2018-11-09 20:04:07 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class IStorageAccessor final : public ServiceFramework<IStorageAccessor> {
|
|
|
|
public:
|
|
|
|
explicit IStorageAccessor(IStorage& backing);
|
2018-11-11 16:39:25 -05:00
|
|
|
~IStorageAccessor() override;
|
2018-11-09 20:04:07 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
void GetSize(Kernel::HLERequestContext& ctx);
|
|
|
|
void Write(Kernel::HLERequestContext& ctx);
|
|
|
|
void Read(Kernel::HLERequestContext& ctx);
|
2018-11-11 16:39:25 -05:00
|
|
|
|
|
|
|
IStorage& backing;
|
2018-11-09 20:04:07 -05:00
|
|
|
};
|
|
|
|
|
2018-02-02 16:03:40 -05:00
|
|
|
class ILibraryAppletCreator final : public ServiceFramework<ILibraryAppletCreator> {
|
|
|
|
public:
|
2019-07-11 00:53:55 -04:00
|
|
|
explicit ILibraryAppletCreator(Core::System& system_);
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 21:20:52 -04:00
|
|
|
~ILibraryAppletCreator() override;
|
2018-02-07 07:11:17 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
void CreateLibraryApplet(Kernel::HLERequestContext& ctx);
|
2018-06-03 14:19:24 -04:00
|
|
|
void CreateStorage(Kernel::HLERequestContext& ctx);
|
2018-11-09 20:01:20 -05:00
|
|
|
void CreateTransferMemoryStorage(Kernel::HLERequestContext& ctx);
|
2019-06-06 19:46:36 -04:00
|
|
|
|
2019-07-11 00:53:55 -04:00
|
|
|
Core::System& system;
|
2018-02-02 16:03:40 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class IApplicationFunctions final : public ServiceFramework<IApplicationFunctions> {
|
|
|
|
public:
|
2019-07-11 00:53:55 -04:00
|
|
|
explicit IApplicationFunctions(Core::System& system_);
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 21:20:52 -04:00
|
|
|
~IApplicationFunctions() override;
|
2018-02-02 16:03:40 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
void PopLaunchParameter(Kernel::HLERequestContext& ctx);
|
2018-05-07 11:27:30 -04:00
|
|
|
void CreateApplicationAndRequestToStartForQuest(Kernel::HLERequestContext& ctx);
|
2018-02-05 20:58:11 -05:00
|
|
|
void EnsureSaveData(Kernel::HLERequestContext& ctx);
|
2018-02-02 16:03:40 -05:00
|
|
|
void SetTerminateResult(Kernel::HLERequestContext& ctx);
|
2018-05-26 00:21:03 -04:00
|
|
|
void GetDisplayVersion(Kernel::HLERequestContext& ctx);
|
2018-02-02 16:03:40 -05:00
|
|
|
void GetDesiredLanguage(Kernel::HLERequestContext& ctx);
|
|
|
|
void InitializeGamePlayRecording(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetGamePlayRecordingState(Kernel::HLERequestContext& ctx);
|
|
|
|
void NotifyRunning(Kernel::HLERequestContext& ctx);
|
2018-06-05 18:44:01 -04:00
|
|
|
void GetPseudoDeviceId(Kernel::HLERequestContext& ctx);
|
2018-12-10 22:17:45 -05:00
|
|
|
void ExtendSaveData(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetSaveDataSize(Kernel::HLERequestContext& ctx);
|
2018-10-19 09:01:10 -04:00
|
|
|
void BeginBlockingHomeButtonShortAndLongPressed(Kernel::HLERequestContext& ctx);
|
|
|
|
void EndBlockingHomeButtonShortAndLongPressed(Kernel::HLERequestContext& ctx);
|
|
|
|
void BeginBlockingHomeButton(Kernel::HLERequestContext& ctx);
|
|
|
|
void EndBlockingHomeButton(Kernel::HLERequestContext& ctx);
|
2018-11-17 09:05:55 -05:00
|
|
|
void EnableApplicationCrashReport(Kernel::HLERequestContext& ctx);
|
2019-11-02 20:26:13 -04:00
|
|
|
void InitializeApplicationCopyrightFrameBuffer(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetApplicationCopyrightImage(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetApplicationCopyrightVisibility(Kernel::HLERequestContext& ctx);
|
2019-11-14 15:59:50 -05:00
|
|
|
void QueryApplicationPlayStatistics(Kernel::HLERequestContext& ctx);
|
2019-11-11 10:21:45 -05:00
|
|
|
void QueryApplicationPlayStatisticsByUid(Kernel::HLERequestContext& ctx);
|
2019-11-14 15:59:50 -05:00
|
|
|
void GetGpuErrorDetectedSystemEvent(Kernel::HLERequestContext& ctx);
|
2020-04-30 08:37:26 -04:00
|
|
|
void GetFriendInvitationStorageChannelEvent(Kernel::HLERequestContext& ctx);
|
2019-09-04 11:43:04 -04:00
|
|
|
|
2019-05-01 22:40:51 -04:00
|
|
|
bool launch_popped_application_specific = false;
|
|
|
|
bool launch_popped_account_preselect = false;
|
2019-09-04 11:43:04 -04:00
|
|
|
Kernel::EventPair gpu_error_detected_event;
|
2020-04-30 08:37:26 -04:00
|
|
|
Kernel::EventPair friend_invitation_storage_channel_event;
|
2019-07-11 00:53:55 -04:00
|
|
|
Core::System& system;
|
2018-02-02 16:03:40 -05:00
|
|
|
};
|
|
|
|
|
2018-05-07 11:27:30 -04:00
|
|
|
class IHomeMenuFunctions final : public ServiceFramework<IHomeMenuFunctions> {
|
|
|
|
public:
|
|
|
|
IHomeMenuFunctions();
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 21:20:52 -04:00
|
|
|
~IHomeMenuFunctions() override;
|
2018-05-07 11:27:30 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
void RequestToGetForeground(Kernel::HLERequestContext& ctx);
|
|
|
|
};
|
|
|
|
|
|
|
|
class IGlobalStateController final : public ServiceFramework<IGlobalStateController> {
|
|
|
|
public:
|
|
|
|
IGlobalStateController();
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 21:20:52 -04:00
|
|
|
~IGlobalStateController() override;
|
2018-05-07 11:27:30 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
class IApplicationCreator final : public ServiceFramework<IApplicationCreator> {
|
|
|
|
public:
|
|
|
|
IApplicationCreator();
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 21:20:52 -04:00
|
|
|
~IApplicationCreator() override;
|
2018-05-07 11:27:30 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
class IProcessWindingController final : public ServiceFramework<IProcessWindingController> {
|
|
|
|
public:
|
|
|
|
IProcessWindingController();
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 21:20:52 -04:00
|
|
|
~IProcessWindingController() override;
|
2018-05-07 11:27:30 -04:00
|
|
|
};
|
|
|
|
|
2017-10-14 22:50:04 -04:00
|
|
|
/// Registers all AM services with the specified service manager.
|
2018-01-22 13:46:36 -05:00
|
|
|
void InstallInterfaces(SM::ServiceManager& service_manager,
|
2019-06-06 19:46:36 -04:00
|
|
|
std::shared_ptr<NVFlinger::NVFlinger> nvflinger, Core::System& system);
|
2017-10-14 22:50:04 -04:00
|
|
|
|
2019-07-11 00:53:55 -04:00
|
|
|
} // namespace Service::AM
|