diff --git a/cpp/oskar/OSKARElementResponse.cc b/cpp/oskar/OSKARElementResponse.cc index 175c8d780add72f376dadc2f5220c6ce8df4c0f2..6a0b782c3c4992c2626a5827d71e6a4ad0847344 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 b7e175b80e620ae88d211a858a1a2ad0fd6fa087..301bb34c6b5318c7f5fe324b3be082e924af6269 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;