Ocean
platform/apple/System.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_APPLE_SYSTEM_H
9 #define META_OCEAN_PLATFORM_APPLE_SYSTEM_H
10 
12 
13 namespace Ocean
14 {
15 
16 namespace Platform
17 {
18 
19 namespace Apple
20 {
21 
22 /**
23  * This class implements system functions on Apple platforms.
24  * @ingroup platformapple
25  */
26 class System
27 {
28  public:
29 
30  /**
31  * Returns a defined environment variable.
32  * @param variable Environment variable to return, must be valid
33  * @param removeQuotes Determines whether all beginning and ending quotes are removed from the environment variable, if existent
34  * @return Specified environment variable
35  */
36  static std::string environmentVariable(const std::string& variable, const bool removeQuotes = true);
37 
38  /**
39  * Sets an environment variable.
40  * @param variable Environment variable to set, must be valid
41  * @param value The new value of the specified variable, an empty value remove the environment variable
42  * @return True, if succeeded
43  */
44  static bool setEnvironmentVariable(const std::string& variable, const std::string& value);
45 
46  /**
47  * Returns the current Apple-platform version.
48  * @param major Optional resulting major version number
49  * @param minor Optional resulting minor version number
50  * @return The Apple-platform version determined by major + minor / 100
51  */
52  static double version(unsigned int* major = nullptr, unsigned int* minor = nullptr);
53 
54  /**
55  * Returns whether the current Apple-platform version is equal or larger than a specified (minimal required version number).
56  * @param minimalMajor The minimal major version number the current Apple-platform must have, with range [10, infinity)
57  * @param minimalMinor THe minimal minor version number the current Apple-platform must have, with range [0, infinity)
58  * @return True, if succeeded
59  */
60  static bool isMinimalVersion(const unsigned int minimalMajor, const unsigned int minimalMinor);
61 
62  /**
63  * Returns the path of the home directory of the calling process.
64  * The home directory can be the application's sandbox directory or the current user's home directory (depending on the application and platform).
65  * @return The path of the home directory
66  */
67  static std::string homeDirectory();
68 
69  /**
70  * Explicitly runs the main loop for a specified time interval.
71  * This function can be used to force event handling which is done in the main loop e.g., in a console application in macOS.
72  * @param interval The time interval the main loop will be executed, in seconds, with range (0, infinity)
73  */
74  static void runMainLoop(const double interval);
75 
76  /**
77  * Returns whether the process ia a bundle-based app or a command line app.
78  * @return True, if the app is a bundle-based app
79  */
80  static bool isBundleApp();
81 };
82 
83 }
84 
85 }
86 
87 }
88 
89 #endif // META_OCEAN_PLATFORM_APPLE_SYSTEM_H
This class implements system functions on Apple platforms.
Definition: platform/apple/System.h:27
static bool setEnvironmentVariable(const std::string &variable, const std::string &value)
Sets an environment variable.
static std::string homeDirectory()
Returns the path of the home directory of the calling process.
static std::string environmentVariable(const std::string &variable, const bool removeQuotes=true)
Returns a defined environment variable.
static bool isBundleApp()
Returns whether the process ia a bundle-based app or a command line app.
static double version(unsigned int *major=nullptr, unsigned int *minor=nullptr)
Returns the current Apple-platform version.
static bool isMinimalVersion(const unsigned int minimalMajor, const unsigned int minimalMinor)
Returns whether the current Apple-platform version is equal or larger than a specified (minimal requi...
static void runMainLoop(const double interval)
Explicitly runs the main loop for a specified time interval.
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15