mirror of
https://github.com/boostorg/statechart.git
synced 2026-01-24 18:32:22 +00:00
66 lines
1.4 KiB
C++
66 lines
1.4 KiB
C++
//////////////////////////////////////////////////////////////////////////////
|
|
// Copyright (c) 2002-2003 Andreas Huber Doenni, Switzerland
|
|
// Permission to copy, use, modify, sell and distribute this software
|
|
// is granted provided this copyright notice appears in all copies.
|
|
// This software is provided "as is" without express or implied
|
|
// warranty, and with no claim as to its suitability for any purpose.
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "Precompiled.hpp"
|
|
#include "Shooting.hpp"
|
|
#include <iostream>
|
|
|
|
|
|
|
|
Shooting::Shooting()
|
|
{
|
|
std::cout << "Entering Shooting\n";
|
|
}
|
|
|
|
Shooting::~Shooting()
|
|
{
|
|
std::cout << "Exiting Shooting\n";
|
|
}
|
|
|
|
|
|
struct Storing : fsm::simple_state< Storing, Shooting >
|
|
{
|
|
Storing()
|
|
{
|
|
std::cout << "Picture taken!\n";
|
|
}
|
|
};
|
|
|
|
|
|
struct Focused : fsm::simple_state< Focused, Shooting,
|
|
fsm::custom_reaction< EvShutterFull > >
|
|
{
|
|
fsm::result react( const EvShutterFull & );
|
|
};
|
|
|
|
fsm::result Focused::react( const EvShutterFull & )
|
|
{
|
|
if ( context< Camera >().IsMemoryAvailable() )
|
|
{
|
|
return transit< Storing >();
|
|
}
|
|
else
|
|
{
|
|
std::cout << "Cache memory full. Please wait...\n";
|
|
return discard_event();
|
|
}
|
|
}
|
|
|
|
|
|
Focusing::Focusing( my_context ctx ) : my_base( ctx )
|
|
{
|
|
post_event( boost::intrusive_ptr< EvInFocus >( new EvInFocus() ) );
|
|
}
|
|
|
|
fsm::result Focusing::react( const EvInFocus & evt )
|
|
{
|
|
return transit< Focused >( &Shooting::DisplayFocused, evt );
|
|
}
|