World Ocean Simulation System (WOSS) library
woss-db.h
Go to the documentation of this file.
1/* WOSS - World Ocean Simulation System -
2 *
3 * Copyright (C) 2009 Federico Guerra
4 * and regents of the SIGNET lab, University of Padova
5 *
6 * Author: Federico Guerra - federico@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/*
23 * This software has been developed by Federico Guerra and SIGNET lab,
24 * University of Padova, in collaboration with the NATO Centre for
25 * Maritime Research and Experimentation (http://www.cmre.nato.int ;
26 * E-mail: pao@cmre.nato.int), whose support is gratefully acknowledged.
27 */
28
29
40#ifndef WOSS_DB_H
41#define WOSS_DB_H
42
43#include <fstream>
44
45#if defined(WOSS_NETCDF4_SUPPORT)
46#include <ncFile.h>
47#elif defined(WOSS_NETCDF_SUPPORT)
48#include <netcdfcpp.h>
49#endif
50
51#include <definitions.h>
53
54
55namespace woss {
56
57
58 class Sediment;
59 class Pressure;
60 class SSP;
61 class TimeArr;
62 class Time;
63
64
68 #define DB_NAME_NOT_SET "DB_NAME_NOT_SET"
69
70
76 typedef ::std::pair< ::std::string, ::std::string > PathName; // path , filename
77
78
89 class WossDb {
90
91
92 public:
93
94
99 WossDb( const ::std::string& name );
100
101 virtual ~WossDb() { }
102
103
108 void setDbName( const ::std::string& pathname ) { db_name = pathname; }
109
114 ::std::string getDbName() const { return db_name; }
115
116
121 void setDebug( double flag = true ) { debug = flag; }
122
127 bool isUsingDebug() const { return debug; }
128
129
134 virtual bool isValid() { return( db_name.length() > 0 ); }
135
136
141 virtual bool openConnection() = 0;
142
143
148 virtual bool finalizeConnection() = 0;
149
150
155 virtual bool closeConnection() = 0;
156
157
158 protected:
159
160
164 ::std::string db_name;
165
166
170 bool debug;
171
172
178 PathName getPathName( const ::std::string& complete_path );
179
180
181 };
182
184#ifdef WOSS_NETCDF_SUPPORT
193 class WossNetcdfDb : public WossDb {
194
195
196 public:
197
198
203 WossNetcdfDb( const ::std::string& name );
204
205 virtual ~WossNetcdfDb();
206
207
212 virtual bool openConnection();
213
214
219 virtual bool closeConnection();
220
221
222 protected:
223
224
228#if defined(WOSS_NETCDF4_SUPPORT)
229 netCDF::NcFile* netcdf_db;
230#else
231 NcFile* netcdf_db;
232#endif // defined(WOSS_NETCDF4_SUPPORT)
233
234 };
235#endif // WOSS_NETCDF_SUPPORT
236
237
245 class WossTextualDb : public WossDb {
246
247
248 public:
249
254 WossTextualDb( const ::std::string& name );
255
256 virtual ~WossTextualDb();
257
258
263 virtual bool openConnection();
264
265
270 virtual bool closeConnection();
271
272
273 protected:
274
275
279 ::std::fstream textual_db;
280
281
282 };
283
285
293
294
295 public:
296
297
298 WossBathymetryDb() { }
299
300 virtual ~WossBathymetryDb() { }
301
302
309 virtual bool insertValue( const Coord& coordinates, const Bathymetry& bathymetry_value ) = 0;
310
316 virtual Bathymetry getValue( const Coord& coords ) const = 0;
317
318
319 };
320
321
329
330
331 public:
332
333
334 WossSedimentDb() { }
335
336 virtual ~WossSedimentDb() { }
337
338
345 virtual bool insertValue( const Coord& coordinates, const Sediment& sediment_value ) = 0;
346
347
354 virtual Sediment* getValue( const CoordZ& coords ) const = 0;
355
363 virtual Sediment* getValue( const CoordZVector& coordz_vector ) const = 0;
364
365
366 };
367
368
375 class WossSSPDb {
376
377
378 public:
379
380
381 WossSSPDb() { }
382
383 virtual ~WossSSPDb() { }
384
385
393 virtual bool insertValue( const Coord& coordinates, const Time& time_value, const SSP& ssp_value ) = 0;
394
395
404 virtual SSP* getValue( const Coord& coords, const Time& time, long double ssp_depth_precision ) const = 0;
405
406
407 };
408
409
417
418
419 public:
420
421
422 WossResTimeArrDb() { }
423
424 virtual ~WossResTimeArrDb() { }
425
435 virtual TimeArr* getValue( const CoordZ& coord_tx, const CoordZ& coord_rx, const double frequency, const Time& time_value ) const = 0;
436
437
446 virtual bool insertValue( const CoordZ& coord_tx, const CoordZ& coord_rx, const double frequency, const Time& time_value, const TimeArr& channel ) = 0;
447
448
449 };
450
451
459
460
461 public:
462
463
464 WossResPressDb() { }
465
466 virtual ~WossResPressDb() { }
467
468
477 virtual Pressure* getValue( const CoordZ& coord_tx, const CoordZ& coord_rx, const double frequency, const Time& time_value ) const = 0;
478
479
488 virtual bool insertValue( const CoordZ& coord_tx, const CoordZ& coord_rx, const double frequency, const Time& time_value, const Pressure& pressure ) = 0;
489
490
491 };
492
493}
494
495
496#endif /* WOSS_DB_H */
497
498
3D-Coordinates (lat, long, depth) class definitions and functions library
Definition coordinates-definitions.h:403
Coordinates (lat, long) class definitions and functions library.
Definition coordinates-definitions.h:107
Complex attenuated pressure class.
Definition pressure-definitions.h:59
SSP class offers multiple creation and manipulation capabilities for sound speed profile.
Definition ssp-definitions.h:258
Surficial sediment geoacoustic parameters definitions.
Definition sediment-definitions.h:63
Channel power delay profile class.
Definition time-arrival-definitions.h:82
a class for time date manipulation
Definition time-definitions.h:95
Data behaviour class for bathymetry database.
Definition woss-db.h:292
virtual bool insertValue(const Coord &coordinates, const Bathymetry &bathymetry_value)=0
virtual Bathymetry getValue(const Coord &coords) const =0
Abstract class that provides the interface of databases.
Definition woss-db.h:89
virtual bool isValid()
Definition woss-db.h:134
::std::string db_name
Definition woss-db.h:164
bool debug
Definition woss-db.h:170
bool isUsingDebug() const
Definition woss-db.h:127
virtual bool finalizeConnection()=0
PathName getPathName(const ::std::string &complete_path)
Definition woss-db.cpp:54
::std::string getDbName() const
Definition woss-db.h:114
virtual bool closeConnection()=0
virtual bool openConnection()=0
void setDebug(double flag=true)
Definition woss-db.h:121
void setDbName(const ::std::string &pathname)
Definition woss-db.h:108
NetCDF implementation of WossDb.
Definition woss-db.h:193
virtual bool openConnection()
Definition woss-db.cpp:97
virtual bool closeConnection()
Definition woss-db.cpp:113
netCDF::NcFile * netcdf_db
Definition woss-db.h:229
Data behaviour class for storing calculated Pressure.
Definition woss-db.h:458
virtual Pressure * getValue(const CoordZ &coord_tx, const CoordZ &coord_rx, const double frequency, const Time &time_value) const =0
virtual bool insertValue(const CoordZ &coord_tx, const CoordZ &coord_rx, const double frequency, const Time &time_value, const Pressure &pressure)=0
Data behaviour class for storing calculated TimeArr.
Definition woss-db.h:416
virtual bool insertValue(const CoordZ &coord_tx, const CoordZ &coord_rx, const double frequency, const Time &time_value, const TimeArr &channel)=0
virtual TimeArr * getValue(const CoordZ &coord_tx, const CoordZ &coord_rx, const double frequency, const Time &time_value) const =0
Data behaviour class for SSP database.
Definition woss-db.h:375
virtual bool insertValue(const Coord &coordinates, const Time &time_value, const SSP &ssp_value)=0
virtual SSP * getValue(const Coord &coords, const Time &time, long double ssp_depth_precision) const =0
Data behaviour class for Sediment database.
Definition woss-db.h:328
virtual Sediment * getValue(const CoordZ &coords) const =0
virtual bool insertValue(const Coord &coordinates, const Sediment &sediment_value)=0
virtual Sediment * getValue(const CoordZVector &coordz_vector) const =0
Textual implementation of WossDb.
Definition woss-db.h:245
::std::fstream textual_db
Definition woss-db.h:279
virtual bool openConnection()
Definition woss-db.cpp:137
virtual bool closeConnection()
Definition woss-db.cpp:142
Provides the interface for the woss::Coord and woss::CoordZ classes.
::std::vector< CoordZ > CoordZVector
Definition coordinates-definitions.h:64
Generic functions and variables
::std::pair< ::std::string, ::std::string > PathName
Definition woss-db.h:76