ARB
calculator.h
Go to the documentation of this file.
1 // ========================================================= //
2 // //
3 // File : calculator.h //
4 // Purpose : perform SAI calculation //
5 // //
6 // Coded by Ralf Westram (coder@reallysoft.de) in Dec 19 //
7 // http://www.arb-home.de/ //
8 // //
9 // ========================================================= //
10 
11 #ifndef CALCULATOR_H
12 #define CALCULATOR_H
13 
14 #ifndef SAIOP_H
15 #include "saiop.h"
16 #endif
17 #ifndef ARBDB_H
18 #include <arbdb.h>
19 #endif
20 
22  SAS_SELECTED, // apply to selected alignment
23  SAS_ALL, // apply to all existing alignments
24  SAS_COMMON, // all alignments common for all input SAI
25  SAS_TARGET, // existing target alignments
26  // (avoid changing order! int is saved to config)
27 };
28 
29 class SaiCalculator : virtual Noncopyable {
30  GBDATA *gb_main;
31  const CharPtrArray& inputSaiNames;
32  const SaiOperator& op;
33  const char *outSaiName;
34  SaiAliScope scope;
35  ARB_ERROR error;
36 
37  void run();
38  void calc4ali(const char *ali, GBDATA *gb_target_sai);
39  bool allSaiHaveDataInAlignment(const char *ali);
40 
41 public:
42  SaiCalculator(GBDATA *gb_main_, const CharPtrArray& inputSaiNames_, const SaiOperator& op_, const char *outSaiName_, SaiAliScope scope_) :
43  gb_main(gb_main_),
44  inputSaiNames(inputSaiNames_),
45  op(op_),
46  outSaiName(outSaiName_),
47  scope(scope_)
48  {
49  GB_transaction ta(gb_main);
50  run();
51  error = ta.close(error);
52  }
53 
54  bool hasError() const {
55  if (error) return true;
56  error.expect_no_error();
57  return false;
58  }
59  ARB_ERROR getError() const {
60  return error;
61  }
62 };
63 
64 
65 #else
66 #error calculator.h included twice
67 #endif // CALCULATOR_H
bool hasError() const
Definition: calculator.h:54
SaiCalculator(GBDATA *gb_main_, const CharPtrArray &inputSaiNames_, const SaiOperator &op_, const char *outSaiName_, SaiAliScope scope_)
Definition: calculator.h:42
ARB_ERROR getError() const
Definition: calculator.h:59
void expect_no_error() const
Definition: arb_error.h:136
SaiAliScope
Definition: calculator.h:21
GB_ERROR close(GB_ERROR error)
Definition: arbdbpp.cxx:32
GB_transaction ta(gb_var)