diff --git a/cpp/common/CMakeLists.txt b/cpp/common/CMakeLists.txt index 37d714a255baae95cdde8be7ea0e45214ec90e21..27a509426dddbb6ced3672c8d771638b270eca35 100644 --- a/cpp/common/CMakeLists.txt +++ b/cpp/common/CMakeLists.txt @@ -1,12 +1,6 @@ # Copyright (C) 2020 ASTRON (Netherlands Institute for Radio Astronomy) # SPDX-License-Identifier: GPL-3.0-or-later -install( - FILES constants.h - casautils.h - mathutils.h - mutable_ptr.h - types.h - fftresampler.h - sphericalharmonics.h - DESTINATION "include/${CMAKE_PROJECT_NAME}/common") +install(FILES constants.h casautils.h mathutils.h types.h fftresampler.h + sphericalharmonics.h + DESTINATION "include/${CMAKE_PROJECT_NAME}/common") diff --git a/cpp/common/mutable_ptr.h b/cpp/common/mutable_ptr.h deleted file mode 100644 index 876e250b486f6a80dc67699f2adf0328525a66a1..0000000000000000000000000000000000000000 --- a/cpp/common/mutable_ptr.h +++ /dev/null @@ -1,71 +0,0 @@ -// mutableptr.h: Representation of an LBA antenna field. -// -// Copyright (C) 2020 ASTRON (Netherlands Institute for Radio Astronomy) -// SPDX-License-Identifier: GPL-3.0-or-later - -#ifndef EVERYBEAM_MUTABLEPTR_H -#define EVERYBEAM_MUTABLEPTR_H - -#include <memory> - -namespace everybeam { -namespace common { -/*! - * \brief MutablePtr is a mutable smart pointer derived from std::shared_ptr. - * - * Its purpose is to have a pointer that - * 1. can by copied/passed by value, - * 2. the original can be modified after it has been copied - * 3. the copies will dereference to the new value - * - * This behaviour is different from a `reset` of a std::shared_ptr - * There the copies will keep pointing to the original object - * - * The inner pointer is a shared_ptr which manages the object it points to - * - * Usage: - * - * \code - * #include<iostream> - * #include "mutable_ptr.h" - * - * class Msg { - * public: - * Msg(const std::string &t) : text(t) {} - * std::string text; - * }; - * - * typedef MutablePtr<Msg> MsgMutPtr; - * - * int main() - * { - * auto m1 = std::make_shared<Msg>("hoi"); - * auto m2 = std::make_shared<Msg>("hallo"); - * - * MsgPtr mut_ptr(m1); - * auto mut_ptr_copy = mut_ptr; - * - * mut_ptr.set(m2); - * - * std::cout << mut_ptr->text << std::endl; - * std::cout << mut_ptr_copy->text << std::endl; - * - * // Output: - * // Greetings from object number two - * // Greetings from object number two - * - * \endcode - */ -template <typename T> -class MutablePtr : public std::shared_ptr<std::shared_ptr<T>> { - public: - MutablePtr(std::shared_ptr<T> ptr) - : std::shared_ptr<std::shared_ptr<T>>(new std::shared_ptr<T>(ptr)) {} - T& operator*() const { return **(this->get()); } - std::shared_ptr<T> operator->() const { return *(this->get()); } - void set(std::shared_ptr<T> ptr) { *(this->get()) = ptr; } - explicit operator bool() const noexcept { return **this; } -}; -} // namespace common -} // namespace everybeam -#endif diff --git a/cpp/elementresponse.h b/cpp/elementresponse.h index fbbd9e2b29961dbf8fcee90408d82621439454b1..05bd12b2ef79b36a49031c05273a7a30135eeec5 100644 --- a/cpp/elementresponse.h +++ b/cpp/elementresponse.h @@ -11,16 +11,10 @@ #include <aocommon/matrix2x2.h> -#include "common/mutable_ptr.h" #include "common/types.h" namespace everybeam { -namespace common { -template <typename T> -class MutablePtr; -} - struct Options; enum class ElementResponseModel { @@ -60,9 +54,6 @@ class ElementResponse : public std::enable_shared_from_this<ElementResponse> { public: virtual ~ElementResponse() {} - typedef common::MutablePtr<ElementResponse> - Ptr; //!< Pointer to ElementResponse object - virtual ElementResponseModel GetModel() const = 0; /** diff --git a/cpp/station.cc b/cpp/station.cc index 87cdf3be3868a73a5dfd0a91f55636e18a9eadf8..3f3eb27c55e6dbc65323a19c26037e363de76162 100644 --- a/cpp/station.cc +++ b/cpp/station.cc @@ -24,14 +24,6 @@ Station::Station(const std::string& name, const vector3r_t& position, ncp_pol0_.reset(new coords::ITRFDirection(ncppol0)); } -void Station::SetResponseModel(const ElementResponseModel model) { - element_response_.set(ElementResponse::GetInstance(model, name_, options_)); -} - -void Station::SetResponse(std::shared_ptr<ElementResponse> element_response) { - element_response_.set(element_response); -} - const std::string& Station::GetName() const { return name_; } const vector3r_t& Station::GetPosition() const { return position_; } diff --git a/cpp/station.h b/cpp/station.h index 6a9799a4c0a25ce479862fca321782097c3a5600..aef4b9315597ea570e539a68d85c5d63cd1e1464 100644 --- a/cpp/station.h +++ b/cpp/station.h @@ -35,8 +35,6 @@ class Station { Station(const std::string& name, const vector3r_t& position, const Options& options = Options()); - void SetResponse(std::shared_ptr<ElementResponse> element_response); - //! Return the name of the station. const std::string& GetName() const; @@ -262,7 +260,7 @@ class Station { //! Returns a pointer to the ElementResponse class std::shared_ptr<const ElementResponse> GetElementResponse() const { - return *element_response_.get(); + return element_response_; } /** @@ -310,8 +308,6 @@ class Station { std::shared_ptr<Antenna> GetAntenna() const { return antenna_; } private: - void SetResponseModel(const ElementResponseModel model); - vector3r_t NCP(real_t time) const; vector3r_t NCPPol0(real_t time) const; @@ -319,7 +315,7 @@ class Station { vector3r_t position_; Options options_; vector3r_t phase_reference_; - ElementResponse::Ptr element_response_; + std::shared_ptr<const ElementResponse> element_response_; // element_ either refers to antenna_ or an Element inside antenna_. // Besides Station, no one has (shared) ownership of antenna_. std::shared_ptr<Element> element_;