UniMRCP  1.3.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
mrcp_state_machine.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2014 Arsen Chaloyan
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * $Id: mrcp_state_machine.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
17  */
18 
19 #ifndef MRCP_STATE_MACHINE_H
20 #define MRCP_STATE_MACHINE_H
21 
22 /**
23  * @file mrcp_state_machine.h
24  * @brief MRCP State Machine
25  */
26 
27 #include "mrcp_types.h"
28 
30 
31 /** MRCP state machine declaration */
33 
34 
35 /** MRCP state machine */
37  /** External object associated with state machine */
38  void *obj;
39  /** State either active or deactivating */
41 
42  /** Virtual update */
43  apt_bool_t (*update)(mrcp_state_machine_t *state_machine, mrcp_message_t *message);
44  /** Deactivate */
46 
47 
48  /** Message dispatcher */
50  /** Deactivated */
52 };
53 
54 /** Initialize MRCP state machine */
55 static APR_INLINE void mrcp_state_machine_init(mrcp_state_machine_t *state_machine, void *obj)
56 {
57  state_machine->obj = obj;
58  state_machine->active = TRUE;
59  state_machine->on_dispatch = NULL;
60  state_machine->on_deactivate = NULL;
61  state_machine->update = NULL;
62  state_machine->deactivate = NULL;
63 }
64 
65 /** Update MRCP state machine */
66 static APR_INLINE apt_bool_t mrcp_state_machine_update(mrcp_state_machine_t *state_machine, mrcp_message_t *message)
67 {
68  if(state_machine->update) {
69  return state_machine->update(state_machine,message);
70  }
71  return FALSE;
72 }
73 
74 /** Deactivate MRCP state machine */
75 static APR_INLINE apt_bool_t mrcp_state_machine_deactivate(mrcp_state_machine_t *state_machine)
76 {
77  if(state_machine->deactivate) {
78  state_machine->active = FALSE;
79  return state_machine->deactivate(state_machine);
80  }
81  return FALSE;
82 }
83 
85 
86 #endif /* MRCP_STATE_MACHINE_H */