Ocean
meta/quest/platformsdk/Application.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_PLATFORM_META_QUEST_PLATFORMSDK_APPLICATION_H
9 #define META_OCEAN_PLATFORM_META_QUEST_PLATFORMSDK_APPLICATION_H
10 
13 
14 #include "ocean/base/Singleton.h"
15 #include "ocean/base/Timestamp.h"
16 
17 #include <OVR_Platform.h>
18 
19 namespace Ocean
20 {
21 
22 namespace Platform
23 {
24 
25 namespace Meta
26 {
27 
28 namespace Quest
29 {
30 
31 namespace PlatformSDK
32 {
33 
34 /**
35  * This class implements application functionalities based on the PlatformSDK.
36  * @ingroup platformmetaquestplatformsdk
37  */
38 class OCEAN_PLATFORM_META_QUEST_PLATFORMSDK_EXPORT Application :
39  public Singleton<Application>,
40  protected MessageHandler
41 {
42  friend class Singleton<Application>;
43  friend class Manager;
44 
45  public:
46 
47  /**
48  * Ensures that the mulit-player functionalities are initialized.
49  */
51 
52  /**
53  * Returns whether the app has been launched with a deep link.
54  * The manager needs to be initialized before calling this function.
55  * @param launchDeepLink The resulting deepLink which has been used to launch the app
56  * @param sessionId Optional resulting session id which has been defined when launching the app
57  * @return True, if so; False, if the if the app was launched normally
58  * @see isInitialized(), hasChangedLaunchDeepLink().
59  */
60  bool hasLaunchDeepLink(std::string& launchDeepLink, std::string* sessionId = nullptr) const;
61 
62  /**
63  * Returns whether the app has received a new launch deep link while the app was already running.
64  * @param changedDeepLink The resulting deepLink which has been changed
65  * @param sessionId Optional resulting session id which has been changed
66  * @return True, if so
67  */
68  bool hasChangedLaunchDeepLink(std::string& changedDeepLink, std::string* sessionId = nullptr);
69 
70  /**
71  * Launches another application in the user's library.
72  * @param appId The id of the application to launch, must be valid
73  * @param deepLink Optional deep link to use when launching the app
74  * @return The future containing the success state, invalid in case of a failure
75  */
76  std::future<bool> launchAnotherApplication(const uint64_t appId, const std::string& deepLink = std::string());
77 
78  protected:
79 
80  /**
81  * Creates a new object.
82  */
84 
85  /**
86  * Checks whether the application has a launch deep link.
87  */
89 
90  /**
91  * The event function for ovrMessage_Notification_ApplicationLifecycle_LaunchIntentChanged notifications.
92  * @param message The notification message, must be valid
93  * @param succeeded True, if the request succeeded
94  */
95  void onLaunchIntentChangedNotification(ovrMessage* message, const bool succeeded);
96 
97  /**
98  * The response function for launchAnotherApplication().
99  * @param message The response message, must be valid
100  * @param succeeded True, if the request succeeded
101  */
102  void onLaunchedAnotherApplication(ovrMessage* message, const bool succeeded);
103 
104  protected:
105 
106  /// The subscription objects for all messages.
108 
109  /// The deep link which has been used to launch the app, empty if the app was launched normally.
110  std::string launchDeepLink_;
111 
112  /// The session id which has been defined when launching the app, empty if no session is was provided.
113  std::string launchSessionId_;
114 
115  /// The timestamp when the launch deep link was assigned the last time.
116  Timestamp launchDeepLinkTimestamp_ = Timestamp(false);
117 
118  /// The deep link which has arrived while the app was already running, empty otherwise.
120 
121  /// The session id which has arrived while the app was already running, empty otherwise.
123 
124  /// The result queue for launchAnotherApplication().
126 
127  /// The application class' lock.
128  mutable Lock lock_;
129 };
130 
131 }
132 
133 }
134 
135 }
136 
137 }
138 
139 }
140 
141 #endif // META_OCEAN_PLATFORM_META_QUEST_PLATFORMSDK_APPLICATION_H
This class implements a recursive lock object.
Definition: Lock.h:31
This class implements application functionalities based on the PlatformSDK.
Definition: meta/quest/platformsdk/Application.h:41
bool hasChangedLaunchDeepLink(std::string &changedDeepLink, std::string *sessionId=nullptr)
Returns whether the app has received a new launch deep link while the app was already running.
std::string changedLaunchSessionId_
The session id which has arrived while the app was already running, empty otherwise.
Definition: meta/quest/platformsdk/Application.h:122
std::string changedLaunchDeepLink_
The deep link which has arrived while the app was already running, empty otherwise.
Definition: meta/quest/platformsdk/Application.h:119
RequestQueue< bool > launchAnotherApplicationRequestQueue_
The result queue for launchAnotherApplication().
Definition: meta/quest/platformsdk/Application.h:125
std::string launchSessionId_
The session id which has been defined when launching the app, empty if no session is was provided.
Definition: meta/quest/platformsdk/Application.h:113
void checkLaunchDeepLink()
Checks whether the application has a launch deep link.
bool hasLaunchDeepLink(std::string &launchDeepLink, std::string *sessionId=nullptr) const
Returns whether the app has been launched with a deep link.
MessageScopedSubscriptions messageScopedSubscriptions_
The subscription objects for all messages.
Definition: meta/quest/platformsdk/Application.h:107
std::string launchDeepLink_
The deep link which has been used to launch the app, empty if the app was launched normally.
Definition: meta/quest/platformsdk/Application.h:110
void ensureInitialization()
Ensures that the mulit-player functionalities are initialized.
void onLaunchIntentChangedNotification(ovrMessage *message, const bool succeeded)
The event function for ovrMessage_Notification_ApplicationLifecycle_LaunchIntentChanged notifications...
std::future< bool > launchAnotherApplication(const uint64_t appId, const std::string &deepLink=std::string())
Launches another application in the user's library.
void onLaunchedAnotherApplication(ovrMessage *message, const bool succeeded)
The response function for launchAnotherApplication().
Lock lock_
The application class' lock.
Definition: meta/quest/platformsdk/Application.h:128
This class implements a manager that handles the central PlatformSDK functionalities.
Definition: platform/meta/quest/platformsdk/Manager.h:41
This class implements a helper object allowing to queue responses of requests.
Definition: MessageHandler.h:162
This class is the base class for all objects needing to handle with messages.
Definition: MessageHandler.h:40
std::vector< MessageScopedSubscription > MessageScopedSubscriptions
Definition of a vector holding MessageScopedSubscription objects.
Definition: MessageHandler.h:220
This template class is the base class for all singleton objects.
Definition: Singleton.h:71
This class implements a timestamp.
Definition: Timestamp.h:36
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15