check(sr_session_stop(_structure));
}
+bool Session::is_running() const
+{
+ const int ret = sr_session_is_running(_structure);
+ if (ret < 0)
+ throw Error{ret};
+ return (ret != 0);
+}
+
+static void session_stopped_callback(void *data)
+{
+ auto *const callback = static_cast<SessionStoppedCallback*>(data);
+ (*callback)();
+}
+
+void Session::set_stopped_callback(SessionStoppedCallback callback)
+{
+ _stopped_callback = move(callback);
+ if (_stopped_callback)
+ check(sr_session_stopped_callback_set(_structure,
+ &session_stopped_callback, &_stopped_callback));
+ else
+ check(sr_session_stopped_callback_set(_structure,
+ nullptr, nullptr));
+}
+
static void datafeed_callback(const struct sr_dev_inst *sdi,
const struct sr_datafeed_packet *pkt, void *cb_data)
{
friend class TriggerStage;
};
+/** Type of session stopped callback */
+typedef function<void()> SessionStoppedCallback;
+
/** Type of datafeed callback */
typedef function<void(shared_ptr<Device>, shared_ptr<Packet>)>
DatafeedCallbackFunction;
void run();
/** Stop the session. */
void stop();
+ /** Return whether the session is running. */
+ bool is_running() const;
+ /** Set callback to be invoked on session stop. */
+ void set_stopped_callback(SessionStoppedCallback callback);
/** Get current trigger setting. */
shared_ptr<Trigger> trigger();
/** Get the context. */
map<const struct sr_dev_inst *, SessionDevice *> _owned_devices;
map<const struct sr_dev_inst *, shared_ptr<Device> > _other_devices;
vector<DatafeedCallbackData *> _datafeed_callbacks;
+ SessionStoppedCallback _stopped_callback;
map<shared_ptr<EventSource>, SourceCallbackData *> _source_callbacks;
string _filename;
shared_ptr<Trigger> _trigger;