Ocean
UserInterface.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_INTERACTION_USER_INTERFACE_H
9 #define META_OCEAN_INTERACTION_USER_INTERFACE_H
10 
12 
13 #if defined(OCEAN_PLATFORM_BUILD_APPLE_IOS_ANY) && defined(__OBJC__)
14  #import <UIKit/UIKit.h>
15 #endif
16 
17 namespace Ocean
18 {
19 
20 namespace Interaction
21 {
22 
23 /**
24  * This class holds UI elements of the application from which the interaction is executed.
25  * @ingroup interaction
26  */
27 class OCEAN_INTERACTION_EXPORT UserInterface
28 {
29  public:
30 
31  /**
32  * Default constructor.
33  */
34  UserInterface() = default;
35 
36 #if defined(OCEAN_PLATFORM_BUILD_APPLE_IOS_ANY) && defined(__OBJC__)
37 
38  /**
39  * Creates new user interface object for iOS applications.
40  * @param window The application's window, must be valid
41  * @param viewController The application's view controller, must be valid
42  */
43  UserInterface(UIWindow* window, UIViewController* viewController);
44 
45  /**
46  * Returns the window of the application.
47  * @return The application's window; nullptr if not an iOS application
48  */
49  UIWindow* window() const;
50 
51  /**
52  * Returns the view controller of the iOS application.
53  * @return The application's view controller; nullptr if not an iOS application
54  */
55  UIViewController* viewController() const;
56 #endif
57 
58  /**
59  * Returns whether this object holds UI elements for an iOS application.
60  * @return True, if so
61  */
62  inline bool isIOS() const;
63 
64  protected:
65 
66  /// True, in case this object holds UI elements for an iOS application.
67  bool isIOS_ = false;
68 
69 #if defined(OCEAN_PLATFORM_BUILD_APPLE_IOS_ANY) && defined(__OBJC__)
70 
71  /// The application's window; nullptr if not an iOS application.
72  UIWindow* window_ = nullptr;
73 
74  /// The application's view controller; nullptr if not an iOS application.
75  UIViewController* viewController_ = nullptr;
76 
77 #endif
78 };
79 
80 inline bool UserInterface::isIOS() const
81 {
82  return isIOS_;
83 }
84 
85 }
86 
87 }
88 
89 #endif // META_OCEAN_INTERACTION_USER_INTERFACE_H
This class holds UI elements of the application from which the interaction is executed.
Definition: UserInterface.h:28
bool isIOS_
True, in case this object holds UI elements for an iOS application.
Definition: UserInterface.h:67
UIViewController * viewController() const
Returns the view controller of the iOS application.
UIWindow * window() const
Returns the window of the application.
bool isIOS() const
Returns whether this object holds UI elements for an iOS application.
Definition: UserInterface.h:80
UserInterface(UIWindow *window, UIViewController *viewController)
Creates new user interface object for iOS applications.
UserInterface()=default
Default constructor.
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15