| 1 | // ============================================================= // |
|---|
| 2 | // // |
|---|
| 3 | // File : recmac.hxx // |
|---|
| 4 | // Purpose : // |
|---|
| 5 | // // |
|---|
| 6 | // Coded by Ralf Westram (coder@reallysoft.de) in April 2012 // |
|---|
| 7 | // Institute of Microbiology (Technical University Munich) // |
|---|
| 8 | // http://www.arb-home.de/ // |
|---|
| 9 | // // |
|---|
| 10 | // ============================================================= // |
|---|
| 11 | |
|---|
| 12 | #ifndef AW_MACRO_HXX |
|---|
| 13 | #define AW_MACRO_HXX |
|---|
| 14 | |
|---|
| 15 | #ifndef ARBTOOLS_H |
|---|
| 16 | #include <arbtools.h> |
|---|
| 17 | #endif |
|---|
| 18 | #ifndef AW_AWAR_HXX |
|---|
| 19 | #include "aw_awar.hxx" |
|---|
| 20 | #endif |
|---|
| 21 | |
|---|
| 22 | #define ma_assert(bed) arb_assert(bed) |
|---|
| 23 | |
|---|
| 24 | class RecordingMacro : virtual Noncopyable { |
|---|
| 25 | char *stop_action_name; |
|---|
| 26 | char *application_id; |
|---|
| 27 | |
|---|
| 28 | char *path; |
|---|
| 29 | FILE *out; |
|---|
| 30 | |
|---|
| 31 | GB_ERROR error; |
|---|
| 32 | |
|---|
| 33 | void write(char ch) const { fputc(ch, out); } |
|---|
| 34 | void write(const char *text) const { fputs(text, out); } |
|---|
| 35 | |
|---|
| 36 | void write_as_perl_string(const char *value) const; |
|---|
| 37 | void write_dated_comment(const char *what) const; |
|---|
| 38 | |
|---|
| 39 | void flush() const { fflush(out); } |
|---|
| 40 | |
|---|
| 41 | void post_process(); |
|---|
| 42 | |
|---|
| 43 | public: |
|---|
| 44 | RecordingMacro(const char *filename, const char *application_id_, const char *stop_action_name_, bool expand_existing); |
|---|
| 45 | ~RecordingMacro() { |
|---|
| 46 | ma_assert(!out); // forgot to call stop() |
|---|
| 47 | free(path); |
|---|
| 48 | free(application_id); |
|---|
| 49 | free(stop_action_name); |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | GB_ERROR has_error() const { return error; } |
|---|
| 53 | |
|---|
| 54 | void track_action(const char *action_id); |
|---|
| 55 | void track_awar_change(AW_awar *awar); |
|---|
| 56 | |
|---|
| 57 | void write_action(const char *app_id, const char *action_name); |
|---|
| 58 | void write_awar_change(const char *app_id, const char *awar_name, const char *content); |
|---|
| 59 | |
|---|
| 60 | void write_planned_interruption(const char *displayed_text); |
|---|
| 61 | |
|---|
| 62 | GB_ERROR stop(); |
|---|
| 63 | }; |
|---|
| 64 | |
|---|
| 65 | void warn_unrecordable(const char *what); |
|---|
| 66 | |
|---|
| 67 | #else |
|---|
| 68 | #error AW_macro.hxx included twice |
|---|
| 69 | #endif // AW_MACRO_HXX |
|---|