MIRA
StateMachineListenerWrap.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) by
3  * MetraLabs GmbH (MLAB), GERMANY
4  * and
5  * Neuroinformatics and Cognitive Robotics Labs (NICR) at TU Ilmenau, GERMANY
6  * All rights reserved.
7  *
8  * Redistribution and modification of this code is strictly prohibited.
9  *
10  * IN NO EVENT SHALL "MLAB" OR "NICR" BE LIABLE TO ANY PARTY FOR DIRECT,
11  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
12  * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF "MLAB" OR
13  * "NICR" HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14  *
15  * "MLAB" AND "NICR" SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
16  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
18  * ON AN "AS IS" BASIS, AND "MLAB" AND "NICR" HAVE NO OBLIGATION TO
19  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS.
20  */
21 
30 #ifndef _MIRA_STATEMACHINELISTENERWRAP_H_
31 #define _MIRA_STATEMACHINELISTENERWRAP_H_
32 
34 
35 
36 namespace mira { namespace sm {
37 
39 
40 struct StateMachineListenerWrap : StateMachineListener, boost::python::wrapper<StateMachineListener>
41 {
43 
45  python::ScopedGILLock lock; // lock the python GIL
46  get_override("onEntry")(target);
47  }
48 
49  void onExit(TransitionTargetPtr target) {
50  python::ScopedGILLock lock; // lock the python GIL
51  get_override("onExit")(target);
52  }
53 
55  python::ScopedGILLock lock; // lock the python GIL
56  get_override("onTransition")(from, to, transition);
57  }
58 
59  void onEvent(Event event) {
60  python::ScopedGILLock lock; // lock the python GIL
61  get_override("onEvent")(event);
62  }
63 };
64 
66 
67 }} // namespace
68 
69 #endif
Definition: StateMachineListener.h:41
boost::shared_ptr< TransitionTarget > TransitionTargetPtr
Definition: TransitionTarget.h:54
virtual ~StateMachineListenerWrap()
Definition: StateMachineListenerWrap.h:42
void onEvent(Event event)
Definition: StateMachineListenerWrap.h:59
void onEntry(TransitionTargetPtr target)
Definition: StateMachineListenerWrap.h:44
void onTransition(TransitionTargetPtr from, TransitionTargetPtr to, TransitionPtr transition)
Definition: StateMachineListenerWrap.h:54
Definition: StateMachineListenerWrap.h:40
void onExit(TransitionTargetPtr target)
Definition: StateMachineListenerWrap.h:49
Definition: Event.h:49
boost::shared_ptr< Transition > TransitionPtr
Definition: TransitionTarget.h:57
TODO Add description.