1 ////////////////////////////////////////////////////////////////////////////// 2 // Copyright 2002-2006 Andreas Huber Doenni 3 // Distributed under the Boost Software License, Version 1.0. (See accompany- 4 // ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 ////////////////////////////////////////////////////////////////////////////// 6 7 8 9 #include "Precompiled.hpp" 10 #include "Shooting.hpp" 11 #include <iostream> 12 13 #include <boost/config.hpp> 14 15 #ifdef BOOST_INTEL 16 # pragma warning( disable: 383 ) // reference to temporary used 17 #endif 18 19 20 21 ////////////////////////////////////////////////////////////////////////////// Shooting()22Shooting::Shooting() 23 { 24 std::cout << "Entering Shooting\n"; 25 } 26 ~Shooting()27Shooting::~Shooting() 28 { 29 std::cout << "Exiting Shooting\n"; 30 } 31 32 ////////////////////////////////////////////////////////////////////////////// 33 struct Storing : sc::simple_state< Storing, Shooting > 34 { StoringStoring35 Storing() 36 { 37 std::cout << "Picture taken!\n"; 38 } 39 }; 40 41 ////////////////////////////////////////////////////////////////////////////// 42 struct Focused : sc::simple_state< Focused, Shooting > 43 { 44 typedef sc::custom_reaction< EvShutterFull > reactions; 45 46 sc::result react( const EvShutterFull & ); 47 }; 48 react(const EvShutterFull &)49sc::result Focused::react( const EvShutterFull & ) 50 { 51 if ( context< Camera >().IsMemoryAvailable() ) 52 { 53 return transit< Storing >(); 54 } 55 else 56 { 57 std::cout << "Cache memory full. Please wait...\n"; 58 return discard_event(); 59 } 60 } 61 62 ////////////////////////////////////////////////////////////////////////////// Focusing(my_context ctx)63Focusing::Focusing( my_context ctx ) : my_base( ctx ) 64 { 65 post_event( boost::intrusive_ptr< EvInFocus >( new EvInFocus() ) ); 66 } 67 react(const EvInFocus & evt)68sc::result Focusing::react( const EvInFocus & evt ) 69 { 70 return transit< Focused >( &Shooting::DisplayFocused, evt ); 71 } 72