Fix random clazy warnings
[pulseview.git] / pv / session.hpp
index 5a54d83aa047a0f245457eae0eb8832f67bc98ba..2ee31cfee5afb8ef6de44171322d1d20086e755a 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef PULSEVIEW_PV_SESSION_HPP
 #define PULSEVIEW_PV_SESSION_HPP
 
 #ifndef PULSEVIEW_PV_SESSION_HPP
 #define PULSEVIEW_PV_SESSION_HPP
 
+#include <functional>
 #include <map>
 #include <memory>
 #include <mutex>
 #include <map>
 #include <memory>
 #include <mutex>
@@ -100,6 +101,8 @@ public:
                Running
        };
 
                Running
        };
 
+       static shared_ptr<sigrok::Context> sr_context;
+
 public:
        Session(DeviceManager &device_manager, QString name);
 
 public:
        Session(DeviceManager &device_manager, QString name);
 
@@ -161,6 +164,10 @@ public:
 
        double get_samplerate() const;
 
 
        double get_samplerate() const;
 
+       uint32_t get_segment_count() const;
+
+       vector<util::Timestamp> get_triggers(uint32_t segment_id) const;
+
        void register_view(shared_ptr<views::ViewBase> view);
 
        void deregister_view(shared_ptr<views::ViewBase> view);
        void register_view(shared_ptr<views::ViewBase> view);
 
        void deregister_view(shared_ptr<views::ViewBase> view);
@@ -169,8 +176,10 @@ public:
 
        const unordered_set< shared_ptr<data::SignalBase> > signalbases() const;
 
 
        const unordered_set< shared_ptr<data::SignalBase> > signalbases() const;
 
+       bool all_segments_complete(uint32_t segment_id) const;
+
 #ifdef ENABLE_DECODE
 #ifdef ENABLE_DECODE
-       bool add_decoder(srd_decoder *const dec);
+       shared_ptr<data::DecodeSignal> add_decode_signal();
 
        void remove_decode_signal(shared_ptr<data::DecodeSignal> signal);
 #endif
 
        void remove_decode_signal(shared_ptr<data::DecodeSignal> signal);
 #endif
@@ -187,11 +196,13 @@ private:
                vector<string> user_spec,
                map<string, shared_ptr<Option>> fmt_opts);
 
                vector<string> user_spec,
                map<string, shared_ptr<Option>> fmt_opts);
 
-private:
        void sample_thread_proc(function<void (const QString)> error_handler);
 
        void free_unused_memory();
 
        void sample_thread_proc(function<void (const QString)> error_handler);
 
        void free_unused_memory();
 
+       void signal_new_segment();
+       void signal_segment_completed();
+
        void feed_in_header();
 
        void feed_in_meta(shared_ptr<sigrok::Meta> meta);
        void feed_in_header();
 
        void feed_in_meta(shared_ptr<sigrok::Meta> meta);
@@ -199,6 +210,7 @@ private:
        void feed_in_trigger();
 
        void feed_in_frame_begin();
        void feed_in_trigger();
 
        void feed_in_frame_begin();
+       void feed_in_frame_end();
 
        void feed_in_logic(shared_ptr<sigrok::Logic> logic);
 
 
        void feed_in_logic(shared_ptr<sigrok::Logic> logic);
 
@@ -207,6 +219,27 @@ private:
        void data_feed_in(shared_ptr<sigrok::Device> device,
                shared_ptr<sigrok::Packet> packet);
 
        void data_feed_in(shared_ptr<sigrok::Device> device,
                shared_ptr<sigrok::Packet> packet);
 
+Q_SIGNALS:
+       void capture_state_changed(int state);
+       void device_changed();
+
+       void signals_changed();
+
+       void name_changed();
+
+       void trigger_event(int segment_id, util::Timestamp location);
+
+       void new_segment(int new_segment_id);
+       void segment_completed(int segment_id);
+
+       void data_received();
+
+       void add_view(const QString &title, views::ViewType type,
+               Session *session);
+
+public Q_SLOTS:
+       void on_data_saved();
+
 private:
        DeviceManager &device_manager_;
        shared_ptr<devices::Device> device_;
 private:
        DeviceManager &device_manager_;
        shared_ptr<devices::Device> device_;
@@ -223,39 +256,22 @@ private:
        unordered_set< shared_ptr<data::SignalBase> > signalbases_;
        unordered_set< shared_ptr<data::SignalData> > all_signal_data_;
 
        unordered_set< shared_ptr<data::SignalBase> > signalbases_;
        unordered_set< shared_ptr<data::SignalData> > all_signal_data_;
 
+       /// trigger_list_ contains pairs of <segment_id, timestamp> values.
+       vector< std::pair<uint32_t, util::Timestamp> > trigger_list_;
+
        mutable recursive_mutex data_mutex_;
        shared_ptr<data::Logic> logic_data_;
        uint64_t cur_samplerate_;
        shared_ptr<data::LogicSegment> cur_logic_segment_;
        map< shared_ptr<sigrok::Channel>, shared_ptr<data::AnalogSegment> >
                cur_analog_segments_;
        mutable recursive_mutex data_mutex_;
        shared_ptr<data::Logic> logic_data_;
        uint64_t cur_samplerate_;
        shared_ptr<data::LogicSegment> cur_logic_segment_;
        map< shared_ptr<sigrok::Channel>, shared_ptr<data::AnalogSegment> >
                cur_analog_segments_;
+       int32_t highest_segment_id_;
 
        std::thread sampling_thread_;
 
        bool out_of_memory_;
        bool data_saved_;
 
        std::thread sampling_thread_;
 
        bool out_of_memory_;
        bool data_saved_;
-
-Q_SIGNALS:
-       void capture_state_changed(int state);
-       void device_changed();
-
-       void signals_changed();
-
-       void name_changed();
-
-       void trigger_event(util::Timestamp location);
-
-       void frame_began();
-
-       void data_received();
-
-       void frame_ended();
-
-       void add_view(const QString &title, views::ViewType type,
-               Session *session);
-
-public Q_SLOTS:
-       void on_data_saved();
+       bool frame_began_;
 };
 
 } // namespace pv
 };
 
 } // namespace pv