2015-05-06 00:50:57 +00:00
|
|
|
#ifndef IRUNLOOP_HPP
|
|
|
|
#define IRUNLOOP_HPP
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "windowsys/IWindow.hpp"
|
|
|
|
#include "inputdev/CDeviceFinder.hpp"
|
|
|
|
|
|
|
|
namespace boo
|
|
|
|
{
|
|
|
|
class IApplication;
|
|
|
|
|
|
|
|
struct IApplicationCallback
|
|
|
|
{
|
|
|
|
virtual void appLaunched(IApplication* app) {(void)app;}
|
|
|
|
virtual void appQuitting(IApplication* app) {(void)app;}
|
2015-05-13 22:21:13 +00:00
|
|
|
virtual void appFilesOpen(IApplication* app, const std::vector<const std::string>& paths) {(void)app;(void)paths;}
|
2015-05-06 00:50:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class IApplication
|
|
|
|
{
|
|
|
|
friend class CWindowCocoa;
|
|
|
|
friend class CWindowWayland;
|
|
|
|
friend class CWindowXCB;
|
|
|
|
friend class CWindowWin32;
|
|
|
|
virtual void _deletedWindow(IWindow* window)=0;
|
|
|
|
public:
|
|
|
|
virtual ~IApplication() {}
|
|
|
|
|
|
|
|
enum EPlatformType
|
|
|
|
{
|
|
|
|
PLAT_AUTO = 0,
|
|
|
|
PLAT_WAYLAND = 1,
|
|
|
|
PLAT_XCB = 2,
|
|
|
|
PLAT_ANDROID = 3,
|
|
|
|
PLAT_COCOA = 4,
|
|
|
|
PLAT_COCOA_TOUCH = 5,
|
|
|
|
PLAT_WIN32 = 6,
|
|
|
|
PLAT_WINRT = 7,
|
|
|
|
PLAT_REVOLUTION = 8,
|
|
|
|
PLAT_CAFE = 9
|
|
|
|
};
|
|
|
|
virtual EPlatformType getPlatformType() const=0;
|
|
|
|
|
|
|
|
virtual void run()=0;
|
|
|
|
virtual void quit()=0;
|
2015-05-13 22:21:13 +00:00
|
|
|
virtual const std::string& getUniqueName() const=0;
|
|
|
|
virtual const std::string& getFriendlyName() const=0;
|
2015-05-06 00:50:57 +00:00
|
|
|
virtual const std::string& getProcessName() const=0;
|
|
|
|
virtual const std::vector<std::string>& getArgs() const=0;
|
|
|
|
|
|
|
|
/* Constructors/initializers for sub-objects */
|
|
|
|
virtual IWindow* newWindow(const std::string& title)=0;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
IApplication* IApplicationBootstrap(IApplication::EPlatformType platform,
|
|
|
|
IApplicationCallback& cb,
|
2015-05-13 22:21:13 +00:00
|
|
|
const std::string& uniqueName,
|
2015-05-06 00:50:57 +00:00
|
|
|
const std::string& friendlyName,
|
|
|
|
const std::string& pname,
|
2015-05-13 22:21:13 +00:00
|
|
|
const std::vector<std::string>& args,
|
|
|
|
bool singleInstance=true);
|
2015-05-06 00:50:57 +00:00
|
|
|
extern IApplication* APP;
|
|
|
|
#define IApplicationInstance() APP
|
|
|
|
|
|
|
|
static inline IApplication* IApplicationBootstrap(IApplication::EPlatformType platform,
|
|
|
|
IApplicationCallback& cb,
|
2015-05-13 22:21:13 +00:00
|
|
|
const std::string& uniqueName,
|
2015-05-06 00:50:57 +00:00
|
|
|
const std::string& friendlyName,
|
2015-05-13 22:21:13 +00:00
|
|
|
int argc, char** argv,
|
|
|
|
bool singleInstance=true)
|
2015-05-06 00:50:57 +00:00
|
|
|
{
|
|
|
|
if (APP)
|
|
|
|
return APP;
|
|
|
|
std::vector<std::string> args;
|
|
|
|
for (int i=1 ; i<argc ; ++i)
|
|
|
|
args.push_back(argv[i]);
|
2015-05-13 22:21:13 +00:00
|
|
|
return IApplicationBootstrap(platform, cb, uniqueName, friendlyName, argv[0], args, singleInstance);
|
2015-05-06 00:50:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // IRUNLOOP_HPP
|