1 #ifdef _cplusplus
2 extern "C" {
3 #endif
4 #include "gwquickdb.h"
5
6
7 /* Function: init_GeneWiseQuickDB(gdb,return_status)
8 *
9 * Descrip: inits a genewisequick database.
10 *
11 *
12 * Arg: gdb [UNKN ] Undocumented argument [GeneWiseQuickDB *]
13 * Arg: return_status [UNKN ] Undocumented argument [int *]
14 *
15 * Return [UNKN ] Undocumented return value [GeneWiseScoreFlat *]
16 *
17 */
18 # line 37 "gwquickdb.dy"
init_GeneWiseQuickDB(GeneWiseQuickDB * gdb,int * return_status)19 GeneWiseScoreFlat * init_GeneWiseQuickDB(GeneWiseQuickDB * gdb,int * return_status)
20 {
21 GeneWiseScore * gws;
22
23 gws = init_GeneWiseDB(gdb->gwdb,return_status);
24 if( gws != NULL ) {
25 return GeneWiseScoreFlat_from_GeneWiseScore(gws);
26 }
27
28 }
29
30
31 /* Function: reload_GeneWiseQuickDB(prev,gdb,return_status)
32 *
33 * Descrip: Reloads a genewisequick database
34 *
35 *
36 *
37 * Arg: prev [UNKN ] Undocumented argument [GeneWiseScoreFlat *]
38 * Arg: gdb [UNKN ] Undocumented argument [GeneWiseQuickDB *]
39 * Arg: return_status [UNKN ] Undocumented argument [int *]
40 *
41 * Return [UNKN ] Undocumented return value [GeneWiseScoreFlat *]
42 *
43 */
44 # line 53 "gwquickdb.dy"
reload_GeneWiseQuickDB(GeneWiseScoreFlat * prev,GeneWiseQuickDB * gdb,int * return_status)45 GeneWiseScoreFlat * reload_GeneWiseQuickDB(GeneWiseScoreFlat * prev,GeneWiseQuickDB * gdb,int * return_status)
46 {
47 GeneWiseScore * gws;
48
49 if( prev != NULL )
50 free_GeneWiseScoreFlat(prev);
51
52 gws = reload_GeneWiseDB(NULL,gdb->gwdb,return_status);
53 if( gws != NULL ) {
54 return GeneWiseScoreFlat_from_GeneWiseScore(gws);
55 }
56
57 }
58
59
60 /* Function: close_GeneWiseQuickDB(gws,gdb)
61 *
62 * Descrip: closes a GeneWiseDB
63 *
64 *
65 * Arg: gws [UNKN ] Undocumented argument [GeneWiseScoreFlat *]
66 * Arg: gdb [UNKN ] Undocumented argument [GeneWiseQuickDB *]
67 *
68 * Return [UNKN ] Undocumented return value [boolean]
69 *
70 */
71 # line 71 "gwquickdb.dy"
close_GeneWiseQuickDB(GeneWiseScoreFlat * gws,GeneWiseQuickDB * gdb)72 boolean close_GeneWiseQuickDB(GeneWiseScoreFlat * gws,GeneWiseQuickDB * gdb)
73 {
74 if( gws != NULL )
75 free_GeneWiseScoreFlat(gws);
76
77 return close_GeneWiseDB(NULL,gdb->gwdb);
78 }
79
80 /* Function: dataentry_add_GeneWiseQuickDB(de,gws,gdb)
81 *
82 * Descrip: adds dataentry stuff to a query.
83 *
84 *
85 * Arg: de [UNKN ] Undocumented argument [DataEntry *]
86 * Arg: gws [UNKN ] Undocumented argument [GeneWiseScoreFlat *]
87 * Arg: gdb [UNKN ] Undocumented argument [GeneWiseQuickDB *]
88 *
89 * Return [UNKN ] Undocumented return value [boolean]
90 *
91 */
92 # line 82 "gwquickdb.dy"
dataentry_add_GeneWiseQuickDB(DataEntry * de,GeneWiseScoreFlat * gws,GeneWiseQuickDB * gdb)93 boolean dataentry_add_GeneWiseQuickDB(DataEntry * de,GeneWiseScoreFlat * gws,GeneWiseQuickDB * gdb)
94 {
95 return dataentry_add_GeneWiseDB(de,NULL,gdb->gwdb);
96 }
97
98 /* Function: GeneWiseQuickDB_from_GeneWiseDB(gwdb)
99 *
100 * Descrip: Makes a new genewisequickdb from a genewisemodeldb
101 *
102 *
103 * Arg: gwdb [READ ] genewisedb - hard links as it enters [GeneWiseDB *]
104 *
105 * Return [UNKN ] Undocumented return value [GeneWiseQuickDB *]
106 *
107 */
108 # line 92 "gwquickdb.dy"
GeneWiseQuickDB_from_GeneWiseDB(GeneWiseDB * gwdb)109 GeneWiseQuickDB * GeneWiseQuickDB_from_GeneWiseDB(GeneWiseDB * gwdb)
110 {
111 GeneWiseQuickDB * out;
112
113 out = GeneWiseQuickDB_alloc();
114 out->gwdb = hard_link_GeneWiseDB(gwdb);
115
116 return out;
117 }
118
119 # line 108 "gwquickdb.c"
120 /* Function: hard_link_GeneWiseQuickDB(obj)
121 *
122 * Descrip: Bumps up the reference count of the object
123 * Meaning that multiple pointers can 'own' it
124 *
125 *
126 * Arg: obj [UNKN ] Object to be hard linked [GeneWiseQuickDB *]
127 *
128 * Return [UNKN ] Undocumented return value [GeneWiseQuickDB *]
129 *
130 */
hard_link_GeneWiseQuickDB(GeneWiseQuickDB * obj)131 GeneWiseQuickDB * hard_link_GeneWiseQuickDB(GeneWiseQuickDB * obj)
132 {
133 if( obj == NULL ) {
134 warn("Trying to hard link to a GeneWiseQuickDB object: passed a NULL object");
135 return NULL;
136 }
137 obj->dynamite_hard_link++;
138 return obj;
139 }
140
141
142 /* Function: GeneWiseQuickDB_alloc(void)
143 *
144 * Descrip: Allocates structure: assigns defaults if given
145 *
146 *
147 *
148 * Return [UNKN ] Undocumented return value [GeneWiseQuickDB *]
149 *
150 */
GeneWiseQuickDB_alloc(void)151 GeneWiseQuickDB * GeneWiseQuickDB_alloc(void)
152 {
153 GeneWiseQuickDB * out; /* out is exported at end of function */
154
155
156 /* call ckalloc and see if NULL */
157 if((out=(GeneWiseQuickDB *) ckalloc (sizeof(GeneWiseQuickDB))) == NULL) {
158 warn("GeneWiseQuickDB_alloc failed ");
159 return NULL; /* calling function should respond! */
160 }
161 out->dynamite_hard_link = 1;
162 #ifdef PTHREAD
163 pthread_mutex_init(&(out->dynamite_mutex),NULL);
164 #endif
165 out->gwdb = NULL;
166
167
168 return out;
169 }
170
171
172 /* Function: free_GeneWiseQuickDB(obj)
173 *
174 * Descrip: Free Function: removes the memory held by obj
175 * Will chain up to owned members and clear all lists
176 *
177 *
178 * Arg: obj [UNKN ] Object that is free'd [GeneWiseQuickDB *]
179 *
180 * Return [UNKN ] Undocumented return value [GeneWiseQuickDB *]
181 *
182 */
free_GeneWiseQuickDB(GeneWiseQuickDB * obj)183 GeneWiseQuickDB * free_GeneWiseQuickDB(GeneWiseQuickDB * obj)
184 {
185 int return_early = 0;
186
187
188 if( obj == NULL) {
189 warn("Attempting to free a NULL pointer to a GeneWiseQuickDB obj. Should be trappable");
190 return NULL;
191 }
192
193
194 #ifdef PTHREAD
195 assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0);
196 #endif
197 if( obj->dynamite_hard_link > 1) {
198 return_early = 1;
199 obj->dynamite_hard_link--;
200 }
201 #ifdef PTHREAD
202 assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0);
203 #endif
204 if( return_early == 1)
205 return NULL;
206 if( obj->gwdb != NULL)
207 free_GeneWiseDB(obj->gwdb);
208
209
210 ckfree(obj);
211 return NULL;
212 }
213
214
215
216 #ifdef _cplusplus
217 }
218 #endif
219