1 #ifdef _cplusplus
2 extern "C" {
3 #endif
4 #include "packaln.h"
5
6 /* Function: read_simple_PackAln_file(file)
7 *
8 * Descrip: Reads in a PackAln from a file in show_simple_PackAln
9 *
10 *
11 * Arg: file [UNKN ] Undocumented argument [char *]
12 *
13 * Return [UNKN ] Undocumented return value [PackAln *]
14 *
15 */
16 # line 57 "packaln.dy"
read_simple_PackAln_file(char * file)17 PackAln * read_simple_PackAln_file(char * file)
18 {
19 FILE * ifp;
20 PackAln * out;
21
22 if( (ifp=openfile(file,"r")) == NULL ) {
23 warn("Could not open %s for PackAln file reading",file);
24 }
25
26 out = read_simple_PackAln(ifp);
27
28 fclose(ifp);
29
30 return out;
31
32 }
33
34 /* Function: read_simple_PackAln(ifp)
35 *
36 * Descrip: Reads in PackAln from file format in show_simple_PackAln
37 *
38 *
39 * Arg: ifp [UNKN ] Undocumented argument [FILE *]
40 *
41 * Return [UNKN ] Undocumented return value [PackAln *]
42 *
43 */
44 # line 77 "packaln.dy"
read_simple_PackAln(FILE * ifp)45 PackAln * read_simple_PackAln(FILE * ifp)
46 {
47 PackAln * out;
48 PackAlnUnit * unit;
49 char buffer[MAXLINE];
50
51 assert(ifp);
52
53 out = PackAln_alloc_std();
54
55 /* score line */
56 fgets(buffer,MAXLINE,ifp);
57
58 while( fgets(buffer,MAXLINE,ifp) != NULL ) {
59 if( strstartcmp(buffer,"//") == 0 ) {
60 break;
61 }
62
63 unit = PackAlnUnit_alloc();
64
65 sscanf(buffer,"Position i:[%d] j:[%d] State:[%d] Score: %d",&unit->i,&unit->j,&unit->state,&unit->score);
66
67 add_PackAln(out,unit);
68 }
69
70 return out;
71 }
72
73
74 /* Function: show_simple_PackAlnUnit(pau,ofp)
75 *
76 * Descrip: shows packalnunit very simply ;)
77 *
78 *
79 * Arg: pau [UNKN ] Undocumented argument [PackAlnUnit *]
80 * Arg: ofp [UNKN ] Undocumented argument [FILE *]
81 *
82 */
83 # line 110 "packaln.dy"
show_simple_PackAlnUnit(PackAlnUnit * pau,FILE * ofp)84 void show_simple_PackAlnUnit(PackAlnUnit * pau,FILE * ofp)
85 {
86 fprintf(ofp,"Position i:[%d] j:[%d] State:[%d] Score: %d\n",pau->i,pau->j,pau->state,pau->score);
87 }
88
89 /* Function: show_text_PackAlnUnit(state_to_char,pau,ofp)
90 *
91 * Descrip: shows packalnunit with the text mapping
92 *
93 *
94 * Arg: state_to_char [UNKN ] Undocumented argument [NullString]
95 * Arg: pau [UNKN ] Undocumented argument [PackAlnUnit *]
96 * Arg: ofp [UNKN ] Undocumented argument [FILE *]
97 *
98 */
99 # line 119 "packaln.dy"
show_text_PackAlnUnit(PackAlnUnit * pau,char * (* state_to_char)(int),FILE * ofp)100 void show_text_PackAlnUnit(PackAlnUnit * pau,char * (*state_to_char)(int),FILE * ofp)
101 {
102 fprintf(ofp,"Position i:[%4d] j:[%4d] State:[%2d] Score:[%3d] [%s]\n",pau->i,pau->j,pau->state,pau->score,(*state_to_char)(pau->state));
103 }
104
105 /* Function: show_bits_and_cumlative_PackAln(pal,ofp)
106 *
107 * Descrip: Shows packaln as:
108 *
109 * i,j,state,score,bits,cumlative-score,cumlative-bits
110 *
111 * cumlative score and cumlative bits are useful sometimes
112 *
113 *
114 * Arg: pal [UNKN ] Undocumented argument [PackAln *]
115 * Arg: ofp [UNKN ] Undocumented argument [FILE *]
116 *
117 */
118 # line 131 "packaln.dy"
show_bits_and_cumlative_PackAln(PackAln * pal,FILE * ofp)119 void show_bits_and_cumlative_PackAln(PackAln * pal,FILE * ofp)
120 {
121 int i;
122 int cs = 0;
123 double cb = 0.0;
124
125
126 fprintf(ofp,"Score %d\n",pal->score);
127 for(i=0;i<pal->len;i++) {
128 auto PackAlnUnit * pau;
129 pau = pal->pau[i];
130
131 cs += pal->pau[i]->score;
132 cb += Score2Bits(pal->pau[i]->score);
133 fprintf(ofp,"i [%4d] j [%4d] state [%2d] score [%4d] bits [%2.2f] Score-CF [%6d] Bits-CF[%4.2f]\n",pau->i,pau->j,pau->state,pau->score,Score2Bits(pau->score),cs,cb);
134 }
135
136 }
137
138
139 /* Function: show_simple_PackAln(pal,ofp)
140 *
141 * Descrip: shows packaln with a pretty verbose debugging
142 * format
143 *
144 *
145 * Arg: pal [UNKN ] Undocumented argument [PackAln *]
146 * Arg: ofp [UNKN ] Undocumented argument [FILE *]
147 *
148 */
149 # line 155 "packaln.dy"
show_simple_PackAln(PackAln * pal,FILE * ofp)150 void show_simple_PackAln(PackAln * pal,FILE * ofp)
151 {
152 register int i;
153
154 fprintf(ofp,"Score %d\n",pal->score);
155 for(i=0;i<pal->len;i++)
156 show_simple_PackAlnUnit(pal->pau[i],ofp);
157 }
158
159 /* Function: show_text_PackAln(state_to_char,pal,ofp)
160 *
161 * Descrip: shows packaln with a pretty verbose debugging
162 * format, but with a conversion function from state number to
163 * a string
164 *
165 *
166 * Arg: state_to_char [UNKN ] Undocumented argument [NullString]
167 * Arg: pal [UNKN ] Undocumented argument [PackAln *]
168 * Arg: ofp [UNKN ] Undocumented argument [FILE *]
169 *
170 */
171 # line 169 "packaln.dy"
show_text_PackAln(PackAln * pal,char * (* state_to_char)(int),FILE * ofp)172 void show_text_PackAln(PackAln * pal,char * (*state_to_char)(int),FILE * ofp)
173 {
174 register int i;
175
176 fprintf(ofp,"Score %d\n",pal->score);
177 for(i=0;i<pal->len;i++)
178 show_text_PackAlnUnit(pal->pau[i],state_to_char,ofp);
179 }
180
181 /* Function: invert_PackAln(pal)
182 *
183 * Descrip: inverts the packaln so that the last unit is the first
184 * etc. Because most alignments are read backwards this
185 * is useful
186 *
187 *
188 * Arg: pal [UNKN ] PackAln to be inverted [PackAln *]
189 *
190 */
191 # line 185 "packaln.dy"
invert_PackAln(PackAln * pal)192 void invert_PackAln(PackAln * pal)
193 {
194 PackAlnUnit ** temp;
195 register int i;
196
197 /*** there are better ways to do this! ***/
198
199 temp = (PackAlnUnit **) ckcalloc(pal->len,sizeof(PackAlnUnit *));
200
201 for(i=0;i<pal->len;i++)
202 temp[i] = pal->pau[pal->len-1-i];
203 for(i=0;i<pal->len;i++)
204 pal->pau[i] = temp[i];
205
206 ckfree(temp);
207 }
208
209
210
211 # line 194 "packaln.c"
212 /* Function: hard_link_PackAlnUnit(obj)
213 *
214 * Descrip: Bumps up the reference count of the object
215 * Meaning that multiple pointers can 'own' it
216 *
217 *
218 * Arg: obj [UNKN ] Object to be hard linked [PackAlnUnit *]
219 *
220 * Return [UNKN ] Undocumented return value [PackAlnUnit *]
221 *
222 */
hard_link_PackAlnUnit(PackAlnUnit * obj)223 PackAlnUnit * hard_link_PackAlnUnit(PackAlnUnit * obj)
224 {
225 if( obj == NULL ) {
226 warn("Trying to hard link to a PackAlnUnit object: passed a NULL object");
227 return NULL;
228 }
229 obj->dynamite_hard_link++;
230 return obj;
231 }
232
233
234 /* Function: PackAlnUnit_alloc(void)
235 *
236 * Descrip: Allocates structure: assigns defaults if given
237 *
238 *
239 *
240 * Return [UNKN ] Undocumented return value [PackAlnUnit *]
241 *
242 */
PackAlnUnit_alloc(void)243 PackAlnUnit * PackAlnUnit_alloc(void)
244 {
245 PackAlnUnit * out; /* out is exported at end of function */
246
247
248 /* call ckalloc and see if NULL */
249 if((out=(PackAlnUnit *) ckalloc (sizeof(PackAlnUnit))) == NULL) {
250 warn("PackAlnUnit_alloc failed ");
251 return NULL; /* calling function should respond! */
252 }
253 out->dynamite_hard_link = 1;
254 #ifdef PTHREAD
255 pthread_mutex_init(&(out->dynamite_mutex),NULL);
256 #endif
257 out->i = 0;
258 out->j = 0;
259 out->state = 0;
260 out->score = 0;
261
262
263 return out;
264 }
265
266
267 /* Function: free_PackAlnUnit(obj)
268 *
269 * Descrip: Free Function: removes the memory held by obj
270 * Will chain up to owned members and clear all lists
271 *
272 *
273 * Arg: obj [UNKN ] Object that is free'd [PackAlnUnit *]
274 *
275 * Return [UNKN ] Undocumented return value [PackAlnUnit *]
276 *
277 */
free_PackAlnUnit(PackAlnUnit * obj)278 PackAlnUnit * free_PackAlnUnit(PackAlnUnit * obj)
279 {
280 int return_early = 0;
281
282
283 if( obj == NULL) {
284 warn("Attempting to free a NULL pointer to a PackAlnUnit obj. Should be trappable");
285 return NULL;
286 }
287
288
289 #ifdef PTHREAD
290 assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0);
291 #endif
292 if( obj->dynamite_hard_link > 1) {
293 return_early = 1;
294 obj->dynamite_hard_link--;
295 }
296 #ifdef PTHREAD
297 assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0);
298 #endif
299 if( return_early == 1)
300 return NULL;
301
302
303 ckfree(obj);
304 return NULL;
305 }
306
307
308 /* Function: swap_PackAln(list,i,j)
309 *
310 * Descrip: swap function: an internal for qsort_PackAln
311 * swaps two positions in the array
312 *
313 *
314 * Arg: list [UNKN ] List of structures to swap in [PackAlnUnit **]
315 * Arg: i [UNKN ] swap position [int]
316 * Arg: j [UNKN ] swap position [int]
317 *
318 */
319 /* swap function for qsort function */
swap_PackAln(PackAlnUnit ** list,int i,int j)320 void swap_PackAln(PackAlnUnit ** list,int i,int j)
321 {
322 PackAlnUnit * temp;
323 temp=list[i];
324 list[i]=list[j];
325 list[j]=temp;
326 }
327
328
329 /* Function: qsort_PackAln(list,left,right,comp)
330 *
331 * Descrip: qsort - lifted from K&R
332 * sorts the array using quicksort
333 * Probably much better to call sort_PackAln which sorts from start to end
334 *
335 *
336 * Arg: list [UNKN ] List of structures to swap in [PackAlnUnit **]
337 * Arg: left [UNKN ] left position [int]
338 * Arg: right [UNKN ] right position [int]
339 * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp]
340 *
341 */
qsort_PackAln(PackAlnUnit ** list,int left,int right,int (* comp)(PackAlnUnit *,PackAlnUnit *))342 void qsort_PackAln(PackAlnUnit ** list,int left,int right,int (*comp)(PackAlnUnit * ,PackAlnUnit * ))
343 {
344 int i,last;
345 if( left >= right )
346 return;
347
348
349 swap_PackAln(list,left,(left+right)/2);
350 last = left;
351 for ( i=left+1; i <= right;i++) {
352 if( (*comp)(list[i],list[left]) < 0)
353 swap_PackAln (list,++last,i);
354 }
355 swap_PackAln (list,left,last);
356 qsort_PackAln(list,left,last-1,comp);
357 qsort_PackAln(list,last+1,right,comp);
358 }
359
360
361 /* Function: sort_PackAln(obj,comp)
362 *
363 * Descrip: sorts from start to end using comp
364 * sorts the array using quicksort by calling qsort_PackAln
365 *
366 *
367 * Arg: obj [UNKN ] Object containing list [PackAln *]
368 * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp]
369 *
370 */
sort_PackAln(PackAln * obj,int (* comp)(PackAlnUnit *,PackAlnUnit *))371 void sort_PackAln(PackAln * obj,int (*comp)(PackAlnUnit *, PackAlnUnit *))
372 {
373 qsort_PackAln(obj->pau,0,obj->len-1,comp);
374 return;
375 }
376
377
378 /* Function: expand_PackAln(obj,len)
379 *
380 * Descrip: Really an internal function for add_PackAln
381 *
382 *
383 * Arg: obj [UNKN ] Object which contains the list [PackAln *]
384 * Arg: len [UNKN ] Length to add one [int]
385 *
386 * Return [UNKN ] Undocumented return value [boolean]
387 *
388 */
expand_PackAln(PackAln * obj,int len)389 boolean expand_PackAln(PackAln * obj,int len)
390 {
391
392
393 if( obj->maxlen > obj->len ) {
394 warn("expand_PackAln called with no need");
395 return TRUE;
396 }
397
398
399 if( (obj->pau = (PackAlnUnit ** ) ckrealloc (obj->pau,sizeof(PackAlnUnit *)*len)) == NULL) {
400 warn("ckrealloc failed for expand_PackAln, returning FALSE");
401 return FALSE;
402 }
403 obj->maxlen = len;
404 return TRUE;
405 }
406
407
408 /* Function: add_PackAln(obj,add)
409 *
410 * Descrip: Adds another object to the list. It will expand the list if necessary
411 *
412 *
413 * Arg: obj [UNKN ] Object which contains the list [PackAln *]
414 * Arg: add [OWNER] Object to add to the list [PackAlnUnit *]
415 *
416 * Return [UNKN ] Undocumented return value [boolean]
417 *
418 */
419 /* will expand function if necessary */
add_PackAln(PackAln * obj,PackAlnUnit * add)420 boolean add_PackAln(PackAln * obj,PackAlnUnit * add)
421 {
422 if( obj->len >= obj->maxlen) {
423 if( expand_PackAln(obj,obj->len + PackAlnLISTLENGTH) == FALSE)
424 return FALSE;
425 }
426
427
428 obj->pau[obj->len++]=add;
429 return TRUE;
430 }
431
432
433 /* Function: flush_PackAln(obj)
434 *
435 * Descrip: Frees the list elements, sets length to 0
436 * If you want to save some elements, use hard_link_xxx
437 * to protect them from being actually destroyed in the free
438 *
439 *
440 * Arg: obj [UNKN ] Object which contains the list [PackAln *]
441 *
442 * Return [UNKN ] Undocumented return value [int]
443 *
444 */
flush_PackAln(PackAln * obj)445 int flush_PackAln(PackAln * obj)
446 {
447 int i;
448
449
450 for(i=0;i<obj->len;i++) { /*for i over list length*/
451 if( obj->pau[i] != NULL) {
452 free_PackAlnUnit(obj->pau[i]);
453 obj->pau[i] = NULL;
454 }
455 } /* end of for i over list length */
456
457
458 obj->len = 0;
459 return i;
460 }
461
462
463 /* Function: PackAln_alloc_std(void)
464 *
465 * Descrip: Equivalent to PackAln_alloc_len(PackAlnLISTLENGTH)
466 *
467 *
468 *
469 * Return [UNKN ] Undocumented return value [PackAln *]
470 *
471 */
PackAln_alloc_std(void)472 PackAln * PackAln_alloc_std(void)
473 {
474 return PackAln_alloc_len(PackAlnLISTLENGTH);
475 }
476
477
478 /* Function: PackAln_alloc_len(len)
479 *
480 * Descrip: Allocates len length to all lists
481 *
482 *
483 * Arg: len [UNKN ] Length of lists to allocate [int]
484 *
485 * Return [UNKN ] Undocumented return value [PackAln *]
486 *
487 */
PackAln_alloc_len(int len)488 PackAln * PackAln_alloc_len(int len)
489 {
490 PackAln * out; /* out is exported at the end of function */
491
492
493 /* Call alloc function: return NULL if NULL */
494 /* Warning message alread in alloc function */
495 if((out = PackAln_alloc()) == NULL)
496 return NULL;
497
498
499 /* Calling ckcalloc for list elements */
500 if((out->pau = (PackAlnUnit ** ) ckcalloc (len,sizeof(PackAlnUnit *))) == NULL) {
501 warn("Warning, ckcalloc failed in PackAln_alloc_len");
502 return NULL;
503 }
504 out->len = 0;
505 out->maxlen = len;
506
507
508 return out;
509 }
510
511
512 /* Function: hard_link_PackAln(obj)
513 *
514 * Descrip: Bumps up the reference count of the object
515 * Meaning that multiple pointers can 'own' it
516 *
517 *
518 * Arg: obj [UNKN ] Object to be hard linked [PackAln *]
519 *
520 * Return [UNKN ] Undocumented return value [PackAln *]
521 *
522 */
hard_link_PackAln(PackAln * obj)523 PackAln * hard_link_PackAln(PackAln * obj)
524 {
525 if( obj == NULL ) {
526 warn("Trying to hard link to a PackAln object: passed a NULL object");
527 return NULL;
528 }
529 obj->dynamite_hard_link++;
530 return obj;
531 }
532
533
534 /* Function: PackAln_alloc(void)
535 *
536 * Descrip: Allocates structure: assigns defaults if given
537 *
538 *
539 *
540 * Return [UNKN ] Undocumented return value [PackAln *]
541 *
542 */
PackAln_alloc(void)543 PackAln * PackAln_alloc(void)
544 {
545 PackAln * out; /* out is exported at end of function */
546
547
548 /* call ckalloc and see if NULL */
549 if((out=(PackAln *) ckalloc (sizeof(PackAln))) == NULL) {
550 warn("PackAln_alloc failed ");
551 return NULL; /* calling function should respond! */
552 }
553 out->dynamite_hard_link = 1;
554 #ifdef PTHREAD
555 pthread_mutex_init(&(out->dynamite_mutex),NULL);
556 #endif
557 out->pau = NULL;
558 out->len = out->maxlen = 0;
559 out->score = 0;
560
561
562 return out;
563 }
564
565
566 /* Function: free_PackAln(obj)
567 *
568 * Descrip: Free Function: removes the memory held by obj
569 * Will chain up to owned members and clear all lists
570 *
571 *
572 * Arg: obj [UNKN ] Object that is free'd [PackAln *]
573 *
574 * Return [UNKN ] Undocumented return value [PackAln *]
575 *
576 */
free_PackAln(PackAln * obj)577 PackAln * free_PackAln(PackAln * obj)
578 {
579 int return_early = 0;
580 int i;
581
582
583 if( obj == NULL) {
584 warn("Attempting to free a NULL pointer to a PackAln obj. Should be trappable");
585 return NULL;
586 }
587
588
589 #ifdef PTHREAD
590 assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0);
591 #endif
592 if( obj->dynamite_hard_link > 1) {
593 return_early = 1;
594 obj->dynamite_hard_link--;
595 }
596 #ifdef PTHREAD
597 assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0);
598 #endif
599 if( return_early == 1)
600 return NULL;
601 if( obj->pau != NULL) {
602 for(i=0;i<obj->len;i++) {
603 if( obj->pau[i] != NULL)
604 free_PackAlnUnit(obj->pau[i]);
605 }
606 ckfree(obj->pau);
607 }
608
609
610 ckfree(obj);
611 return NULL;
612 }
613
614
615 /* Function: access_pau_PackAln(obj,i)
616 *
617 * Descrip: Access members stored in the pau list
618 * For use principly by API functions
619 *
620 *
621 * Arg: obj [UNKN ] Object holding the list [PackAln *]
622 * Arg: i [UNKN ] Position in the list [int]
623 *
624 * Return [SOFT ] Element of the list [PackAlnUnit *]
625 *
626 */
access_pau_PackAln(PackAln * obj,int i)627 PackAlnUnit * access_pau_PackAln(PackAln * obj,int i)
628 {
629 if( obj == NULL) {
630 warn("In accessor function pau for object PackAln, got a NULL object");
631 return NULL;
632 }
633 if( obj->len <= i ) {
634 warn("In accessor function pau for object PackAln, index %%d is greater than list length %%d",i,obj->len);
635 return NULL;
636 }
637 return obj->pau[i];
638 }
639
640
641 /* Function: length_pau_PackAln(obj)
642 *
643 * Descrip: discover the length of the list
644 * For use principly by API functions
645 *
646 *
647 * Arg: obj [UNKN ] Object holding the list [PackAln *]
648 *
649 * Return [UNKN ] length of the list [int]
650 *
651 */
length_pau_PackAln(PackAln * obj)652 int length_pau_PackAln(PackAln * obj)
653 {
654 if( obj == NULL) {
655 warn("In length function pau for object PackAln, got a NULL object");
656 return -1;
657 }
658 return obj->len;
659 }
660
661
662 /* Function: replace_score_PackAln(obj,score)
663 *
664 * Descrip: Replace member variable score
665 * For use principly by API functions
666 *
667 *
668 * Arg: obj [UNKN ] Object holding the variable [PackAln *]
669 * Arg: score [OWNER] New value of the variable [int]
670 *
671 * Return [SOFT ] member variable score [boolean]
672 *
673 */
replace_score_PackAln(PackAln * obj,int score)674 boolean replace_score_PackAln(PackAln * obj,int score)
675 {
676 if( obj == NULL) {
677 warn("In replacement function score for object PackAln, got a NULL object");
678 return FALSE;
679 }
680 obj->score = score;
681 return TRUE;
682 }
683
684
685 /* Function: access_score_PackAln(obj)
686 *
687 * Descrip: Access member variable score
688 * For use principly by API functions
689 *
690 *
691 * Arg: obj [UNKN ] Object holding the variable [PackAln *]
692 *
693 * Return [SOFT ] member variable score [int]
694 *
695 */
access_score_PackAln(PackAln * obj)696 int access_score_PackAln(PackAln * obj)
697 {
698 if( obj == NULL) {
699 warn("In accessor function score for object PackAln, got a NULL object");
700 return 0;
701 }
702 return obj->score;
703 }
704
705
706 /* Function: replace_i_PackAlnUnit(obj,i)
707 *
708 * Descrip: Replace member variable i
709 * For use principly by API functions
710 *
711 *
712 * Arg: obj [UNKN ] Object holding the variable [PackAlnUnit *]
713 * Arg: i [OWNER] New value of the variable [int]
714 *
715 * Return [SOFT ] member variable i [boolean]
716 *
717 */
replace_i_PackAlnUnit(PackAlnUnit * obj,int i)718 boolean replace_i_PackAlnUnit(PackAlnUnit * obj,int i)
719 {
720 if( obj == NULL) {
721 warn("In replacement function i for object PackAlnUnit, got a NULL object");
722 return FALSE;
723 }
724 obj->i = i;
725 return TRUE;
726 }
727
728
729 /* Function: access_i_PackAlnUnit(obj)
730 *
731 * Descrip: Access member variable i
732 * For use principly by API functions
733 *
734 *
735 * Arg: obj [UNKN ] Object holding the variable [PackAlnUnit *]
736 *
737 * Return [SOFT ] member variable i [int]
738 *
739 */
access_i_PackAlnUnit(PackAlnUnit * obj)740 int access_i_PackAlnUnit(PackAlnUnit * obj)
741 {
742 if( obj == NULL) {
743 warn("In accessor function i for object PackAlnUnit, got a NULL object");
744 return 0;
745 }
746 return obj->i;
747 }
748
749
750 /* Function: replace_j_PackAlnUnit(obj,j)
751 *
752 * Descrip: Replace member variable j
753 * For use principly by API functions
754 *
755 *
756 * Arg: obj [UNKN ] Object holding the variable [PackAlnUnit *]
757 * Arg: j [OWNER] New value of the variable [int]
758 *
759 * Return [SOFT ] member variable j [boolean]
760 *
761 */
replace_j_PackAlnUnit(PackAlnUnit * obj,int j)762 boolean replace_j_PackAlnUnit(PackAlnUnit * obj,int j)
763 {
764 if( obj == NULL) {
765 warn("In replacement function j for object PackAlnUnit, got a NULL object");
766 return FALSE;
767 }
768 obj->j = j;
769 return TRUE;
770 }
771
772
773 /* Function: access_j_PackAlnUnit(obj)
774 *
775 * Descrip: Access member variable j
776 * For use principly by API functions
777 *
778 *
779 * Arg: obj [UNKN ] Object holding the variable [PackAlnUnit *]
780 *
781 * Return [SOFT ] member variable j [int]
782 *
783 */
access_j_PackAlnUnit(PackAlnUnit * obj)784 int access_j_PackAlnUnit(PackAlnUnit * obj)
785 {
786 if( obj == NULL) {
787 warn("In accessor function j for object PackAlnUnit, got a NULL object");
788 return 0;
789 }
790 return obj->j;
791 }
792
793
794 /* Function: replace_state_PackAlnUnit(obj,state)
795 *
796 * Descrip: Replace member variable state
797 * For use principly by API functions
798 *
799 *
800 * Arg: obj [UNKN ] Object holding the variable [PackAlnUnit *]
801 * Arg: state [OWNER] New value of the variable [int]
802 *
803 * Return [SOFT ] member variable state [boolean]
804 *
805 */
replace_state_PackAlnUnit(PackAlnUnit * obj,int state)806 boolean replace_state_PackAlnUnit(PackAlnUnit * obj,int state)
807 {
808 if( obj == NULL) {
809 warn("In replacement function state for object PackAlnUnit, got a NULL object");
810 return FALSE;
811 }
812 obj->state = state;
813 return TRUE;
814 }
815
816
817 /* Function: access_state_PackAlnUnit(obj)
818 *
819 * Descrip: Access member variable state
820 * For use principly by API functions
821 *
822 *
823 * Arg: obj [UNKN ] Object holding the variable [PackAlnUnit *]
824 *
825 * Return [SOFT ] member variable state [int]
826 *
827 */
access_state_PackAlnUnit(PackAlnUnit * obj)828 int access_state_PackAlnUnit(PackAlnUnit * obj)
829 {
830 if( obj == NULL) {
831 warn("In accessor function state for object PackAlnUnit, got a NULL object");
832 return 0;
833 }
834 return obj->state;
835 }
836
837
838 /* Function: replace_score_PackAlnUnit(obj,score)
839 *
840 * Descrip: Replace member variable score
841 * For use principly by API functions
842 *
843 *
844 * Arg: obj [UNKN ] Object holding the variable [PackAlnUnit *]
845 * Arg: score [OWNER] New value of the variable [int]
846 *
847 * Return [SOFT ] member variable score [boolean]
848 *
849 */
replace_score_PackAlnUnit(PackAlnUnit * obj,int score)850 boolean replace_score_PackAlnUnit(PackAlnUnit * obj,int score)
851 {
852 if( obj == NULL) {
853 warn("In replacement function score for object PackAlnUnit, got a NULL object");
854 return FALSE;
855 }
856 obj->score = score;
857 return TRUE;
858 }
859
860
861 /* Function: access_score_PackAlnUnit(obj)
862 *
863 * Descrip: Access member variable score
864 * For use principly by API functions
865 *
866 *
867 * Arg: obj [UNKN ] Object holding the variable [PackAlnUnit *]
868 *
869 * Return [SOFT ] member variable score [int]
870 *
871 */
access_score_PackAlnUnit(PackAlnUnit * obj)872 int access_score_PackAlnUnit(PackAlnUnit * obj)
873 {
874 if( obj == NULL) {
875 warn("In accessor function score for object PackAlnUnit, got a NULL object");
876 return 0;
877 }
878 return obj->score;
879 }
880
881
882
883 #ifdef _cplusplus
884 }
885 #endif
886