File: luathreadgroup.h

package info (click to toggle)
aoflagger 3.4.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,960 kB
  • sloc: cpp: 83,076; python: 10,187; sh: 260; makefile: 178
file content (46 lines) | stat: -rw-r--r-- 1,252 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef LUA_THREAD_GROUP_H
#define LUA_THREAD_GROUP_H

#include "luastrategy.h"

#include <vector>

class LuaThreadGroup {
 public:
  explicit LuaThreadGroup(size_t nThreads) : _strategies(nThreads) {}

  void LoadFile(const char* filename) {
    for (LuaStrategy& s : _strategies) {
      s.Initialize();
      s.LoadFile(filename);
    }
  }
  void LoadText(const std::string& text) {
    for (LuaStrategy& s : _strategies) {
      s.Initialize();
      s.LoadText(text);
    }
  }
  void Execute(size_t threadIndex, class TimeFrequencyData& tfData,
               const TimeFrequencyMetaDataCPtr& metaData,
               class ScriptData& scriptData,
               const std::string& executeFunctionName) {
    _strategies[threadIndex].Execute(tfData, metaData, scriptData,
                                     executeFunctionName);
  }
  void RunPreamble(const std::vector<std::string>& preamble) {
    for (LuaStrategy& s : _strategies) s.RunPreamble(preamble);
  }

  size_t NThreads() const { return _strategies.size(); }

  const LuaStrategy& GetThread(size_t index) const {
    return _strategies[index];
  }
  LuaStrategy& GetThread(size_t index) { return _strategies[index]; }

 private:
  std::vector<LuaStrategy> _strategies;
};

#endif