]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/statechart/example/Camera/Main.cpp
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 //////////////////////////////////////////////////////////////////////////////
9 //////////////////////////////////////////////////////////////////////////////
10 // This program shows how a state machine can be spread over several
11 // translation units if necessary. The inner workings of a digital camera are
12 // modeled, the corresponding state chart looks as follows:
14 // ---------------------------
18 // | ------------- |<---O
19 // | O--->| Idle | | --------------
20 // | ------------- | EvShutterHalf | |
21 // | | ^ |------------------>| Shooting |
22 // | EvConfig | | EvConfig | | |
23 // | v | | EvShutterRelease | |
24 // | ------------- |<------------------| |
25 // | | Configuring | | | |
26 // | ------------- | --------------
27 // ---------------------------
29 // The states Configuring and Shooting will contain a large amount of logic,
30 // so they are implemented in their own translation units. This way one team
31 // could implement the Configuring mode while the other would work on the
32 // Shooting mode. Once the above state chart is implemented, the teams could
33 // work completely independently of each other.
37 #include "Precompiled.hpp"
43 //////////////////////////////////////////////////////////////////////////////
52 //////////////////////////////////////////////////////////////////////////////
55 std::cout
<< "Boost.Statechart Camera example\n\n";
57 std::cout
<< "h<CR>: Press shutter half-way\n";
58 std::cout
<< "f<CR>: Press shutter fully\n";
59 std::cout
<< "r<CR>: Release shutter\n";
60 std::cout
<< "c<CR>: Enter/exit configuration\n";
61 std::cout
<< "e<CR>: Exits the program\n\n";
62 std::cout
<< "You may chain commands, e.g. hfr<CR> first presses the shutter half-way,\n";
63 std::cout
<< "fully and then releases it.\n\n";
77 myCamera
.process_event( EvShutterHalf() );
83 myCamera
.process_event( EvShutterFull() );
89 myCamera
.process_event( EvShutterRelease() );
95 myCamera
.process_event( EvConfig() );
101 std::cout
<< "Invalid key!\n";