source: branches/profile/NALIGNER/ali_sequence.hxx

Last change on this file was 7623, checked in by westram, 13 years ago
  • merge from dev [7450] [7452] [7456] [7457] [7458] [7459] [7460] [7461] [7464] [7465] [7466] [7467] [7468] [7469] [7482]
    • tweaked compiler options
      • activated -Weffc++
        • postfilter warnings where Scott Meyers' advices are too general.
          • base classes should not always have virtual destructors, since that renders tiny classes useless and
          • members should not always be initialized via initialization list, since that often violates the DRY principle
        • fix gcc's inability to detect that Noncopyable implements a private copy-ctor and op=
        • this slows down complete ARB recompilation by ~5%
    • added -Wold-style-cast (inactive)
    • removed -Wno-non-template-friend added in [7447]
  • postcompile.pl
    • added option —original to show unmodified compiler output
  • declared op= for classes which had a copy-ctor
  • moved op= macros to arbtools.h
  • derived classes containing pointers from Noncopyable (use Noncopyable virtually) or
  • made them copyable if needed (awt_mask_item, KnownDB, Code, AWT_registered_itemtype, GEN_gene, PosGene, PartialSequence, PlugIn, Range, Convaln_exception)
  • other related changes
    • user mask destruction working now
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : ali_sequence.hxx                                  //
4//   Purpose   :                                                   //
5//                                                                 //
6//   Institute of Microbiology (Technical University Munich)       //
7//   http://www.arb-home.de/                                       //
8//                                                                 //
9// =============================================================== //
10
11#ifndef ALI_SEQUENCE_HXX
12#define ALI_SEQUENCE_HXX
13
14#ifndef _GLIBCXX_CSTRING
15#include <cstring>
16#endif
17#ifndef ALI_MISC_HXX
18#include "ali_misc.hxx"
19#endif
20
21
22class ALI_SEQUENCE : virtual Noncopyable {
23    unsigned char *seq;
24    char *seq_name;
25    unsigned long seq_len;
26public:
27    ALI_SEQUENCE(char *Name, char *str) {
28        seq = (unsigned char *) str;
29        seq_len = strlen(str);
30        seq_name = strdup(Name);
31        ali_string_to_sequence(str);
32        if (seq_name == 0) ali_fatal_error("Out of memory");
33    }
34    ALI_SEQUENCE(char *Name, unsigned char *str, unsigned long str_len) {
35        seq = str;
36        seq_len = str_len;
37        seq_name = strdup(Name);
38    }
39    ~ALI_SEQUENCE() {
40        if (seq)
41            free((char *) seq);
42        if (seq_name)
43            free((char *) seq_name);
44    }
45    unsigned char *sequence() {
46        return seq;
47    }
48    unsigned char base(unsigned long position) {
49        return seq[position];
50    }
51    int check();
52    char *string();
53    char *name() {
54        return seq_name;
55    }
56    unsigned long length() {
57        return seq_len;
58    }
59};
60
61
62class ALI_NORM_SEQUENCE : virtual Noncopyable {
63    unsigned char *seq;
64    char *seq_name;
65    unsigned char **dots;
66    unsigned long seq_len;
67public:
68    ALI_NORM_SEQUENCE(char *name, char *str);
69    ALI_NORM_SEQUENCE(ALI_SEQUENCE *sequence);
70    ~ALI_NORM_SEQUENCE() {
71        if (seq)
72            free((char *) seq);
73        if (seq_name)
74            free((char *) seq_name);
75        if (dots)
76            free((char *) dots);
77    }
78    unsigned char *sequence() {
79        return seq;
80    }
81    unsigned char base(unsigned long position) {
82        return seq[position];
83    }
84    char *string();
85    char *name() {
86        return seq_name;
87    }
88    unsigned long length() {
89        return seq_len;
90    }
91    int is_begin(unsigned long pos) {
92        if (dots == 0)
93            return 0;
94        else {
95            if (pos > seq_len)
96                return 1;
97            else
98                return (((*dots)[pos/8] & (unsigned char) (1<<(7-(pos%8)))) != 0);
99        }
100    }
101};
102
103#else
104#error ali_sequence.hxx included twice
105#endif // ALI_SEQUENCE_HXX
Note: See TracBrowser for help on using the repository browser.