From a8abe1e40667037853424b8858c3122095639f56 Mon Sep 17 00:00:00 2001
From: Sebastiaan van der Tol <tol@astron.nl>
Date: Tue, 30 Jun 2020 06:36:14 +0200
Subject: [PATCH] Add a new constructor to OSKARElementResponse

This constructor takes a path to a coeffcients file as argument
---
 cpp/oskar/OSKARElementResponse.cc |  7 ++++++-
 cpp/oskar/OSKARElementResponse.h  | 14 ++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/cpp/oskar/OSKARElementResponse.cc b/cpp/oskar/OSKARElementResponse.cc
index 175c8d78..6a0b782c 100644
--- a/cpp/oskar/OSKARElementResponse.cc
+++ b/cpp/oskar/OSKARElementResponse.cc
@@ -19,11 +19,16 @@ void OSKARElementResponseDipole::response(
                                        response_ptr + 2);
 }
 
-OSKARElementResponseSphericalWave::OSKARElementResponseSphericalWave() {
+OSKARElementResponseSphericalWave::OSKARElementResponseSphericalWave()
+{
   std::string path = get_path("oskar.h5");
   m_datafile.reset(new Datafile(path));
 }
 
+OSKARElementResponseSphericalWave::OSKARElementResponseSphericalWave(const std::string &path) {
+  m_datafile.reset(new Datafile(path));
+}
+
 void OSKARElementResponseSphericalWave::response(
     double freq, double theta, double phi,
     std::complex<double> (&response)[2][2]) const {
diff --git a/cpp/oskar/OSKARElementResponse.h b/cpp/oskar/OSKARElementResponse.h
index b7e175b8..301bb34c 100644
--- a/cpp/oskar/OSKARElementResponse.h
+++ b/cpp/oskar/OSKARElementResponse.h
@@ -25,12 +25,26 @@ class OSKARElementResponseDipole : public ElementResponse {
 //! Implementation of the OSKAR spherical wave response model
 class OSKARElementResponseSphericalWave : public ElementResponse {
  public:
+
+  /**
+   * A constructor-like static method to instantiate the class
+   *
+   * returns a globally shared instance of the class that is instantiated
+   * in the first call
+   */
   static std::shared_ptr<OSKARElementResponseSphericalWave> getInstance() {
     return common::Singleton<OSKARElementResponseSphericalWave>::getInstance();
   }
 
+  /** Constructor loading the default coefficients file */
   OSKARElementResponseSphericalWave();
 
+  /** Constructor loading a custom coefficients file
+   *
+   * @param path Path to the coefficients file to load
+   */
+  OSKARElementResponseSphericalWave(const std::string &path);
+
   virtual void response(
       double freq, double theta, double phi,
       std::complex<double> (&response)[2][2]) const final override;
-- 
GitLab