source: tags/ms_r16q2/SECEDIT/SEC_abspos.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.5 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : sec_abspos.hxx                                    //
4//   Purpose   : Encapsulates helix position access                //
5//                                                                 //
6//   Coded by Ralf Westram (coder@reallysoft.de) in July 2007      //
7//   Institute of Microbiology (Technical University Munich)       //
8//   http://www.arb-home.de/                                       //
9//                                                                 //
10// =============================================================== //
11
12#ifndef SEC_ABSPOS_HXX
13#define SEC_ABSPOS_HXX
14
15#ifndef _GLIBCXX_CSTDIO
16#include <cstdio>
17#endif
18#ifndef ARBTOOLS_H
19#include <arbtools.h>
20#endif
21
22#ifndef SEC_DEFS_HXX
23#include "SEC_defs.hxx"
24#endif
25
26
27class XString : virtual Noncopyable {
28    char   *x_string;
29    size_t  x_string_len;
30
31    int x_count;                // number of 'x's found in x_string
32
33    size_t *abspos;             // contains absolute positions for all 'x's in 'x_string'
34    int    *number_found;       // for each absolute position P, contains number of 'x's from start of sequence till P-1
35
36    bool initialized;           // true if initialize called
37
38    void set_length(size_t len); // dealloc internal array if length grows
39
40    void addX(size_t abs_pos) { // add an X at pos
41        initialized   = false;
42        sec_assert(abs_pos<x_string_len);
43        x_string[abs_pos] = 'x';
44    }
45
46public:
47    XString(size_t ali_length);
48    XString(const char *saved_x_string, size_t saved_len, size_t ali_length);
49    ~XString();
50
51    void initialize();          // builds all internal data from x_string
52
53    int getXcount() const {
54        sec_assert(initialized);
55        return x_count;
56    }
57    size_t getLength() const { return x_string_len; }
58
59    size_t getAbsPos(int x) const; // gets absolute position of a 'x'
60    int getXleftOf(size_t abspos) const; // gets the number of 'x's left of sequence pos
61
62    void addXpair(size_t start, size_t end) {
63#if defined(DEBUG) && 0
64        printf("addXpair(%u, %u)\n", start, end);
65#endif // DEBUG
66        addX(start);
67        addX(end);
68    }
69
70    const char *get_x_string() const; // version saved to DB
71    bool alignment_too_short() const { return x_string[x_string_len-1] == 'x'; }
72    size_t get_x_string_length() const { return getLength() - (alignment_too_short() ? 0 : 1); } // version saved to DB
73};
74
75#else
76#error sec_abspos.hxx included twice
77#endif // SEC_ABSPOS_HXX
Note: See TracBrowser for help on using the repository browser.