UniMRCP  1.7.0
mrcp_resource.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_RESOURCE_H
18 #define MRCP_RESOURCE_H
19 
20 /**
21  * @file mrcp_resource.h
22  * @brief Abstract MRCP Resource
23  */
24 
25 #include "mrcp_types.h"
26 #include "mrcp_header_accessor.h"
27 
29 
30 
31 /** MRCP resource definition */
33  /** MRCP resource identifier */
35  /** MRCP resource name */
37 
38  /** Get string table of methods */
39  const apt_str_table_item_t* (*get_method_str_table)(mrcp_version_e version);
40  /** Number of methods */
41  apr_size_t method_count;
42 
43  /** Get string table of events */
44  const apt_str_table_item_t* (*get_event_str_table)(mrcp_version_e version);
45  /** Number of events */
46  apr_size_t event_count;
47 
48  /** Get vtable of resource header */
49  const mrcp_header_vtable_t* (*get_resource_header_vtable)(mrcp_version_e version);
50 };
51 
52 /** Initialize MRCP resource */
53 static APR_INLINE mrcp_resource_t* mrcp_resource_create(apr_pool_t *pool)
54 {
55  mrcp_resource_t *resource = (mrcp_resource_t*) apr_palloc(pool, sizeof(mrcp_resource_t));
56  resource->id = 0;
57  apt_string_reset(&resource->name);
58  resource->method_count = 0;
59  resource->event_count = 0;
60  resource->get_method_str_table = NULL;
61  resource->get_event_str_table = NULL;
62  resource->get_resource_header_vtable = NULL;
63  return resource;
64 }
65 
66 /** Validate MRCP resource */
67 static APR_INLINE apt_bool_t mrcp_resource_validate(mrcp_resource_t *resource)
68 {
69  if(resource->method_count && resource->event_count &&
70  resource->get_method_str_table && resource->get_event_str_table &&
71  resource->get_resource_header_vtable &&
72  resource->name.buf && resource->name.length) {
73  return TRUE;
74  }
75  return FALSE;
76 }
77 
79 
80 #endif /* MRCP_RESOURCE_H */
apr_size_t method_count
Definition: mrcp_resource.h:41
#define APT_END_EXTERN_C
Definition: apt.h:38
int apt_bool_t
Definition: apt.h:57
Definition: mrcp_header_accessor.h:37
apt_str_t name
Definition: mrcp_resource.h:36
apr_size_t event_count
Definition: mrcp_resource.h:46
mrcp_version_e
Definition: mrcp_types.h:30
const apt_str_table_item_t *(* get_event_str_table)(mrcp_version_e version)
Definition: mrcp_resource.h:44
apr_size_t length
Definition: apt_string.h:40
#define APT_BEGIN_EXTERN_C
Definition: apt.h:36
Basic MRCP Types.
apr_size_t mrcp_resource_id
Definition: mrcp_types.h:68
Definition: apt_string.h:36
mrcp_resource_id id
Definition: mrcp_resource.h:34
const apt_str_table_item_t *(* get_method_str_table)(mrcp_version_e version)
Definition: mrcp_resource.h:39
Abstract MRCP Header Accessor.
const mrcp_header_vtable_t *(* get_resource_header_vtable)(mrcp_version_e version)
Definition: mrcp_resource.h:49
Definition: mrcp_resource.h:32
char * buf
Definition: apt_string.h:38
Definition: apt_string_table.h:34