From: Soeren Apel Date: Sat, 15 Aug 2015 21:40:29 +0000 (+0200) Subject: Introduce OutputFlag X-Git-Tag: libsigrok-0.4.0~446 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=3cd4b381744eb88fd4ba32565bd408c33b431629;p=libsigrok.git Introduce OutputFlag --- diff --git a/bindings/cxx/classes.cpp b/bindings/cxx/classes.cpp index 357c9d6f..f8a02314 100644 --- a/bindings/cxx/classes.cpp +++ b/bindings/cxx/classes.cpp @@ -1573,6 +1573,11 @@ shared_ptr OutputFormat::create_output(string filename, Output::Deleter()); } +bool OutputFormat::test_flag(const OutputFlag *flag) +{ + return sr_output_test_flag(_structure, flag->id()); +} + Output::Output(shared_ptr format, shared_ptr device, map options) : UserOwned(sr_output_new(format->_structure, diff --git a/bindings/cxx/enums.py b/bindings/cxx/enums.py index aed42120..90120d7f 100644 --- a/bindings/cxx/enums.py +++ b/bindings/cxx/enums.py @@ -40,7 +40,8 @@ mapping = dict([ ('sr_configkey', ('ConfigKey', 'Configuration key')), ('sr_datatype', ('DataType', 'Configuration data type')), ('sr_channeltype', ('ChannelType', 'Channel type')), - ('sr_trigger_matches', ('TriggerMatchType', 'Trigger match type'))]) + ('sr_trigger_matches', ('TriggerMatchType', 'Trigger match type')), + ('sr_output_flag', ('OutputFlag', 'Flag applied to output modules'))]) index = ElementTree.parse(index_file) diff --git a/bindings/cxx/include/libsigrokcxx/libsigrokcxx.hpp b/bindings/cxx/include/libsigrokcxx/libsigrokcxx.hpp index 9bc9cdaa..e1e8d7b9 100644 --- a/bindings/cxx/include/libsigrokcxx/libsigrokcxx.hpp +++ b/bindings/cxx/include/libsigrokcxx/libsigrokcxx.hpp @@ -96,6 +96,7 @@ class SR_API Session; class SR_API ConfigKey; class SR_API InputFormat; class SR_API OutputFormat; +class SR_API OutputFlag; class SR_API LogLevel; class SR_API ChannelGroup; class SR_API Trigger; @@ -969,6 +970,13 @@ public: shared_ptr device, map options = map()); + /** + * Checks whether a given flag is set. + * @param flag Flag to check + * @return true if flag is set for this module + * @see sr_output_flags + */ + bool test_flag(const OutputFlag *flag); protected: OutputFormat(const struct sr_output_module *structure); ~OutputFormat(); diff --git a/include/libsigrok/libsigrok.h b/include/libsigrok/libsigrok.h index 356739cc..085ac061 100644 --- a/include/libsigrok/libsigrok.h +++ b/include/libsigrok/libsigrok.h @@ -518,6 +518,12 @@ struct sr_option { GSList *values; }; +/** Output module flags. */ +enum sr_output_flag { + /** If set, this output module writes the output itself. */ + SR_OUTPUT_INTERNAL_IO_HANDLING = 0x01, +}; + struct sr_input; struct sr_input_module; struct sr_output; diff --git a/include/libsigrok/proto.h b/include/libsigrok/proto.h index 788f80de..1aa2ee76 100644 --- a/include/libsigrok/proto.h +++ b/include/libsigrok/proto.h @@ -155,6 +155,8 @@ SR_API const char *const *sr_input_extensions_get( const struct sr_input_module *imod); SR_API const struct sr_input_module *sr_input_find(char *id); SR_API const struct sr_option **sr_input_options_get(const struct sr_input_module *imod); +SR_API gboolean sr_output_test_flag(const struct sr_output_module *omod, + uint64_t flag); SR_API void sr_input_options_free(const struct sr_option **options); SR_API struct sr_input *sr_input_new(const struct sr_input_module *imod, GHashTable *options); diff --git a/src/libsigrok-internal.h b/src/libsigrok-internal.h index 3ab181b3..b127d0ef 100644 --- a/src/libsigrok-internal.h +++ b/src/libsigrok-internal.h @@ -412,6 +412,13 @@ struct sr_output_module { */ const char *const *exts; + /** + * Bitfield containing flags that describe certain properties + * this output module may or may not have. + * @see sr_output_flags + */ + const uint64_t flags; + /** * Returns a NULL-terminated list of options this module can take. * Can be NULL, if the module has no options. diff --git a/src/output/analog.c b/src/output/analog.c index 406d8c6e..ff5e91f3 100644 --- a/src/output/analog.c +++ b/src/output/analog.c @@ -345,6 +345,7 @@ SR_PRIV struct sr_output_module output_analog = { .name = "Analog", .desc = "Analog data and types", .exts = NULL, + .flags = 0, .options = get_options, .init = init, .receive = receive, diff --git a/src/output/ascii.c b/src/output/ascii.c index d2ad3aca..e5072416 100644 --- a/src/output/ascii.c +++ b/src/output/ascii.c @@ -253,6 +253,7 @@ SR_PRIV struct sr_output_module output_ascii = { .name = "ASCII", .desc = "ASCII art", .exts = (const char*[]){"txt", NULL}, + .flags = 0, .options = get_options, .init = init, .receive = receive, diff --git a/src/output/binary.c b/src/output/binary.c index 04627f32..4037d9e9 100644 --- a/src/output/binary.c +++ b/src/output/binary.c @@ -47,6 +47,7 @@ SR_PRIV struct sr_output_module output_binary = { .name = "Binary", .desc = "Raw binary", .exts = NULL, + .flags = 0, .options = NULL, .receive = receive, }; diff --git a/src/output/bits.c b/src/output/bits.c index 180ea563..a26424d5 100644 --- a/src/output/bits.c +++ b/src/output/bits.c @@ -239,6 +239,7 @@ SR_PRIV struct sr_output_module output_bits = { .name = "Bits", .desc = "0/1 digits", .exts = (const char*[]){"txt", NULL}, + .flags = 0, .options = get_options, .init = init, .receive = receive, diff --git a/src/output/chronovu_la8.c b/src/output/chronovu_la8.c index 1c0953f7..cfabf4cd 100644 --- a/src/output/chronovu_la8.c +++ b/src/output/chronovu_la8.c @@ -188,6 +188,7 @@ SR_PRIV struct sr_output_module output_chronovu_la8 = { .name = "ChronoVu LA8", .desc = "ChronoVu LA8 native file format", .exts = (const char*[]){"kdt", NULL}, + .flags = 0, .options = NULL, .init = init, .receive = receive, diff --git a/src/output/csv.c b/src/output/csv.c index d947ba2d..5f0d647c 100644 --- a/src/output/csv.c +++ b/src/output/csv.c @@ -333,6 +333,7 @@ SR_PRIV struct sr_output_module output_csv = { .name = "CSV", .desc = "Comma-separated values", .exts = (const char*[]){"csv", NULL}, + .flags = 0, .options = NULL, .init = init, .receive = receive, diff --git a/src/output/gnuplot.c b/src/output/gnuplot.c index 053f0424..fc3c15ac 100644 --- a/src/output/gnuplot.c +++ b/src/output/gnuplot.c @@ -221,6 +221,7 @@ SR_PRIV struct sr_output_module output_gnuplot = { .name = "Gnuplot", .desc = "Gnuplot data file format", .exts = (const char*[]){"dat", NULL}, + .flags = 0, .options = NULL, .init = init, .receive = receive, diff --git a/src/output/hex.c b/src/output/hex.c index bad60751..a499e354 100644 --- a/src/output/hex.c +++ b/src/output/hex.c @@ -253,6 +253,7 @@ SR_PRIV struct sr_output_module output_hex = { .name = "Hexadecimal", .desc = "Hexadecimal digits", .exts = (const char*[]){"txt", NULL}, + .flags = 0, .options = get_options, .init = init, .receive = receive, diff --git a/src/output/ols.c b/src/output/ols.c index bf1aacbd..1202a93e 100644 --- a/src/output/ols.c +++ b/src/output/ols.c @@ -151,6 +151,7 @@ SR_PRIV struct sr_output_module output_ols = { .name = "OLS", .desc = "OpenBench Logic Sniffer", .exts = (const char*[]){"ols", NULL}, + .flags = 0, .options = NULL, .init = init, .receive = receive, diff --git a/src/output/output.c b/src/output/output.c index 04f3054c..d06002e3 100644 --- a/src/output/output.c +++ b/src/output/output.c @@ -156,6 +156,18 @@ SR_API const char *const *sr_output_extensions_get( return omod->exts; } +/* + * Checks whether a given flag is set. + * + * @see sr_output_flag + * @since 0.4.0 + */ +SR_API gboolean sr_output_test_flag(const struct sr_output_module *omod, + uint64_t flag) +{ + return (flag & omod->flags); +} + /** * Return the output module with the specified ID, or NULL if no module * with that id is found. diff --git a/src/output/srzip.c b/src/output/srzip.c index 409421cb..dd493334 100644 --- a/src/output/srzip.c +++ b/src/output/srzip.c @@ -317,6 +317,7 @@ SR_PRIV struct sr_output_module output_srzip = { .name = "srzip", .desc = "srzip session file", .exts = (const char*[]){"sr", NULL}, + .flags = SR_OUTPUT_INTERNAL_IO_HANDLING, .options = get_options, .init = init, .receive = receive, diff --git a/src/output/vcd.c b/src/output/vcd.c index 9d3516b7..7403d575 100644 --- a/src/output/vcd.c +++ b/src/output/vcd.c @@ -264,6 +264,7 @@ struct sr_output_module output_vcd = { .name = "VCD", .desc = "Value Change Dump", .exts = (const char*[]){"vcd", NULL}, + .flags = 0, .options = NULL, .init = init, .receive = receive, diff --git a/src/output/wav.c b/src/output/wav.c index e9c7d6fd..a16f45ea 100644 --- a/src/output/wav.c +++ b/src/output/wav.c @@ -352,6 +352,7 @@ SR_PRIV struct sr_output_module output_wav = { .name = "WAV", .desc = "Microsoft WAV file format", .exts = (const char*[]){"wav", NULL}, + .flags = 0, .options = get_options, .init = init, .receive = receive,