DP3
Patch.h
Go to the documentation of this file.
1 // Copyright (C) 2020 ASTRON (Netherlands Institute for Radio Astronomy)
2 // SPDX-License-Identifier: GPL-3.0-or-later
3 
4 #ifndef DP3_BASE_PATCH_H_
5 #define DP3_BASE_PATCH_H_
6 
7 #include "base/Direction.h"
8 #include "base/ModelComponent.h"
9 
10 #include <memory>
11 #include <string>
12 #include <vector>
13 
14 namespace dp3::model {
15 
18 
19 class Patch {
20  public:
21  using iterator = std::vector<std::shared_ptr<base::ModelComponent>>::iterator;
23  std::vector<std::shared_ptr<const base::ModelComponent>>::const_iterator;
24 
25  template <typename T>
26  Patch(const std::string &name, T first, T last)
27  : name_(name), components_(first, last) {
29  }
30 
31  const std::string &Name() const { return name_; }
32  const base::Direction &Direction() const { return direction_; }
33  double Brightness() const { return brightness_; }
39  size_t Index() const { return index_; }
40 
41  void SetDirection(const base::Direction &pos) { direction_ = pos; }
42  void SetBrightness(double brightness) { brightness_ = brightness; }
43  void SetIndex(size_t index) { index_ = index; }
44 
45  size_t NComponents() const { return components_.size(); }
46  std::shared_ptr<base::ModelComponent> component(size_t i) {
47  return components_[i];
48  }
49  std::shared_ptr<const base::ModelComponent> component(size_t i) const {
50  return components_[i];
51  }
52 
53  iterator begin() { return components_.begin(); }
54  iterator end() { return components_.end(); }
55 
58 
59  private:
60  size_t index_ = 0;
61  std::string name_;
62  base::Direction direction_;
63  double brightness_ = 0.0;
64  std::vector<std::shared_ptr<base::ModelComponent>> components_;
65 };
66 
67 } // namespace dp3::model
68 
69 #endif
A set of sources for which direction dependent effects are assumed to be equal.
Definition: Patch.h:19
std::shared_ptr< base::ModelComponent > component(size_t i)
Definition: Patch.h:46
void SetDirection(const base::Direction &pos)
Definition: Patch.h:41
std::vector< std::shared_ptr< const base::ModelComponent > >::const_iterator const_iterator
Definition: Patch.h:23
const std::string & Name() const
Definition: Patch.h:31
Patch(const std::string &name, T first, T last)
Definition: Patch.h:26
size_t Index() const
Definition: Patch.h:39
void ComputeDirection()
Compute the direction as the average of the positions of the components.
std::shared_ptr< const base::ModelComponent > component(size_t i) const
Definition: Patch.h:49
std::vector< std::shared_ptr< base::ModelComponent > >::iterator iterator
Definition: Patch.h:21
iterator end()
Definition: Patch.h:54
iterator begin()
Definition: Patch.h:53
void SetBrightness(double brightness)
Definition: Patch.h:42
const base::Direction & Direction() const
Definition: Patch.h:32
void SetIndex(size_t index)
Definition: Patch.h:43
double Brightness() const
Definition: Patch.h:33
size_t NComponents() const
Definition: Patch.h:45
Definition: Patch.h:14
A direction on the celestial sphere.
Definition: Direction.h:15