Sha256: 438fd704d9e6da5fb4367285bec5e22fcd860795cec38e230555a5fb1d8d502d

Contents?: true

Size: 1.65 KB

Versions: 3

Compression:

Stored size: 1.65 KB

Contents

// -*- objc -*-
#include "reflex/application.h"


#include <assert.h>
#include "reflex/exception.h"
#include "application_data.h"
#import "app_delegate.h"


extern "C" {
	char*** _NSGetArgv ();
	int*    _NSGetArgc ();
}


namespace Reflex
{


	bool initialized ();


	static Application* instance = NULL;


	Application*
	app ()
	{
		return instance;
	}


	Application::Application ()
	{
		if (!initialized())
			reflex_error(__FILE__, __LINE__, "not initialized.");

		if (instance)
			reflex_error(__FILE__, __LINE__, "multiple application instances.");

		instance = this;
	}

	Application::~Application ()
	{
		instance = NULL;
	}

	void
	Application::start ()
	{
		UIApplicationMain(
			*_NSGetArgc(), *_NSGetArgv(), nil, NSStringFromClass(AppDelegate.class));
	}

	void
	Application::quit ()
	{
		if (!*this)
			invalid_state_error(__FILE__, __LINE__);

		not_implemented_error(__FILE__, __LINE__);
	}

	void
	Application::set_name (const char* name)
	{
		if (!name)
			argument_error(__FILE__, __LINE__);

		self->name = name;
	}

	const char*
	Application::name () const
	{
		return self->name.c_str();
	}

	void
	Application::on_start (Event* e)
	{
		if (!*this)
			invalid_state_error(__FILE__, __LINE__);
	}

	void
	Application::on_quit (Event* e)
	{
		if (!*this)
			invalid_state_error(__FILE__, __LINE__);
	}

	void
	Application::on_preference (Event* e)
	{
		if (!*this)
			invalid_state_error(__FILE__, __LINE__);
	}

	void
	Application::on_about (Event* e)
	{
		if (!*this)
			invalid_state_error(__FILE__, __LINE__);
	}

	Application::operator bool () const
	{
		return self && *self;
	}

	bool
	Application::operator ! () const
	{
		return !operator bool();
	}


}// Reflex

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
reflexion-0.1.12 src/ios/application.mm
reflexion-0.1.11 src/ios/application.mm
reflexion-0.1.10 src/ios/application.mm