1 | #include <memory.h> |
---|
2 | #include <string.h> |
---|
3 | #include <stdio.h> |
---|
4 | |
---|
5 | #include <arbdb.h> |
---|
6 | #include "arbdb++.hxx" |
---|
7 | #include "adtools.hxx" |
---|
8 | |
---|
9 | ADT_SEQUENCE::ADT_SEQUENCE() { |
---|
10 | memset(this,0,sizeof(ADT_SEQUENCE)); |
---|
11 | adt_ali = 0; |
---|
12 | } |
---|
13 | |
---|
14 | ADT_SEQUENCE::~ADT_SEQUENCE() { |
---|
15 | // if (showsequence) delete showsequence; |
---|
16 | } |
---|
17 | |
---|
18 | |
---|
19 | void ADT_SEQUENCE::init(ADT_ALI *adtali,AD_CONT * adcont) { |
---|
20 | adt_ali = adtali; |
---|
21 | AD_SEQ::init(adcont); |
---|
22 | show_timestamp = timestamp; |
---|
23 | |
---|
24 | } |
---|
25 | |
---|
26 | char *ADT_SEQUENCE::show_get() { |
---|
27 | if (adt_ali != 0) { |
---|
28 | if ((seq == 0) || (show_timestamp < timestamp) ) { |
---|
29 | ADT_SEQUENCE::show_update(); |
---|
30 | } |
---|
31 | return seq; |
---|
32 | } |
---|
33 | new AD_ERR("ADT_SEQUENCE::show_get() class not inited ?",CORE); |
---|
34 | return 0; |
---|
35 | } |
---|
36 | |
---|
37 | void ADT_SEQUENCE::show_update() { |
---|
38 | ; |
---|
39 | } |
---|
40 | |
---|
41 | int ADT_SEQUENCE::show_len() { |
---|
42 | return seq_len; |
---|
43 | } |
---|
44 | |
---|
45 | AD_ERR * ADT_SEQUENCE::show_put() { |
---|
46 | AD_ERR * error = 0; |
---|
47 | error = put(); |
---|
48 | if (error != 0) { |
---|
49 | show_update(); |
---|
50 | return error; |
---|
51 | } |
---|
52 | show_timestamp = timestamp; |
---|
53 | return error ; |
---|
54 | } |
---|
55 | |
---|
56 | |
---|
57 | /*** EDITIERFUNKTIONEN *******/ |
---|
58 | // show_insert |
---|
59 | // show_remov5// show_replace |
---|
60 | // |
---|
61 | // beeinflussen nicht seq_len und showseq_len ( -> wird von gaps beeinflusst) |
---|
62 | // seq_len entspricht der alignment laenge |
---|
63 | // das Ende wird mit punkten aufgefuellt |
---|
64 | // |
---|
65 | |
---|
66 | AD_ERR * ADT_SEQUENCE::show_insert(char *text,int showposition) { |
---|
67 | // insert text in showsequenc und seq (AD) |
---|
68 | // funktionen: gap_realpos, |
---|
69 | // nur erlaubt, wenn kein gap dahinter |
---|
70 | AD_ERR *ad_err; |
---|
71 | int realposition = adt_ali->gap_realpos(showposition); // bereich in der richtigen sequence |
---|
72 | if (show_timestamp != timestamp) { |
---|
73 | return new AD_ERR("ADT_SEQUENCE::show_insert -- not allowed -- because timeupdate not done !"); |
---|
74 | } |
---|
75 | if (adt_ali->gap_behind(realposition) == 1) { // kein insert wenn luecke dahinter |
---|
76 | return new AD_ERR("ADT_SEQUENCE::show_insert -- not allowed because Gap behind position"); |
---|
77 | } |
---|
78 | ad_err = this->insert(text,realposition,1); //@@@ insert in blocks !!! |
---|
79 | if (!ad_err){ |
---|
80 | this->show_update(); |
---|
81 | } |
---|
82 | return ad_err; |
---|
83 | } |
---|
84 | |
---|
85 | |
---|
86 | |
---|
87 | AD_ERR * ADT_SEQUENCE::show_remove(int charsToDelete, int showposition) { |
---|
88 | AD_ERR *ad_err; |
---|
89 | int realposition = adt_ali->gap_realpos(showposition); |
---|
90 | if ((realposition < 0) || (charsToDelete<0) || (charsToDelete > seq_len) || (showposition >= seq_len)) { |
---|
91 | return new AD_ERR("ADT_SEQ.remove() WARNING ! Wrong Parameters !"); |
---|
92 | } |
---|
93 | if (adt_ali->gap_behind(realposition) == 1) { // kein remove wenn luecke dahinter |
---|
94 | return new AD_ERR("ADT_SEQUENCE::show_remove -- not allowed because Gap behind position"); |
---|
95 | } |
---|
96 | if (show_timestamp != timestamp) { |
---|
97 | return new AD_ERR("ADT_SEQUENCE::show_remove -- not allowed -- because timeupdate not done !"); |
---|
98 | } |
---|
99 | ad_err = this->remove(charsToDelete,realposition,1); |
---|
100 | if (!ad_err) this->show_update(); |
---|
101 | return ad_err; |
---|
102 | } |
---|
103 | |
---|
104 | |
---|
105 | AD_ERR * ADT_SEQUENCE::show_replace(char *text,int showposition) { |
---|
106 | if (show_timestamp != timestamp) { |
---|
107 | return new AD_ERR("ADT_SEQUENCE::show_replace -- not allowed -- because timeupdate not done !"); |
---|
108 | } |
---|
109 | AD_ERR *ad_err; |
---|
110 | ad_err = this->replace(text,showposition,1); |
---|
111 | if (!ad_err) this->show_update(); |
---|
112 | return ad_err; |
---|
113 | } |
---|
114 | |
---|
115 | AD_ERR *ADT_SEQUENCE::show_command( AW_key_mod keymod, AW_key_code keycode, char key, int direction, long &cursorpos, int& changeflag) |
---|
116 | { |
---|
117 | AD_ERR *err= this->command(keymod,keycode,key,direction, cursorpos,changeflag); |
---|
118 | if (changeflag) this->show_update(); |
---|
119 | return err; |
---|
120 | } |
---|