1 /*
2  * Copyright (C) 2008-2009 SVOX AG, Baslerstr. 30, 8048 Zuerich, Switzerland
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  * @file picorsrc.h
18  *
19  * Copyright (C) 2008-2009 SVOX AG, Baslerstr. 30, 8048 Zuerich, Switzerland
20  * All rights reserved.
21  *
22  * History:
23  * - 2009-04-20 -- initial version
24  *
25  */
26 /**
27  * @addtogroup picorsrc
28  *
29  * <b> Pico Resource Management module </b>\n
30  *
31 */
32 
33 #ifndef PICORSRC_H_
34 #define PICORSRC_H_
35 
36 #include "picodefs.h"
37 #include "picoos.h"
38 #include "picoknow.h"
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 #if 0
44 }
45 #endif
46 
47 
48 #define PICORSRC_MAX_RSRC_NAME_SIZ PICO_MAX_RESOURCE_NAME_SIZE /* including terminating NULLC */
49 
50 #define PICORSRC_MAX_NUM_VOICES 64
51 
52 /* size of kb array of a voice */
53 #define PICORSRC_KB_ARRAY_SIZE 64
54 
55 typedef picoos_char picorsrc_resource_name_t[PICORSRC_MAX_RSRC_NAME_SIZ];
56 
57 typedef enum picorsrc_resource_type {
58     PICORSRC_TYPE_NULL,
59     PICORSRC_TYPE_TEXTANA,
60     PICORSRC_TYPE_SIGGEN,
61     PICORSRC_TYPE_USER_LEX,
62     PICORSRC_TYPE_USER_PREPROC,
63     PICORSRC_TYPE_OTHER
64 } picorsrc_resource_type_t;
65 
66 
67 #define PICORSRC_FIELD_VALUE_TEXTANA (picoos_char *) "TEXTANA"
68 #define PICORSRC_FIELD_VALUE_SIGGEN (picoos_char *) "SIGGEN"
69 #define PICORSRC_FIELD_VALUE_USERLEX (picoos_char *) "USERLEX"
70 #define PICORSRC_FIELD_VALUE_USERTPP (picoos_char *) "USERTPP"
71 
72 
73 
74 typedef struct picorsrc_resource_manager * picorsrc_ResourceManager;
75 typedef struct picorsrc_voice            * picorsrc_Voice;
76 typedef struct picorsrc_resource         * picorsrc_Resource;
77 
78 
79 /* **************************************************************************
80  *
81  *          file name extensions
82  *
83  ****************************************************************************/
84 
85 #define PICO_BIN_EXTENSION      ".bin"
86 #define PICO_INPLACE_EXTENSION  ".inp"
87 
88 
89 
90 /* **************************************************************************
91  *
92  *          construct/destruct resource manager
93  *
94  ****************************************************************************/
95 
96 /* create resource manager, given a config file name (or default name, if empty) */
97 
98 picorsrc_ResourceManager picorsrc_newResourceManager(picoos_MemoryManager mm, picoos_Common common /* , picoos_char * configFile */);
99 
100 void picorsrc_disposeResourceManager(picoos_MemoryManager mm, picorsrc_ResourceManager * this);
101 
102 
103 /* **************************************************************************
104  *
105  *          resources
106  *
107  ****************************************************************************/
108 
109 /**
110  * Returns non-zero if 'resource' is a valid resource handle, zero otherwise.
111  */
112 picoos_int16 picoctrl_isValidResourceHandle(picorsrc_Resource resource);
113 
114 /* load resource file. the type of resource file, magic numbers, checksum etc. are in the header, then follows the directory
115  * (with fixed structure per resource type), then the knowledge bases themselves (as byte streams) */
116 pico_status_t picorsrc_loadResource(picorsrc_ResourceManager this,
117         picoos_char * fileName, picorsrc_Resource * resource);
118 
119 /* unload resource file. (warn if resource file is busy) */
120 pico_status_t picorsrc_unloadResource(picorsrc_ResourceManager this, picorsrc_Resource * rsrc);
121 
122 
123 pico_status_t picorsrc_createDefaultResource(picorsrc_ResourceManager this /*,
124         picorsrc_Resource * resource */);
125 
126 
127 pico_status_t picorsrc_rsrcGetName(picorsrc_Resource resource,
128         picoos_char * name, picoos_uint32 maxlen);
129 
130 /* **************************************************************************
131  *
132  *          voice definitions
133  *
134  ****************************************************************************/
135 
136 
137 pico_status_t picorsrc_createVoiceDefinition(picorsrc_ResourceManager this,
138         picoos_char * voiceName);
139 
140 
141 pico_status_t picorsrc_releaseVoiceDefinition(picorsrc_ResourceManager this,
142         picoos_char * voiceName);
143 
144 pico_status_t picorsrc_addResourceToVoiceDefinition(picorsrc_ResourceManager this,
145         picoos_char * voiceName, picoos_char * resourceName);
146 
147 /* **************************************************************************
148  *
149  *          voices
150  *
151  ****************************************************************************/
152 
153 /**  object   : Voice
154  *   shortcut : voice
155  *
156  */
157 
158 typedef struct picorsrc_voice {
159 
160     picorsrc_Voice next;
161 
162     picoknow_KnowledgeBase kbArray[PICORSRC_KB_ARRAY_SIZE];
163 
164     picoos_uint8 numResources;
165 
166     picorsrc_Resource resourceArray[PICO_MAX_NUM_RSRC_PER_VOICE];
167 
168 
169 } picorsrc_voice_t;
170 
171 
172 
173 /* create voice, given a voice name. the corresponding lock counts are incremented */
174 pico_status_t picorsrc_createVoice(picorsrc_ResourceManager this, const picoos_char * voiceName, picorsrc_Voice * voice);
175 
176 /* dispose voice. the corresponding lock counts are decremented. */
177 pico_status_t picorsrc_releaseVoice(picorsrc_ResourceManager this, picorsrc_Voice * voice);
178 
179 #ifdef __cplusplus
180 }
181 #endif
182 
183 
184 
185 #endif /*PICORSRC_H_*/
186