UniMRCP  1.7.0
mrcp_state_machine.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2015 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 
17 #ifndef MRCP_STATE_MACHINE_H
18 #define MRCP_STATE_MACHINE_H
19 
20 /**
21  * @file mrcp_state_machine.h
22  * @brief MRCP State Machine
23  */
24 
25 #include "mrcp_types.h"
26 
28 
29 /** MRCP state machine declaration */
31 
32 
33 /** MRCP state machine */
35  /** External object associated with state machine */
36  void *obj;
37  /** State either active or deactivating */
39 
40  /** Virtual update */
41  apt_bool_t (*update)(mrcp_state_machine_t *state_machine, mrcp_message_t *message);
42  /** Deactivate */
44 
45 
46  /** Message dispatcher */
48  /** Deactivated */
50 };
51 
52 /** Initialize MRCP state machine */
53 static APR_INLINE void mrcp_state_machine_init(mrcp_state_machine_t *state_machine, void *obj)
54 {
55  state_machine->obj = obj;
56  state_machine->active = TRUE;
57  state_machine->on_dispatch = NULL;
58  state_machine->on_deactivate = NULL;
59  state_machine->update = NULL;
60  state_machine->deactivate = NULL;
61 }
62 
63 /** Update MRCP state machine */
64 static APR_INLINE apt_bool_t mrcp_state_machine_update(mrcp_state_machine_t *state_machine, mrcp_message_t *message)
65 {
66  if(state_machine->update) {
67  return state_machine->update(state_machine,message);
68  }
69  return FALSE;
70 }
71 
72 /** Deactivate MRCP state machine */
73 static APR_INLINE apt_bool_t mrcp_state_machine_deactivate(mrcp_state_machine_t *state_machine)
74 {
75  if(state_machine->deactivate) {
76  state_machine->active = FALSE;
77  return state_machine->deactivate(state_machine);
78  }
79  return FALSE;
80 }
81 
83 
84 #endif /* MRCP_STATE_MACHINE_H */
apt_bool_t(* on_deactivate)(mrcp_state_machine_t *state_machine)
Definition: mrcp_state_machine.h:49
apt_bool_t active
Definition: mrcp_state_machine.h:38
apt_bool_t(* on_dispatch)(mrcp_state_machine_t *state_machine, mrcp_message_t *message)
Definition: mrcp_state_machine.h:47
#define APT_END_EXTERN_C
Definition: apt.h:38
int apt_bool_t
Definition: apt.h:57
void * obj
Definition: mrcp_state_machine.h:36
apt_bool_t(* deactivate)(mrcp_state_machine_t *state_machine)
Definition: mrcp_state_machine.h:43
Definition: mrcp_state_machine.h:34
#define APT_BEGIN_EXTERN_C
Definition: apt.h:36
Basic MRCP Types.
apt_bool_t(* update)(mrcp_state_machine_t *state_machine, mrcp_message_t *message)
Definition: mrcp_state_machine.h:41
Definition: mrcp_message.h:37