UniMRCP  1.3.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
mrcp_resource.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_resource.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
17  */
18 
19 #ifndef MRCP_RESOURCE_H
20 #define MRCP_RESOURCE_H
21 
22 /**
23  * @file mrcp_resource.h
24  * @brief Abstract MRCP Resource
25  */
26 
27 #include "mrcp_types.h"
28 #include "mrcp_header_accessor.h"
29 
31 
32 
33 /** MRCP resource definition */
35  /** MRCP resource identifier */
37  /** MRCP resource name */
39 
40  /** Get string table of methods */
41  const apt_str_table_item_t* (*get_method_str_table)(mrcp_version_e version);
42  /** Number of methods */
43  apr_size_t method_count;
44 
45  /** Get string table of events */
46  const apt_str_table_item_t* (*get_event_str_table)(mrcp_version_e version);
47  /** Number of events */
48  apr_size_t event_count;
49 
50  /** Get vtable of resource header */
51  const mrcp_header_vtable_t* (*get_resource_header_vtable)(mrcp_version_e version);
52 };
53 
54 /** Initialize MRCP resource */
55 static APR_INLINE mrcp_resource_t* mrcp_resource_create(apr_pool_t *pool)
56 {
57  mrcp_resource_t *resource = (mrcp_resource_t*) apr_palloc(pool, sizeof(mrcp_resource_t));
58  resource->id = 0;
59  apt_string_reset(&resource->name);
60  resource->method_count = 0;
61  resource->event_count = 0;
62  resource->get_method_str_table = NULL;
63  resource->get_event_str_table = NULL;
64  resource->get_resource_header_vtable = NULL;
65  return resource;
66 }
67 
68 /** Validate MRCP resource */
69 static APR_INLINE apt_bool_t mrcp_resource_validate(mrcp_resource_t *resource)
70 {
71  if(resource->method_count && resource->event_count &&
72  resource->get_method_str_table && resource->get_event_str_table &&
73  resource->get_resource_header_vtable &&
74  resource->name.buf && resource->name.length) {
75  return TRUE;
76  }
77  return FALSE;
78 }
79 
81 
82 #endif /* MRCP_RESOURCE_H */