LASP 1.0
Library for Acoustic Signal Processing
Loading...
Searching...
No Matches
lasp_indatahandler.cpp
Go to the documentation of this file.
1/* #define DEBUGTRACE_ENABLED */
3#include "debugtrace.hpp"
4#include "lasp_streammgr.h"
5#include <thread>
6
8 const InResetType resetfcn)
9 : _mgr(mgr), inCallback(cb), reset(resetfcn)
10#if LASP_DEBUG == 1
11 ,
12 main_thread_id(std::this_thread::get_id())
13#endif
14{
15 DEBUGTRACE_ENTER;
16#if LASP_DEBUG == 1
17 assert(mgr->main_thread_id == main_thread_id);
18#endif
19}
21 DEBUGTRACE_ENTER;
23 if (SmgrHandle handle = _mgr.lock()) {
24 handle->addInDataHandler(this);
25#if LASP_DEBUG == 1
26 assert(handle->main_thread_id == main_thread_id);
27#endif
28 }
29}
31 DEBUGTRACE_ENTER;
33#if LASP_DEBUG == 1
34 stopCalled = true;
35#endif
36 if (SmgrHandle handle = _mgr.lock()) {
37 handle->removeInDataHandler(*this);
38 }
39}
40
42
43 DEBUGTRACE_ENTER;
45#if LASP_DEBUG == 1
46 if (!stopCalled) {
47 std::cerr << "************ BUG: Stop function not called while arriving at "
48 "InDataHandler's destructor. Fix this by calling "
49 "InDataHandler::stop()."
50 << std::endl;
51 abort();
52 }
53#endif
54}
55#if LASP_DEBUG == 1
57 assert(std::this_thread::get_id() == main_thread_id);
58}
59#endif
std::weak_ptr< StreamMgr > _mgr
InDataHandler(SmgrHandle mgr, InCallbackType cb, InResetType resetfcn)
When constructed, the handler is added to the stream manager, which will call the handlers's inCallba...
void start()
Adds the current InDataHandler to the list of handlers in the StreamMgr. After this happens,...
void checkRightThread() const
void stop()
Removes the currend InDataHandler from the list of handlers in the StreamMgr. From that point on,...
std::weak_ptr< StreamMgr > _mgr
The main global handle to a stream, stored in a weak pointer, if it does not yet exist,...
std::function< void(const Daq *)> InResetType
Function definition for the reset callback.
std::function< void(const DaqData &)> InCallbackType
The function definition of callbacks with incoming DAQ data.
std::shared_ptr< StreamMgr > SmgrHandle