switched to unique_ptr due to expected app main use

This commit is contained in:
Jack Andersen 2015-08-18 12:50:52 -10:00
parent 87ab129e01
commit 2c2991d44e
3 changed files with 15 additions and 16 deletions

View File

@ -56,7 +56,7 @@ public:
}; };
std::shared_ptr<IApplication> std::unique_ptr<IApplication>
ApplicationBootstrap(IApplication::EPlatformType platform, ApplicationBootstrap(IApplication::EPlatformType platform,
IApplicationCallback& cb, IApplicationCallback& cb,
const std::string& uniqueName, const std::string& uniqueName,
@ -66,7 +66,7 @@ ApplicationBootstrap(IApplication::EPlatformType platform,
bool singleInstance=true); bool singleInstance=true);
extern IApplication* APP; extern IApplication* APP;
static inline std::shared_ptr<IApplication> static inline std::unique_ptr<IApplication>
ApplicationBootstrap(IApplication::EPlatformType platform, ApplicationBootstrap(IApplication::EPlatformType platform,
IApplicationCallback& cb, IApplicationCallback& cb,
const std::string& uniqueName, const std::string& uniqueName,
@ -75,7 +75,7 @@ ApplicationBootstrap(IApplication::EPlatformType platform,
bool singleInstance=true) bool singleInstance=true)
{ {
if (APP) if (APP)
return std::shared_ptr<IApplication>(APP); return std::unique_ptr<IApplication>();
std::vector<std::string> args; std::vector<std::string> args;
for (int i=1 ; i<argc ; ++i) for (int i=1 ; i<argc ; ++i)
args.push_back(argv[i]); args.push_back(argv[i]);

View File

@ -48,7 +48,7 @@ namespace boo
{ {
IApplication* APP = NULL; IApplication* APP = NULL;
std::shared_ptr<IApplication> ApplicationBootstrap(IApplication::EPlatformType platform, std::unique_ptr<IApplication> ApplicationBootstrap(IApplication::EPlatformType platform,
IApplicationCallback& cb, IApplicationCallback& cb,
const std::string& uniqueName, const std::string& uniqueName,
const std::string& friendlyName, const std::string& friendlyName,
@ -56,17 +56,16 @@ std::shared_ptr<IApplication> ApplicationBootstrap(IApplication::EPlatformType p
const std::vector<std::string>& args, const std::vector<std::string>& args,
bool singleInstance) bool singleInstance)
{ {
if (!APP) if (APP)
{ return std::unique_ptr<IApplication>();
if (platform == IApplication::PLAT_WAYLAND) if (platform == IApplication::PLAT_WAYLAND)
APP = new ApplicationWayland(cb, uniqueName, friendlyName, pname, args, singleInstance); APP = new ApplicationWayland(cb, uniqueName, friendlyName, pname, args, singleInstance);
else if (platform == IApplication::PLAT_XCB || else if (platform == IApplication::PLAT_XCB ||
platform == IApplication::PLAT_AUTO) platform == IApplication::PLAT_AUTO)
APP = new ApplicationXCB(cb, uniqueName, friendlyName, pname, args, singleInstance); APP = new ApplicationXCB(cb, uniqueName, friendlyName, pname, args, singleInstance);
else else
return std::shared_ptr<IApplication>(); return std::unique_ptr<IApplication>();
} return std::unique_ptr<IApplication>(APP);
return std::shared_ptr<IApplication>(APP);
} }
} }

View File

@ -137,7 +137,7 @@ struct TestApplicationCallback : IApplicationCallback
int main(int argc, const char** argv) int main(int argc, const char** argv)
{ {
boo::TestApplicationCallback appCb; boo::TestApplicationCallback appCb;
std::shared_ptr<boo::IApplication> app = std::unique_ptr<boo::IApplication> app =
ApplicationBootstrap(boo::IApplication::PLAT_AUTO, ApplicationBootstrap(boo::IApplication::PLAT_AUTO,
appCb, "rwk", "RWK", argc, argv); appCb, "rwk", "RWK", argc, argv);
app->run(); app->run();