Shooting.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #include "Precompiled.hpp"
  7. #include "Shooting.hpp"
  8. #include <iostream>
  9. #include <boost/config.hpp>
  10. #ifdef BOOST_INTEL
  11. # pragma warning( disable: 383 ) // reference to temporary used
  12. #endif
  13. //////////////////////////////////////////////////////////////////////////////
  14. Shooting::Shooting()
  15. {
  16. std::cout << "Entering Shooting\n";
  17. }
  18. Shooting::~Shooting()
  19. {
  20. std::cout << "Exiting Shooting\n";
  21. }
  22. //////////////////////////////////////////////////////////////////////////////
  23. struct Storing : sc::simple_state< Storing, Shooting >
  24. {
  25. Storing()
  26. {
  27. std::cout << "Picture taken!\n";
  28. }
  29. };
  30. //////////////////////////////////////////////////////////////////////////////
  31. struct Focused : sc::simple_state< Focused, Shooting >
  32. {
  33. typedef sc::custom_reaction< EvShutterFull > reactions;
  34. sc::result react( const EvShutterFull & );
  35. };
  36. sc::result Focused::react( const EvShutterFull & )
  37. {
  38. if ( context< Camera >().IsMemoryAvailable() )
  39. {
  40. return transit< Storing >();
  41. }
  42. else
  43. {
  44. std::cout << "Cache memory full. Please wait...\n";
  45. return discard_event();
  46. }
  47. }
  48. //////////////////////////////////////////////////////////////////////////////
  49. Focusing::Focusing( my_context ctx ) : my_base( ctx )
  50. {
  51. post_event( boost::intrusive_ptr< EvInFocus >( new EvInFocus() ) );
  52. }
  53. sc::result Focusing::react( const EvInFocus & evt )
  54. {
  55. return transit< Focused >( &Shooting::DisplayFocused, evt );
  56. }