neic-glass3  1.4.6
PickList.h
Go to the documentation of this file.
1 /*****************************************
2  * This file is documented for Doxygen.
3  * If you modify this file please update
4  * the comments so that Doxygen will still
5  * be able to work.
6  ****************************************/
7 #ifndef PICKLIST_H
8 #define PICKLIST_H
9 
10 #include <threadbaseclass.h>
11 
12 #include <json.h>
13 #include <set>
14 #include <vector>
15 #include <memory>
16 #include <string>
17 #include <utility>
18 #include <mutex>
19 #include <thread>
20 #include <queue>
21 #include <random>
22 #include <atomic>
23 
24 #include "Glass.h"
25 #include "Pick.h"
26 #include "HypoList.h"
27 
28 namespace glasscore {
29 
30 // forward declarations
31 class CSite;
32 class CSiteList;
33 class CHypo;
34 
41 struct PickCompare {
42  bool operator()(const std::shared_ptr<CPick> &lhs,
43  const std::shared_ptr<CPick> &rhs) const {
44  if (lhs->getTSort() < rhs->getTSort()) {
45  return (true);
46  }
47  return (false);
48  }
49 };
50 
63  public:
75  explicit CPickList(int numThreads = 1, int sleepTime = 50,
76  int checkInterval = 300);
77 
83  ~CPickList();
84 
88  void clear() override;
89 
104  bool receiveExternalMessage(std::shared_ptr<json::Object> com);
105 
128  bool addPick(std::shared_ptr<json::Object> pick);
129 
143  std::shared_ptr<CPick> getDuplicate(double newTPick, std::string newSCNL,
144  double tDuration);
145 
160  bool scavenge(std::shared_ptr<CHypo> hyp,
162 
167  const CSiteList* getSiteList() const;
168 
173  void setSiteList(CSiteList* siteList);
174 
180  int getMaxAllowablePickCount() const;
181 
187  void setMaxAllowablePickCount(int pickMax);
188 
194  int getCountOfTotalPicksProcessed() const;
195 
201  int length() const;
202 
216  std::vector<std::weak_ptr<CPick>> getPicks(double t1, double t2);
217 
225  glass3::util::WorkState work() override;
226 
227  protected:
233  void updatePosition(std::shared_ptr<CPick> pick);
234 
239  void eraseFromMultiset(std::shared_ptr<CPick> pick);
240 
241  private:
246  CSiteList * m_pSiteList;
247 
253  int m_iMaxAllowablePickCount;
254 
259  int m_iCountOfTotalPicksProcessed;
260 
265  std::multiset<std::shared_ptr<CPick>, PickCompare> m_msPickList;
266 
271  std::queue<std::shared_ptr<json::Object>> m_qPicksToProcess;
272 
276  std::mutex m_PicksToProcessMutex;
277 
285  mutable std::recursive_mutex m_PickListMutex;
286 
291  std::shared_ptr<CPick> m_LowerValue;
292 
297  std::shared_ptr<CPick> m_UpperValue;
298 
299  // constants
303  static const int k_nMaxAllowablePickCountDefault = 10000;
304 
308  static const int k_ProcessQueueMaximumSize = 1000;
309 };
310 } // namespace glasscore
311 #endif // PICKLIST_H
glasscore pick list class
Definition: PickList.h:62
glasscore site list class
Definition: SiteList.h:40
WorkState
glass3::util::WorkState enumeration
Definition: workstate.h:25
CPickList comparison function.
Definition: PickList.h:41
The namespace containing the core algorithm.
Definition: Correlation.h:17
static constexpr double k_nHypoSearchPastDurationForPick
The duration in seconds to search into the past for hypos matching a pick.
Definition: HypoList.h:332
glass3::util::ThreadBaseClass class
Definition: threadbaseclass.h:34
bool operator()(const std::shared_ptr< CPick > &lhs, const std::shared_ptr< CPick > &rhs) const
Definition: PickList.h:42