Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
DmTime.cpp
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 #include "cheetah/data/DmTime.h"
25 #include <type_traits>
26 
27 namespace ska {
28 namespace cheetah {
29 namespace data {
30 namespace detail {
31 
35 template <typename DmTrialsType>
37 {
38  typedef std::shared_ptr<DmTrialsType> ElementType;
39  bool operator()(const ElementType &lhs, const ElementType &rhs) const;
40 };
41 
42 template <typename DmTrialsType>
43 bool DmTimeStartTimeComparitor<DmTrialsType>::operator()(const ElementType &lhs, const ElementType &rhs) const
44 {
45  return lhs->start_time() < rhs->start_time();
46 }
47 
48 } // namespace detail
49 
50 template <typename DmTrialsType>
52 {
53 }
54 
55 template <typename DmTrialsType>
57 {
58 }
59 
60 template <typename DmTrialsType>
61 void DmTime<DmTrialsType>::add(ValueType data)
62 {
63  //First determine where in the list this block should be
64  auto it = std::upper_bound(_data.begin(),_data.end(),data,detail::DmTimeStartTimeComparitor<DmTrialsType>());
65 
66  //Insert it in an ordered manner
67  _data.insert(it,data);
68 }
69 
70 template <typename DmTrialsType>
72 {
73  _data.clear();
74 }
75 
76 template <typename DmTrialsType>
77 typename DmTime<DmTrialsType>::Iterator DmTime<DmTrialsType>::begin(std::size_t number_dms_per_slice)
78 {
79  return Iterator(0, number_dms_per_slice, this->shared_from_this());
80 }
81 
82 template <typename DmTrialsType>
83 typename DmTime<DmTrialsType>::ConstIterator DmTime<DmTrialsType>::cbegin(std::size_t number_dms_per_slice) const
84 {
85  return ConstIterator(0, number_dms_per_slice, this->shared_from_this());
86 }
87 
88 template <typename DmTrialsType>
90 {
91  if (_data.empty())
92  return Iterator(0,0,this->shared_from_this());
93  return Iterator(_data.front()->size(),0,this->shared_from_this());
94 }
95 
96 template <typename DmTrialsType>
98 {
99  if (_data.empty())
100  return ConstIterator(0,0,this->shared_from_this());
101  return ConstIterator(_data.front()->size(),0,this->shared_from_this());
102 }
103 
104 template <typename DmTrialsType>
105 typename DmTime<DmTrialsType>::ContainerType const& DmTime<DmTrialsType>::blocks() const
106 {
107  return _data;
108 }
109 
110 template <typename DmTrialsType>
111 typename DmTime<DmTrialsType>::ContainerType& DmTime<DmTrialsType>::blocks()
112 {
113  return _data;
114 }
115 
116 } // namespace data
117 } // namespace cheetah
118 } // namespace ska
Functor to support comparison of start times in DmTime objects.
Definition: DmTime.cpp:36
Iterator begin(std::size_t number_dms_per_slice)
Get an iterator pointing to the first DM trial that iterates over slices of DMs.
Definition: DmTime.cpp:77
void clear()
Clear the DmTime.
Definition: DmTime.cpp:71
Provides an iterator over a DmTime in slices of DMs.
Iterator end()
Get an iterator that points to the last DM trial in the buffer.
Definition: DmTime.cpp:89
ContainerType const & blocks() const
Get a reference to the underlying list.
Definition: DmTime.cpp:105
Some limits and constants for FLDO.
Definition: Brdz.h:35
A wrapper class for a list of DmTime instances.
void add(ValueType data)
Insert a new DmTime object into the buffer.
Definition: DmTime.cpp:61