00001 /* 00002 * Copyright 2008-2010 Arsen Chaloyan 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 * 00016 * $Id: mrcp_resource.h 1474 2010-02-07 20:51:47Z achaloyan $ 00017 */ 00018 00019 #ifndef MRCP_RESOURCE_H 00020 #define MRCP_RESOURCE_H 00021 00022 /** 00023 * @file mrcp_resource.h 00024 * @brief Abstract MRCP Resource 00025 */ 00026 00027 #include "mrcp_types.h" 00028 #include "mrcp_header_accessor.h" 00029 00030 APT_BEGIN_EXTERN_C 00031 00032 00033 /** MRCP resource definition */ 00034 struct mrcp_resource_t { 00035 /** MRCP resource identifier */ 00036 mrcp_resource_id id; 00037 /** MRCP resource name */ 00038 apt_str_t name; 00039 00040 /** Get string table of methods */ 00041 const apt_str_table_item_t* (*get_method_str_table)(mrcp_version_e version); 00042 /** Number of methods */ 00043 apr_size_t method_count; 00044 00045 /** Get string table of events */ 00046 const apt_str_table_item_t* (*get_event_str_table)(mrcp_version_e version); 00047 /** Number of events */ 00048 apr_size_t event_count; 00049 00050 /** Get vtable of resource header */ 00051 const mrcp_header_vtable_t* (*get_resource_header_vtable)(mrcp_version_e version); 00052 }; 00053 00054 /** Initialize MRCP resource */ 00055 static APR_INLINE mrcp_resource_t* mrcp_resource_create(apr_pool_t *pool) 00056 { 00057 mrcp_resource_t *resource = (mrcp_resource_t*) apr_palloc(pool, sizeof(mrcp_resource_t)); 00058 resource->id = 0; 00059 apt_string_reset(&resource->name); 00060 resource->method_count = 0; 00061 resource->event_count = 0; 00062 resource->get_method_str_table = NULL; 00063 resource->get_event_str_table = NULL; 00064 resource->get_resource_header_vtable = NULL; 00065 return resource; 00066 } 00067 00068 /** Validate MRCP resource */ 00069 static APR_INLINE apt_bool_t mrcp_resource_validate(mrcp_resource_t *resource) 00070 { 00071 if(resource->method_count && resource->event_count && 00072 resource->get_method_str_table && resource->get_event_str_table && 00073 resource->get_resource_header_vtable && 00074 resource->name.buf && resource->name.length) { 00075 return TRUE; 00076 } 00077 return FALSE; 00078 } 00079 00080 APT_END_EXTERN_C 00081 00082 #endif /* MRCP_RESOURCE_H */