source: tags/ms_r16q3/ARBDB/gb_aci.h

Last change on this file was 11080, checked in by westram, 10 years ago
File size: 2.7 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : gb_aci.h                                          //
4//   Purpose   :                                                   //
5//                                                                 //
6//   Institute of Microbiology (Technical University Munich)       //
7//   http://www.arb-home.de/                                       //
8//                                                                 //
9// =============================================================== //
10
11#ifndef GB_ACI_H
12#define GB_ACI_H
13
14#ifndef ARBDBT_H
15#include "arbdbt.h"
16#endif
17#ifndef _GLIBCXX_VECTOR
18#include <vector>
19#endif
20
21#define gb_assert(cond) arb_assert(cond)
22
23typedef SmartMallocPtr(char) GBL;
24
25class GBL_reference {
26    GBDATA     *gb_ref;            // the database entry on which the command is applied (may be species, gene, experiment, group and maybe more)
27    const char *default_tree_name; // if we have a default tree, its name is specified here (NULL otherwise)
28
29public:
30    GBL_reference(GBDATA *gbd, const char *treeName)
31        : gb_ref(gbd), default_tree_name(treeName) {}
32
33    GBDATA *get_main() const { return GB_get_root(gb_ref); }
34    GBDATA *get_ref() const { return gb_ref; }
35    const char *get_tree_name() const { return default_tree_name; }
36};
37
38class GBL_streams {
39    std::vector<GBL> content;
40
41public:
42    void insert(char *copy) { content.push_back(copy); }
43    void insert(GBL smartie) { content.push_back(smartie); }
44    const char *get(int idx) const { gb_assert(idx<size()); return &*content[idx]; }
45    GBL get_smart(int idx) const { gb_assert(idx<size()); return content[idx]; }
46    int size() const { return content.size(); }
47
48    void erase() { content.clear(); }
49
50    char *concatenated() const;
51    void swap(GBL_streams& other) { std::swap(content, other.content); }
52};
53
54struct GBL_command_arguments : public GBL_reference {
55    GBL_command_arguments(GBDATA       *gbd,
56                          const char   *treeName,
57                          GBL_streams&  input_,
58                          GBL_streams&  param_,
59                          GBL_streams&  output_)
60        : GBL_reference(gbd, treeName),
61          input(input_),
62          param(param_),
63          output(output_)
64    {}
65
66    const char *command; // the name of the current command
67
68    GBL_streams &input;
69    GBL_streams &param;
70    GBL_streams &output;
71};
72
73typedef GB_ERROR (*GBL_COMMAND)(GBL_command_arguments *args);
74
75struct GBL_command_table {
76    const char *command_identifier;
77    GBL_COMMAND function;
78};
79
80#else
81#error gb_aci.h included twice
82#endif // GB_ACI_H
83
84
Note: See TracBrowser for help on using the repository browser.