X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=bindings%2Fcxx%2Finclude%2Flibsigrok%2Flibsigrok.hpp;h=cc57d1a026cd3e470789873fc60a233188b6a578;hb=6e5240f418a8e021a8d1272b6255a8c0f10b5af6;hp=ad683218a384820766be27d5ee6e74b9affc199d;hpb=70d3b20ba6189093c3a18473b3376644683f729d;p=libsigrok.git diff --git a/bindings/cxx/include/libsigrok/libsigrok.hpp b/bindings/cxx/include/libsigrok/libsigrok.hpp index ad683218..cc57d1a0 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; @@ -283,8 +290,8 @@ protected: /** A generic device, either hardware or virtual */ class SR_API Device : - public Configurable, - public StructureWrapper + public enable_shared_from_this, + public Configurable { public: /** Description identifying this device. */ @@ -307,6 +314,7 @@ protected: Device(struct sr_dev_inst *structure); ~Device(); shared_ptr get_channel(struct sr_channel *ptr); + struct sr_dev_inst *structure; map channels; map channel_groups; /** Deleter needed to allow shared_ptr use with protected destructor. */ @@ -324,7 +332,9 @@ protected: }; /** A real hardware device, connected via a driver */ -class SR_API HardwareDevice : public Device +class SR_API HardwareDevice : + public StructureWrapper, + public Device { public: /** Driver providing this device. */ @@ -724,51 +734,70 @@ 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 StructureWrapper, + 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 {