Introduce OutputFlag

This commit is contained in:
Soeren Apel 2015-08-15 23:40:29 +02:00 committed by Uwe Hermann
parent 7df31ae897
commit 3cd4b38174
19 changed files with 54 additions and 1 deletions

View File

@ -1573,6 +1573,11 @@ shared_ptr<Output> 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<OutputFormat> format,
shared_ptr<Device> device, map<string, Glib::VariantBase> options) :
UserOwned(sr_output_new(format->_structure,

View File

@ -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)

View File

@ -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> device,
map<string, Glib::VariantBase> options =
map<string, Glib::VariantBase>());
/**
* 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();

View File

@ -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;

View File

@ -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);

View File

@ -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.

View File

@ -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,

View File

@ -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,

View File

@ -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,
};

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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.

View File

@ -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,

View File

@ -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,

View File

@ -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,