World Ocean Simulation System (WOSS) library
definitions-handler.h
Go to the documentation of this file.
1/* WOSS - World Ocean Simulation System -
2 *
3 * Copyright (C) 2009 2025 Federico Guerra
4 * and regents of the SIGNET lab, University of Padova
5 *
6 * Author: Federico Guerra - WOSS@guerra-tlc.com
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation;
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22
33#ifndef WOSS_DEF_HANDLER_H
34#define WOSS_DEF_HANDLER_H
35
36
37#include <iostream>
38#include <cassert>
39#include <cstdlib>
40#include <memory>
42#include "time-definitions.h"
50#include "ssp-definitions.h"
51
52namespace woss {
53
63 class DefHandler {
64
65 public:
66
67 DefHandler() = default;
68
69 DefHandler( const DefHandler& copy ) = default;
70
71 DefHandler( DefHandler&& tmp ) = default;
72
73 DefHandler& operator=( const DefHandler& copy ) = default;
74
75 DefHandler& operator=( DefHandler&& tmp ) = default;
76
77 ~DefHandler() = default;
78
79
86 void setPressure( std::unique_ptr<Pressure> ptr ) { pressure_creator = std::move(ptr); }
93 void setTimeArr( std::unique_ptr<TimeArr> ptr ) { time_arr_creator = std::move(ptr); }
100 void setSSP( std::unique_ptr<SSP> ptr ) { ssp_creator = std::move(ptr); }
107 void setSediment( std::unique_ptr<Sediment> ptr ) { sediment_creator = std::move(ptr); }
114 void setTimeReference( std::unique_ptr<TimeReference> ptr ) { time_reference = std::move(ptr); }
121 void setRandGenerator( std::unique_ptr<RandomGenerator> ptr ) { rand_generator = std::move(ptr); }
128 void setTransducer( std::unique_ptr<Transducer> ptr ) { transducer_creator = std::move(ptr); }
135 void setAltimetry( std::unique_ptr<Altimetry> ptr ) { altimetry_creator = std::move(ptr); }
142 void setLocation( std::unique_ptr<Location> ptr) { location_creator = std::move(ptr); }
148 void setDebug( bool flag ) { debug = flag; }
149
154 double getRand() const { assert(rand_generator); return rand_generator->getRand(); }
159 int getRandInt() const { assert(rand_generator); return rand_generator->getRandInt(); }
164 double getTimeReference() const { assert(time_reference); return time_reference->getTimeReference(); }
169 bool getDebug() const { return debug; }
170
177 template<class... Args>
178 std::unique_ptr<Sediment> createSediment(Args&&... args) const { assert(sediment_creator); return sediment_creator->create(std::forward<Args>(args)...); }
185 template<class... Args>
186 std::unique_ptr<Transducer> createTransducer(Args&&... args) const { assert(transducer_creator); return transducer_creator->create(std::forward<Args>(args)...); }
193 template<class... Args>
194 std::unique_ptr<Altimetry> createAltimetry(Args&&... args) const { assert(altimetry_creator); return altimetry_creator->create(std::forward<Args>(args)...); }
201 template<class... Args>
202 std::unique_ptr<Location> createLocation(Args&&... args) const { assert(location_creator); return location_creator->create(std::forward<Args>(args)...); }
209 template<class... Args>
210 std::unique_ptr<SSP> createSSP(Args&&... args) const { assert(ssp_creator); return ssp_creator->create(std::forward<Args>(args)...); }
217 template<class... Args>
218 std::unique_ptr<Pressure> createPressure(Args&&... args) const { assert(pressure_creator); return pressure_creator->create(std::forward<Args>(args)...); }
225 template<class... Args>
226 std::unique_ptr<TimeArr> createTimeArr(Args&&... args) const { assert(time_arr_creator); return time_arr_creator->create(std::forward<Args>(args)...); }
233 template<class... Args>
234 std::unique_ptr<Pressure[]> createPressureArray(Args&&... args) const { assert(pressure_creator); return pressure_creator->createArray(std::forward<Args>(args)...); }
241 template<class... Args>
242 std::unique_ptr<TimeArr[]> createTimeArrArray(Args&&... args) const { assert(time_arr_creator); return time_arr_creator->createArray(std::forward<Args>(args)...); }
243
244 private:
245
249 bool debug = false;
253 std::unique_ptr<SSP> ssp_creator = nullptr;
257 std::unique_ptr<Sediment> sediment_creator = nullptr;
261 std::unique_ptr<TimeReference> time_reference = nullptr;
265 std::unique_ptr<RandomGenerator> rand_generator = nullptr;
269 std::unique_ptr<Transducer> transducer_creator = nullptr;
273 std::unique_ptr<Altimetry> altimetry_creator = nullptr;
277 std::unique_ptr<Location> location_creator = nullptr;
281 std::unique_ptr<Pressure> pressure_creator = nullptr;
285 std::unique_ptr<TimeArr> time_arr_creator = nullptr;
286 };
287
294
295}
296
297#endif /* WOSS_DEF_HANDLER_H */
Definitions and library for woss::Altimetry class.
Class for managing dynamic instantiation of foundation classes.
Definition definitions-handler.h:63
void setSediment(std::unique_ptr< Sediment > ptr)
Definition definitions-handler.h:107
std::unique_ptr< Altimetry > createAltimetry(Args &&... args) const
Definition definitions-handler.h:194
std::unique_ptr< Transducer > createTransducer(Args &&... args) const
Definition definitions-handler.h:186
void setLocation(std::unique_ptr< Location > ptr)
Definition definitions-handler.h:142
std::unique_ptr< Altimetry > altimetry_creator
Definition definitions-handler.h:273
int getRandInt() const
Definition definitions-handler.h:159
void setAltimetry(std::unique_ptr< Altimetry > ptr)
Definition definitions-handler.h:135
bool debug
Definition definitions-handler.h:249
double getTimeReference() const
Definition definitions-handler.h:164
DefHandler()=default
DefHandler(DefHandler &&tmp)=default
std::unique_ptr< TimeArr > createTimeArr(Args &&... args) const
Definition definitions-handler.h:226
std::unique_ptr< Pressure > pressure_creator
Definition definitions-handler.h:281
bool getDebug() const
Definition definitions-handler.h:169
DefHandler & operator=(DefHandler &&tmp)=default
std::unique_ptr< Pressure > createPressure(Args &&... args) const
Definition definitions-handler.h:218
std::unique_ptr< RandomGenerator > rand_generator
Definition definitions-handler.h:265
std::unique_ptr< SSP > createSSP(Args &&... args) const
Definition definitions-handler.h:210
std::unique_ptr< Pressure[]> createPressureArray(Args &&... args) const
Definition definitions-handler.h:234
void setTimeArr(std::unique_ptr< TimeArr > ptr)
Definition definitions-handler.h:93
std::unique_ptr< Transducer > transducer_creator
Definition definitions-handler.h:269
void setRandGenerator(std::unique_ptr< RandomGenerator > ptr)
Definition definitions-handler.h:121
void setSSP(std::unique_ptr< SSP > ptr)
Definition definitions-handler.h:100
std::unique_ptr< TimeArr[]> createTimeArrArray(Args &&... args) const
Definition definitions-handler.h:242
std::unique_ptr< SSP > ssp_creator
Definition definitions-handler.h:253
void setTimeReference(std::unique_ptr< TimeReference > ptr)
Definition definitions-handler.h:114
std::unique_ptr< Location > createLocation(Args &&... args) const
Definition definitions-handler.h:202
DefHandler(const DefHandler &copy)=default
std::unique_ptr< Sediment > sediment_creator
Definition definitions-handler.h:257
std::unique_ptr< Location > location_creator
Definition definitions-handler.h:277
std::unique_ptr< TimeArr > time_arr_creator
Definition definitions-handler.h:285
void setDebug(bool flag)
Definition definitions-handler.h:148
DefHandler & operator=(const DefHandler &copy)=default
~DefHandler()=default
std::unique_ptr< TimeReference > time_reference
Definition definitions-handler.h:261
void setTransducer(std::unique_ptr< Transducer > ptr)
Definition definitions-handler.h:128
double getRand() const
Definition definitions-handler.h:154
std::unique_ptr< Sediment > createSediment(Args &&... args) const
Definition definitions-handler.h:178
void setPressure(std::unique_ptr< Pressure > ptr)
Definition definitions-handler.h:86
Singleton design pattern template.
Definition singleton-definitions.h:47
Implementation of woss::Location class.
Definition ac-toolbox-arr-asc-reader.h:44
Singleton< DefHandler > SDefHandler
Singleton implementation of DefHandler class.
Definition definitions-handler.h:293
Definitions and library for woss::Pressure class.
Definitions and library for woss::RandomGenerator class.
Definitions and library for woss::Sediment class.
Definitions of woss::Singleton template.
Definitions and library for Sound Speed Profiles.
Definitions and library for woss::TimeArr class.
Definitions and library for woss::Time, woss::SimTime, woss::TimeReference and woss::TimeReferenceTcl...
Provides the interface for the woss::Transducer class.