liststatemachine.hpp

来自「j2me is based on j2mepolish, client & se」· HPP 代码 · 共 96 行

HPP
96
字号

//         Copyright E骾n O'Callaghan 2008 - 2008.
// Distributed under the Boost Software License, Version 1.0.
//    (See accompanying file LICENSE_1_0.txt or copy at
//          http://www.boost.org/LICENSE_1_0.txt)

#ifndef LISTSTATE_MACHINE_HPP_INCLUDED
#define LISTSTATE_MACHINE_HPP_INCLUDED

#include "StdAfx.hpp"

#include <boost/statechart/event.hpp>
#include <boost/statechart/transition.hpp>
#include <boost/statechart/state_machine.hpp>
#include <boost/statechart/simple_state.hpp>

#include "SvcListView.hpp"

namespace sc = boost::statechart;

struct i_is_overview_mode
{
	virtual bool is_overview_mode() const = 0;
};

bool inline list_state_machine::is_overview_mode() const
{
	try
	{
	return state_cast<const i_is_overview_mode*>()->is_overview_mode();
	}
	catch (const std::exception& e)
	{	
		aux::wlog() << boost::wformat(L"is_overview_mode() std::exception: %1%") 
			% aux::from_utf8_safe(e.what());
		return false;
	}	
}

struct profile_mode;

struct overview_mode : 
	sc::state<overview_mode, list_state_machine>,
	public i_is_overview_mode
{
	typedef sc::transition<ev_switch_to_profile, profile_mode> reactions;
	
	overview_mode(my_context ctx) : my_base(ctx)
	{
		try
		{
		logger.post(new event_type(event_logger::debug, 
			wformat(L"overview_mode().")));

		if (context<list_state_machine>().list()->is_empty())
			context<list_state_machine>().list()->display_all_services();
		else
			context<list_state_machine>().list()->reset_display_services();

		context<list_state_machine>().list()->InvalidateRect(NULL, true);

		}
		catch (const std::exception& e)
		{	
			aux::wlog() << boost::wformat(L"overview_mode std::exception: %1%") 
				% aux::from_utf8_safe(e.what());
		}	
	}

	virtual bool is_overview_mode() const { return true; }
};

struct profile_mode : 
	sc::state<profile_mode, list_state_machine>,
	public i_is_overview_mode
{
	typedef sc::transition<ev_switch_to_overview, overview_mode> reactions;

	profile_mode(my_context ctx) : my_base(ctx)
	{
		try
		{
		context<list_state_machine>().list()->InvalidateRect(NULL, true);
		}
		catch (const std::exception& e)
		{	
			aux::wlog() << boost::wformat(L"profile_mode std::exception: %1%") 
				% aux::from_utf8_safe(e.what());
		}			
	}

	virtual bool is_overview_mode() const { return false; }
};

#endif // LISTSTATE_MACHINE_HPP_INCLUDED

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?