]> sigrok.org Git - libsigrok.git/blobdiff - bindings/cxx/include/libsigrokcxx/libsigrokcxx.hpp
C++: Declare std::default_delete friend as struct
[libsigrok.git] / bindings / cxx / include / libsigrokcxx / libsigrokcxx.hpp
index a74bbfcfa5002ba665e747c17edd4f3235125710..d8cf3bdc3f62b449e18bf58ad25968ea8f096ffa 100644 (file)
@@ -71,7 +71,12 @@ raised, which provides access to the error code and description.
 #define LIBSIGROKCXX_HPP
 
 #include <libsigrok/libsigrok.h>
+
+/* Suppress warnings due to glibmm's use of std::auto_ptr<> in a public
+ * header file. To be removed once glibmm is fixed. */
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 #include <glibmm.h>
+G_GNUC_END_IGNORE_DEPRECATIONS
 
 #include <stdexcept>
 #include <memory>
@@ -269,15 +274,15 @@ public:
        shared_ptr<Packet> create_header_packet(Glib::TimeVal start_time);
        /** Create a meta packet. */
        shared_ptr<Packet> create_meta_packet(
-               const map<const ConfigKey *, Glib::VariantBase> &config);
+               map<const ConfigKey *, Glib::VariantBase> config);
        /** Create a logic packet. */
        shared_ptr<Packet> create_logic_packet(
                void *data_pointer, size_t data_length, unsigned int unit_size);
        /** Create an analog packet. */
        shared_ptr<Packet> create_analog_packet(
-               const vector<shared_ptr<Channel> > &channels,
+               vector<shared_ptr<Channel> > channels,
                float *data_pointer, unsigned int num_samples, const Quantity *mq,
-               const Unit *unit, const vector<const QuantityFlag *> &mqflags);
+               const Unit *unit, vector<const QuantityFlag *> mqflags);
        /** Load a saved session.
         * @param filename File name string. */
        shared_ptr<Session> load_session(string filename);
@@ -302,7 +307,7 @@ private:
        ~Context();
        friend class Session;
        friend class Driver;
-       friend class std::default_delete<Context>;
+       friend struct std::default_delete<Context>;
 };
 
 enum Capability {
@@ -326,7 +331,7 @@ public:
         * @param key ConfigKey to enumerate values for. */
        Glib::VariantContainerBase config_list(const ConfigKey *key) const;
        /** Enumerate available keys, according to a given index key. */
-       map<const ConfigKey *, set<Capability> > config_keys(const ConfigKey *key);
+       map<const ConfigKey *, set<enum Capability> > config_keys(const ConfigKey *key);
        /** Check for a key in the list from a given index key. */
        bool config_check(const ConfigKey *key, const ConfigKey *index_key) const;
 protected:
@@ -352,8 +357,8 @@ public:
        string long_name() const;
        /** Scan for devices and return a list of devices found.
         * @param options Mapping of (ConfigKey, value) pairs. */
-       vector<shared_ptr<HardwareDevice> > scan(
-               const map<const ConfigKey *, Glib::VariantBase> &options = {});
+       vector<shared_ptr<HardwareDevice> > scan(map<const ConfigKey *, Glib::VariantBase>
+                       options = map<const ConfigKey *, Glib::VariantBase>());
 private:
        struct sr_dev_driver *_structure;
        bool _initialized;
@@ -363,7 +368,7 @@ private:
        friend class Context;
        friend class HardwareDevice;
        friend class ChannelGroup;
-       friend class std::default_delete<Driver>;
+       friend struct std::default_delete<Driver>;
 };
 
 /** A generic device, either hardware or virtual */
@@ -404,7 +409,7 @@ private:
        friend class ChannelGroup;
        friend class Output;
        friend class Analog;
-       friend class std::default_delete<Device>;
+       friend struct std::default_delete<Device>;
 };
 
 /** A real hardware device, connected via a driver */
@@ -423,7 +428,7 @@ private:
 
        friend class Driver;
        friend class ChannelGroup;
-       friend class std::default_delete<HardwareDevice>;
+       friend struct std::default_delete<HardwareDevice>;
 };
 
 /** A virtual device, created by the user */
@@ -440,7 +445,7 @@ private:
        shared_ptr<Device> get_shared_from_this();
 
        friend class Context;
-       friend class std::default_delete<UserDevice>;
+       friend struct std::default_delete<UserDevice>;
 };
 
 /** A channel on a device */
@@ -473,7 +478,7 @@ private:
        friend class Session;
        friend class TriggerStage;
        friend class Context;
-       friend class std::default_delete<Channel>;
+       friend struct std::default_delete<Channel>;
 };
 
 /** A group of channels on a device, which share some configuration */
@@ -491,7 +496,7 @@ private:
        ~ChannelGroup();
        vector<Channel *> _channels;
        friend class Device;
-       friend class std::default_delete<ChannelGroup>;
+       friend struct std::default_delete<ChannelGroup>;
 };
 
 /** A trigger configuration */
@@ -512,7 +517,7 @@ private:
        vector<unique_ptr<TriggerStage> > _stages;
        friend class Context;
        friend class Session;
-       friend class std::default_delete<Trigger>;
+       friend struct std::default_delete<Trigger>;
 };
 
 /** A stage in a trigger configuration */
@@ -539,7 +544,7 @@ private:
        explicit TriggerStage(struct sr_trigger_stage *structure);
        ~TriggerStage();
        friend class Trigger;
-       friend class std::default_delete<TriggerStage>;
+       friend struct std::default_delete<TriggerStage>;
 };
 
 /** A match condition in a trigger configuration  */
@@ -559,7 +564,7 @@ private:
        struct sr_trigger_match *_structure;
        shared_ptr<Channel> _channel;
        friend class TriggerStage;
-       friend class std::default_delete<TriggerMatch>;
+       friend struct std::default_delete<TriggerMatch>;
 };
 
 /** Type of session stopped callback */
@@ -594,7 +599,7 @@ private:
        shared_ptr<Device> get_shared_from_this();
 
        friend class Session;
-       friend class std::default_delete<SessionDevice>;
+       friend struct std::default_delete<SessionDevice>;
 };
 
 /** A sigrok session */
@@ -649,7 +654,7 @@ private:
        friend class Context;
        friend class DatafeedCallbackData;
        friend class SessionDevice;
-       friend class std::default_delete<Session>;
+       friend struct std::default_delete<Session>;
 };
 
 /** A packet on the session datafeed */
@@ -676,7 +681,7 @@ private:
        friend class Logic;
        friend class Analog;
        friend class Context;
-       friend class std::default_delete<Packet>;
+       friend struct std::default_delete<Packet>;
 };
 
 /** Abstract base class for datafeed packet payloads */
@@ -690,7 +695,7 @@ private:
 
        friend class Packet;
        friend class Output;
-       friend class std::default_delete<PacketPayload>;
+       friend struct std::default_delete<PacketPayload>;
 };
 
 /** Payload of a datafeed header packet */
@@ -798,7 +803,8 @@ public:
        map<string, shared_ptr<Option> > options();
        /** Create an input using this input format.
         * @param options Mapping of (option name, value) pairs. */
-       shared_ptr<Input> create_input(const map<string, Glib::VariantBase> &options = {});
+       shared_ptr<Input> create_input(map<string, Glib::VariantBase>
+                       options = map<string, Glib::VariantBase>());
 private:
        explicit InputFormat(const struct sr_input_module *structure);
        ~InputFormat();
@@ -807,7 +813,7 @@ private:
 
        friend class Context;
        friend class InputDevice;
-       friend class std::default_delete<InputFormat>;
+       friend struct std::default_delete<InputFormat>;
 };
 
 /** An input instance (an input format applied to a file or stream) */
@@ -831,7 +837,7 @@ private:
 
        friend class Context;
        friend class InputFormat;
-       friend class std::default_delete<Input>;
+       friend struct std::default_delete<Input>;
 };
 
 /** A virtual device associated with an input */
@@ -845,7 +851,7 @@ private:
        shared_ptr<Device> get_shared_from_this();
        shared_ptr<Input> _input;
        friend class Input;
-       friend class std::default_delete<InputDevice>;
+       friend struct std::default_delete<InputDevice>;
 };
 
 /** An option used by an output format */
@@ -871,7 +877,7 @@ private:
 
        friend class InputFormat;
        friend class OutputFormat;
-       friend class std::default_delete<Option>;
+       friend struct std::default_delete<Option>;
 };
 
 /** An output format supported by the library */
@@ -891,16 +897,15 @@ public:
        /** Create an output using this format.
         * @param device Device to output for.
         * @param options Mapping of (option name, value) pairs. */
-       shared_ptr<Output> create_output(
-               shared_ptr<Device> device,
-               const map<string, Glib::VariantBase> &options = {});
+       shared_ptr<Output> create_output(shared_ptr<Device> device,
+               map<string, Glib::VariantBase> options = map<string, Glib::VariantBase>());
        /** Create an output using this format.
         * @param filename Name of destination file.
         * @param device Device to output for.
         * @param options Mapping of (option name, value) pairs. */
        shared_ptr<Output> create_output(string filename,
                shared_ptr<Device> device,
-               const map<string, Glib::VariantBase> &options = {});
+               map<string, Glib::VariantBase> options = map<string, Glib::VariantBase>());
        /**
         * Checks whether a given flag is set.
         * @param flag Flag to check
@@ -916,7 +921,7 @@ private:
 
        friend class Context;
        friend class Output;
-       friend class std::default_delete<OutputFormat>;
+       friend struct std::default_delete<OutputFormat>;
 };
 
 /** An output instance (an output format applied to a device) */
@@ -929,9 +934,9 @@ public:
 private:
        Output(shared_ptr<OutputFormat> format, shared_ptr<Device> device);
        Output(shared_ptr<OutputFormat> format,
-               shared_ptr<Device> device, const map<string, Glib::VariantBase> &options);
+               shared_ptr<Device> device, map<string, Glib::VariantBase> options);
        Output(string filename, shared_ptr<OutputFormat> format,
-               shared_ptr<Device> device, const map<string, Glib::VariantBase> &options);
+               shared_ptr<Device> device, map<string, Glib::VariantBase> options);
        ~Output();
 
        const struct sr_output *_structure;
@@ -940,7 +945,7 @@ private:
        const map<string, Glib::VariantBase> _options;
 
        friend class OutputFormat;
-       friend class std::default_delete<Output>;
+       friend struct std::default_delete<Output>;
 };
 
 /** Base class for objects which wrap an enumeration value from libsigrok */
@@ -986,8 +991,8 @@ private:
        const string _name;
 };
 
-#include <libsigrokcxx/enums.hpp>
-
 }
 
+#include <libsigrokcxx/enums.hpp>
+
 #endif