source: tags/ms_r16q3/SECEDIT/SEC_drawn_pos.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_drawn_pos.hxx                                 //
4//   Purpose   : store all drawn positions                         //
5//                                                                 //
6//   Coded by Ralf Westram (coder@reallysoft.de) in August 2007    //
7//   Institute of Microbiology (Technical University Munich)       //
8//   http://www.arb-home.de/                                       //
9//                                                                 //
10// =============================================================== //
11
12#ifndef SEC_DRAWN_POS_HXX
13#define SEC_DRAWN_POS_HXX
14
15#ifndef _GLIBCXX_MAP
16#include <map>
17#endif
18#ifndef AW_POSITION_HXX
19#include <aw_position.hxx>
20#endif
21
22using namespace AW;
23
24typedef std::map<size_t, Position> PosMap;
25
26class SEC_drawn_positions : virtual Noncopyable {
27    PosMap drawnAt;
28
29public:
30    void clear() { drawnAt.clear(); }
31    void announce(size_t abs, const Position& drawn) { drawnAt[abs] = drawn; }
32
33    bool empty() const { return drawnAt.empty(); }
34    const PosMap::const_iterator begin() const { return drawnAt.begin(); }
35    const PosMap::const_iterator end() const { return drawnAt.end(); }
36
37    const Position *drawn_at(size_t abs) const {
38        PosMap::const_iterator found = drawnAt.find(abs);
39        return (found == drawnAt.end()) ? 0 : &(found->second);
40    }
41
42    const Position& drawn_before(size_t abspos, size_t *before_abs) const {
43        sec_assert(!empty());
44        PosMap::const_iterator found = drawnAt.lower_bound(abspos); // first pos which is >= abs
45
46        if (found == drawnAt.end() || --found == drawnAt.end()) {
47            found = ++drawnAt.rbegin().base();
48        }
49
50        if (before_abs) *before_abs = found->first;
51        return *&found->second;
52    }
53
54    const Position& drawn_after(size_t abspos, size_t *after_abs) const {
55        sec_assert(!empty());
56        PosMap::const_iterator found = drawnAt.upper_bound(abspos); // first pos which is > abspos
57
58        if (found == drawnAt.end()) { // no position drawn behind abs
59            found = drawnAt.begin(); // wrap to start
60        }
61
62        if (after_abs) *after_abs = found->first;
63        return *&found->second;
64    }
65
66    const Position& drawn_at_or_after(size_t abspos) const {
67        const Position *at = drawn_at(abspos);
68        return at ? *at : drawn_after(abspos, 0);
69    }
70
71};
72
73
74#else
75#error SEC_drawn_pos.hxx included twice
76#endif // SEC_DRAWN_POS_HXX
Note: See TracBrowser for help on using the repository browser.