X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=bindings%2Fcxx%2Finclude%2Flibsigrok%2Flibsigrok.hpp;h=546a4502e7fb6fe945c5c2070e01bbe24c13c94a;hb=ca3291e3ee7415c4c4505164ec931b91ea15cefe;hp=ad683218a384820766be27d5ee6e74b9affc199d;hpb=b84cba4dbf2a78806848f9dbaf10238a18daf735;p=libsigrok.git diff --git a/bindings/cxx/include/libsigrok/libsigrok.hpp b/bindings/cxx/include/libsigrok/libsigrok.hpp index ad683218..546a4502 100644 --- a/bindings/cxx/include/libsigrok/libsigrok.hpp +++ b/bindings/cxx/include/libsigrok/libsigrok.hpp @@ -108,7 +108,8 @@ class SR_API PacketType; class SR_API Quantity; class SR_API Unit; class SR_API QuantityFlag; -class SR_API InputFileDevice; +class SR_API Input; +class SR_API InputDevice; class SR_API Output; class SR_API DataType; class SR_API Option; @@ -214,6 +215,12 @@ public: /** Create a new trigger. * @param name Name string for new trigger. */ shared_ptr create_trigger(string name); + /** Open an input file. + * @param filename File name string. */ + shared_ptr open_file(string filename); + /** Open an input stream based on header data. + * @param header Initial data from stream. */ + shared_ptr open_stream(string header); protected: struct sr_context *structure; map drivers; @@ -724,51 +731,68 @@ protected: /** An input format supported by the library */ class SR_API InputFormat : - public StructureWrapper + public StructureWrapper { public: /** Name of this input format. */ string get_name(); /** Description of this input format. */ string get_description(); - /** Check whether a given file matches this input format. - * @param filename File name string. */ - bool format_match(string filename); - /** Open a file using this input format. - * @param filename File name string. - * @param options Mapping of (option name, value) strings. */ - shared_ptr open_file(string filename, - map options = {}); + /** Options supported by this input format. */ + map > get_options(); + /** Create an input using this input format. + * @param options Mapping of (option name, value) pairs. */ + shared_ptr create_input(map options = {}); protected: - InputFormat(struct sr_input_format *structure); + InputFormat(const struct sr_input_module *structure); ~InputFormat(); friend class Context; - friend class InputFileDevice; + friend class InputDevice; }; -/** A virtual device associated with an input file */ -class SR_API InputFileDevice : public Device +/** An input instance (an input format applied to a file or stream) */ +class SR_API Input : public enable_shared_from_this { public: - /** Load data from file. */ - void load(); + /** Virtual device associated with this input. */ + shared_ptr get_device(); + /** Send next stream data. + * @param data Next stream data. */ + void send(string data); protected: - InputFileDevice(shared_ptr format, - struct sr_input *input, string filename); - ~InputFileDevice(); - struct sr_input *input; - shared_ptr format; - string filename; + Input(shared_ptr context, const struct sr_input *structure); + ~Input(); + const struct sr_input *structure; + shared_ptr context; + InputDevice *device; /** Deleter needed to allow shared_ptr use with protected destructor. */ class Deleter { public: - void operator()(InputFileDevice *device) { delete device; } + void operator()(Input *input) { delete input; } }; friend class Deleter; + friend class Context; friend class InputFormat; }; +/** A virtual device associated with an input */ +class SR_API InputDevice : public Device +{ +protected: + InputDevice(shared_ptr input, struct sr_dev_inst *sdi); + ~InputDevice(); + shared_ptr input; + /** Deleter needed to allow shared_ptr use with protected destructor. */ + class Deleter + { + public: + void operator()(InputDevice *device) { delete device; } + }; + friend class Deleter; + friend class Input; +}; + /** An option used by an output format */ class SR_API Option {