MeVisLabToolboxReference
MeVis/Foundation/Sources/OSXSupport/macLaunchServices.h
Go to the documentation of this file.
00001 // **InsertLicense** code author="Felix Ritter" version="1.0"
00002 
00006 
00007 #ifndef __macLaunchServices_H
00008 #define __macLaunchServices_H
00009 #if defined(__APPLE__)
00010 
00011 #include <ApplicationServices/ApplicationServices.h>
00012 #include <string>
00013 #include <map>
00014 #include <list>
00015 
00016 namespace macx {
00017   
00019   class LaunchServices
00020   {
00021   public:
00022 
00024     enum LSRoles {
00025       LSRoleViewer = kLSRolesViewer,
00026       LSRoleEditor = kLSRolesEditor,
00027       LSRoleShell  = kLSRolesShell,
00028       LSRoleAll    = LSRoleViewer | LSRoleEditor | LSRoleShell
00029     };
00030     
00032     enum LSLaunchFlags {
00033       LSLaunchNewInstance = kLSLaunchNewInstance
00034     };
00035     
00037     static std::string getApplicationWithName(const std::string &appName);
00038     
00040     static std::string getApplicationWithId(const std::string &id);
00041     
00043     static std::string getApplicationWithMIMEType(const std::string &MIMEType, LSRoles role = LSRoleAll);
00044     
00046     static bool registerApplication(const std::string &app, bool forceUpdate = true);
00047     
00049 
00052     static bool openDocument(const std::string &doc, LSRoles role = LSRoleAll, const std::string &app = std::string());
00054     static bool openDocument(const std::string &doc, const std::string &app) {
00055       return openDocument(doc, LSRoleAll, app);
00056     }
00057     
00059     static bool isApplicationOpen(const std::string &id);
00060     
00062 
00065     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));
00067     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)) {
00068       return openApplication(app, docs, argv, std::map<std::string,std::string>(), flags);
00069     }
00071     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)) {
00072       return openApplication(app, docs, std::list<std::string>(), environment, flags);
00073     }
00075     static bool openApplication(const std::string &app, const std::map<std::string,std::string> &environment, LSLaunchFlags flags = static_cast<LSLaunchFlags>(0)) {
00076       return openApplication(app, std::list<std::string>(), std::list<std::string>(), environment, flags);
00077     }
00079     static bool openApplication(const std::string &app, const std::list<std::string> &docs, LSLaunchFlags flags = static_cast<LSLaunchFlags>(0)) {
00080       return openApplication(app, docs, std::list<std::string>(), std::map<std::string,std::string>(), flags);
00081     }
00083     static bool openApplication(const std::string &app, LSLaunchFlags flags = static_cast<LSLaunchFlags>(0)) {
00084       return openApplication(app, std::list<std::string>(), std::list<std::string>(), std::map<std::string,std::string>(), flags);
00085     }
00086     
00087   };
00088 
00089 }
00090 
00091 #endif  // __APPLE__
00092 #endif  // __macLaunchServices_H