MeVisLab Toolbox Reference
macLaunchServices.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef MAC_LAUNCH_SERVICES_H
14 #define MAC_LAUNCH_SERVICES_H
15 
17 
18 #if defined(__APPLE__)
19 
21 #include <ApplicationServices/ApplicationServices.h>
22 #include <string>
23 #include <map>
24 #include <list>
25 
26 namespace macos {
27 
30  {
31  public:
32 
34  enum LSRoles {
35  LSRoleViewer = kLSRolesViewer,
36  LSRoleEditor = kLSRolesEditor,
37  LSRoleShell = kLSRolesShell,
38  LSRoleAll = LSRoleViewer | LSRoleEditor | LSRoleShell
39  };
40 
43  LSLaunchNewInstance = 1 << 0
44  };
45 
47  static std::string getApplicationWithName(const std::string &appName);
48 
50  static std::string getApplicationWithId(const std::string &id);
51 
53  static bool registerApplication(const std::string &app, bool forceUpdate = true);
54 
56 
59  static bool openDocument(const std::string &doc, LSRoles role = LSRoleAll, const std::string &app = std::string());
61  static bool openDocument(const std::string &doc, const std::string &app) {
62  return openDocument(doc, LSRoleAll, app);
63  }
64 
66  static bool isApplicationOpen(const std::string &id);
67 
69 
72  static bool openApplication(const std::string &app, const std::list<std::string> &docs, const std::list<std::string> &argv, const std::map<std::string,std::string> &environment, LSLaunchFlags flags = static_cast<LSLaunchFlags>(0));
74  static bool openApplication(const std::string &app, const std::list<std::string> &docs, const std::list<std::string> &argv, LSLaunchFlags flags = static_cast<LSLaunchFlags>(0)) {
75  return openApplication(app, docs, argv, {}, flags);
76  }
78  static bool openApplication(const std::string &app, const std::list<std::string> &docs, const std::map<std::string,std::string> &environment, LSLaunchFlags flags = static_cast<LSLaunchFlags>(0)) {
79  return openApplication(app, docs, {}, environment, flags);
80  }
82  static bool openApplication(const std::string &app, const std::map<std::string,std::string> &environment, LSLaunchFlags flags = static_cast<LSLaunchFlags>(0)) {
83  return openApplication(app, {}, {}, environment, flags);
84  }
86  static bool openApplication(const std::string &app, const std::list<std::string> &docs, LSLaunchFlags flags = static_cast<LSLaunchFlags>(0)) {
87  return openApplication(app, docs, {}, {}, flags);
88  }
90  static bool openApplication(const std::string &app, const std::string &doc, LSLaunchFlags flags = static_cast<LSLaunchFlags>(0));
92  static bool openApplication(const std::string &app, LSLaunchFlags flags = static_cast<LSLaunchFlags>(0)) {
93  return openApplication(app, {}, {}, {}, flags);
94  }
95 
96  };
97 
98 }
99 
100 #endif // __APPLE__
101 #endif // __macLaunchServices_H
Finder / Launch services encapsulation.
static bool isApplicationOpen(const std::string &id)
Return 'true' if application is already open (UTF8)
static bool openApplication(const std::string &app, const std::list< std::string > &docs, const std::list< std::string > &argv, LSLaunchFlags flags=static_cast< LSLaunchFlags >(0))
This is an overloaded member function, provided for convenience.
static bool openApplication(const std::string &app, const std::string &doc, LSLaunchFlags flags=static_cast< LSLaunchFlags >(0))
This is an overloaded member function, provided for convenience.
static bool openApplication(const std::string &app, LSLaunchFlags flags=static_cast< LSLaunchFlags >(0))
This is an overloaded member function, provided for convenience.
LSLaunchFlags
Specify how to launch the application.
static bool openApplication(const std::string &app, const std::map< std::string, std::string > &environment, LSLaunchFlags flags=static_cast< LSLaunchFlags >(0))
This is an overloaded member function, provided for convenience.
static bool openApplication(const std::string &app, const std::list< std::string > &docs, LSLaunchFlags flags=static_cast< LSLaunchFlags >(0))
This is an overloaded member function, provided for convenience.
static std::string getApplicationWithName(const std::string &appName)
Return bundle location for bundle with given name, e.g. "iCal.app" (UTF8)
static bool openDocument(const std::string &doc, const std::string &app)
This is an overloaded member function, provided for convenience.
LSRoles
Specify the desired role or roles for an application to claim with respect to an item.
static std::string getApplicationWithId(const std::string &id)
Return bundle location for bundle with given id, e.g. "de.mevis.MeVisLab" (UTF8)
static bool registerApplication(const std::string &app, bool forceUpdate=true)
Add the bundle's document and URL claims to the Launch Services database (UTF8)
static bool openApplication(const std::string &app, const std::list< std::string > &docs, const std::map< std::string, std::string > &environment, LSLaunchFlags flags=static_cast< LSLaunchFlags >(0))
This is an overloaded member function, provided for convenience.
static bool openApplication(const std::string &app, const std::list< std::string > &docs, const std::list< std::string > &argv, const std::map< std::string, std::string > &environment, LSLaunchFlags flags=static_cast< LSLaunchFlags >(0))
Launches the specified application (UTF8)
static bool openDocument(const std::string &doc, LSRoles role=LSRoleAll, const std::string &app=std::string())
Open given document in given application (or the default application) using the given role (UTF8)
#define OSXSUPPORT_PUBLIC_API
Symbol visibility macros.
AppleScript support.