Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
BeamLauncher.h
1 /*
2  * The MIT License (MIT)
3  *
4  * Copyright (c) 2016 The SKA organisation
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #ifndef SKA_CHEETAH_PIPELINE_BEAMLAUNCHER_H
25 #define SKA_CHEETAH_PIPELINE_BEAMLAUNCHER_H
26 
27 #include "cheetah/pipeline/MultiBeamConfig.h"
28 #include "cheetah/pipeline/BeamConfig.h"
29 #include "cheetah/pipeline/PipelineHandler.h"
30 #include <vector>
31 #include <functional>
32 #include <condition_variable>
33 #include <mutex>
34 
35 namespace ska {
36 namespace cheetah {
37 namespace pipeline {
38 
45 namespace detail {
46  struct PipelineWrapperBase;
48 }
49 
50 template<typename StreamType, typename NumericalT>
52 {
53  public:
54 
55  template<typename StreamConfigFactory, typename PipelineFactory>
56  BeamLauncher(MultiBeamConfig<NumericalT> const& mb_config, StreamConfigFactory const& config_factory, PipelineFactory const& pipeline_factory);
57  ~BeamLauncher();
58 
63  int exec();
64 
66  void join();
67 
69  bool is_running() const;
70 
72  std::vector<std::unique_ptr<StreamType>>& streams();
73 
74  private:
75  MultiBeamConfig<NumericalT> const& _multi_beam_config;
76  bool _exit;
77  std::mutex _mutex;
78  std::condition_variable _wait_cv;
79  std::vector<std::unique_ptr<panda::Thread>> _threads;
80  std::vector<panda::ThreadConfig const*> _thread_config;
81  std::vector<std::unique_ptr<StreamType>> _streams;
82  std::vector<std::unique_ptr<detail::PipelineHandlerWrapperBase>> _runtime_handlers;
83  std::vector<std::unique_ptr<detail::PipelineWrapperBase>> _pipelines;
84  std::atomic<std::size_t> _execution_count;
85 };
86 
87 } // namespace pipeline
88 } // namespace cheetah
89 } // namespace ska
90 
91 #include "cheetah/pipeline/detail/BeamLauncher.cpp"
92 
93 #endif // SKA_CHEETAH_PIPELINE_BEAMLAUNCHER_H
Node to access multiple beam configurations.
Some limits and constants for FLDO.
Definition: Brdz.h:35