World Ocean Simulation System (WOSS) library
woss.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_PROGRAM_DEFINITIONS_H
41#define WOSS_PROGRAM_DEFINITIONS_H
42
43
44#include <set>
45#include <vector>
46#include <map>
47#include <climits>
49#include <time-definitions.h>
50#include "res-reader.h"
51
52
53#ifdef WOSS_MULTITHREAD
54#include <pthread.h>
55#endif // WOSS_MULTITHREAD
56
57
58namespace woss {
59
60
61 class WossDbManager;
62
66 typedef ::std::vector< double > RangeVector;
67
68
72 typedef ::std::set< double > FreqSet;
73 typedef FreqSet::iterator FreqSIt;
74 typedef FreqSet::const_iterator FreqSCIt;
75 typedef FreqSet::reverse_iterator FreqSRIt;
76 typedef FreqSet::const_reverse_iterator FreqSCRIt;
77
78
79 static const int WOSS_MIN_DEPTH = 0;
81 static const int WOSS_MAX_DEPTH = INT_MAX;
83 static const int WOSS_MIN_RANGE = -INT_MAX;
85 static const int WOSS_MAX_RANGE = INT_MAX;
94 class Woss {
95
96
97 public:
98
99
103 Woss();
104
115 Woss( const CoordZ& tx, const CoordZ& rx, const Time& start_t, const Time& end_t, double start_freq, double end_freq, double freq_step ) ;
116
117 virtual ~Woss();
118
119
124 virtual bool initialize() = 0;
125
126
132 virtual bool run() = 0;
133
134
140 virtual bool timeEvolve( const Time& time_value ) = 0;
141
142
147 virtual bool isValid() const = 0;
148
149
160 virtual Pressure* getAvgPressure( double frequency, double tx_depth, double start_rx_depth = WOSS_MIN_DEPTH, double start_rx_range = WOSS_MIN_RANGE, double end_rx_depth = WOSS_MAX_DEPTH , double end_rx_range = WOSS_MAX_RANGE ) const = 0;
161
170 virtual Pressure* getPressure( double frequency, double tx_depth, double rx_depth, double rx_range ) const = 0;
171
172
181 virtual TimeArr* getTimeArr( double frequency, double tx_depth, double rx_depth, double rx_range ) const = 0;
182
183
189 Woss& setDebug( bool flag ) { debug = flag; return *this; }
190
196 Woss& setCleanWorkDir( bool flag ) { clean_workdir = flag; return *this; }
197
198
204 Woss& setWorkDirPath( const ::std::string& path ) { work_dir_path = path; return *this; }
205
211 Woss& setWossDbManager( const WossDbManager* const ptr ) { db_manager = ptr; return *this; }
212
213
219 Woss& insertFrequency( double freq ) { frequencies.insert(freq); return *this; }
220
228 Woss& insertFrequencies( double freq_start, double freq_end, double freq_step );
229
235 Woss& setFrequencies( const FreqSet& freq_set ) { frequencies = freq_set; return *this; }
236
242 Woss& eraseFrequency( double freq ) { frequencies.erase(freq); return *this; }
243
248 Woss& clearFrequencies() { frequencies.clear(); return *this; }
249
250
256 Woss& setTotalRuns( int runs ) { total_runs = runs; return *this; }
257
263 Woss& setTxCoordZ( const CoordZ& coordz ) { tx_coordz = coordz; return *this; }
264
270 Woss& setRxCoordZ( const CoordZ& coordz ) { rx_coordz = coordz; return *this; }
271
272
278 Woss& setStartTime( const Time& start_t ) { start_time = start_t; return *this; }
279
285 Woss& setEndTime( const Time& end_t ) { end_time = end_t; return *this; }
286
292 Woss& setEvolutionTimeQuantum( double value ) { evolution_time_quantum = value; return *this; }
293
294
299 int getWossId() const { return woss_id; }
300
305 ::std::string getWorkDirPath() const { return work_dir_path; }
306
307
312 const FreqSet& getFrequencies() const { return frequencies; }
313
318 double getMinFrequency() const { return( *( frequencies.begin() ) ); }
319
324 double getMaxFrequency() const { return( *( frequencies.rbegin() ) ); }
325
326
331 FreqSCIt freq_begin() const { return( frequencies.begin() ); }
332
337 FreqSCIt freq_end() const { return( frequencies.end() ); }
338
343 FreqSCRIt freq_rbegin() const { return( frequencies.rbegin() ); }
344
349 FreqSCRIt freq_rend() const { return( frequencies.rend() ); }
350
356 FreqSCIt freq_lower_bound( double frequency ) const { return( frequencies.lower_bound( frequency ) ); }
357
363 FreqSCIt freq_upper_bound( double frequency ) const { return( frequencies.upper_bound( frequency ) ); }
364
365
370 int getTotalRuns() const { return total_runs; }
371
372
377 CoordZ getTxCoordZ() const { return tx_coordz; }
378
383 CoordZ getRxCoordZ() const { return rx_coordz; }
384
385
390 Time getStartTime() const { return start_time; }
391
396 Time getCurrentTime() const { return current_time; }
397
402 Time getEndTime() const { return end_time; }
403
409
416
421 double getDistance() const { return total_distance; }
422
427 double getBearing() const { return bearing; }
428
432 bool usingDebug() const { return debug; }
433
437 virtual bool isRunning() const;
438
439
440 protected:
441
442
443 #ifdef WOSS_MULTITHREAD
447 static pthread_spinlock_t woss_mutex;
448
449 friend void destroyWossSpinlock();
450
451 #endif // WOSS_MULTITHREAD
452
456 static int woss_counter;
457
462
463
467 ::std::string work_dir_path;
468
469
474
475
480
485
490
497
502
507
508
513
514
519 double bearing;
520
526
532
537
538
542 bool debug;
543
544
545 bool has_run_once;
546
547
551 volatile bool is_running;
552
557
564 virtual bool mkWorkDir( double curr_frequency, int curr_run = 0 );
565
572 virtual bool rmWorkDir( double curr_frequency, int curr_run = 0 );
573
574 virtual bool rmWorkDir();
575
576
577 };
578
579
580 #ifdef WOSS_MULTITHREAD
581
585 void destroyWossSpinlock();
586
587 #endif // WOSS_MULTITHREAD
588
589
593 typedef ::std::map< double, ResReader* > ResReaderMap;
594 typedef ResReaderMap::iterator RRMIter;
595 typedef ResReaderMap::reverse_iterator RRMRIter;
596 typedef ResReaderMap::const_iterator RRMCIter;
597 typedef ResReaderMap::const_reverse_iterator RRMCRIter;
598 typedef ::std::pair< RRMIter, bool > RRMPair;
599
600
607 class WossResReader : public Woss {
608
609
610 public:
611
612
617
628 WossResReader( const CoordZ& tx, const CoordZ& rx, const Time& start_t, const Time& end_t,
629 double start_freq, double end_freq, double freq_step )
630 : Woss( tx, rx, start_t, end_t, start_freq, end_freq, freq_step ) { }
631
632
633 virtual ~WossResReader() { clearResReaderMap(); }
634
635
641 virtual bool initResReader( double curr_frequency ) = 0;
642
643
644 protected:
645
646
651
652
656 void clearResReaderMap();
657
658
659 };
660
661
662}
663
664
665#endif /* WOSS_PROGRAM_DEFINITIONS_H */
666
667
3D-Coordinates (lat, long, depth) class definitions and functions library
Definition coordinates-definitions.h:403
Complex attenuated pressure class.
Definition pressure-definitions.h:59
Channel power delay profile class.
Definition time-arrival-definitions.h:82
a class for time date manipulation
Definition time-definitions.h:95
Abstraction layer for database and data manipulation.
Definition woss-db-manager.h:84
Woss class with ResReader objects for reading simulated results.
Definition woss.h:607
WossResReader()
Definition woss.h:616
ResReaderMap res_reader_map
Definition woss.h:650
void clearResReaderMap()
Definition woss.cpp:256
virtual bool initResReader(double curr_frequency)=0
WossResReader(const CoordZ &tx, const CoordZ &rx, const Time &start_t, const Time &end_t, double start_freq, double end_freq, double freq_step)
Definition woss.h:628
Abstract class that provides the interface for initializing and running a channel simulator.
Definition woss.h:94
Woss & setWorkDirPath(const ::std::string &path)
Definition woss.h:204
Woss & setStartTime(const Time &start_t)
Definition woss.h:278
virtual bool mkWorkDir(double curr_frequency, int curr_run=0)
Definition woss.cpp:188
CoordZ getRxCoordZ() const
Definition woss.h:383
Time getStartTime() const
Definition woss.h:390
double getDistance() const
Definition woss.h:421
Woss & insertFrequencies(double freq_start, double freq_end, double freq_step)
Definition woss.cpp:160
double evolution_time_quantum
Definition woss.h:496
FreqSCRIt freq_rbegin() const
Definition woss.h:343
Woss & setCleanWorkDir(bool flag)
Definition woss.h:196
virtual bool run()=0
double bearing
Definition woss.h:519
CoordZ tx_coordz
Definition woss.h:501
static int woss_counter
Definition woss.h:456
int getWossId() const
Definition woss.h:299
FreqSCRIt freq_rend() const
Definition woss.h:349
virtual Pressure * getPressure(double frequency, double tx_depth, double rx_depth, double rx_range) const =0
Woss & setRxCoordZ(const CoordZ &coordz)
Definition woss.h:270
Woss & setFrequencies(const FreqSet &freq_set)
Definition woss.h:235
Woss & setTxCoordZ(const CoordZ &coordz)
Definition woss.h:263
CoordZ getTxCoordZ() const
Definition woss.h:377
int getTotalRuns() const
Definition woss.h:370
const FreqSet & getFrequencies() const
Definition woss.h:312
Woss & setEndTime(const Time &end_t)
Definition woss.h:285
::std::string getWorkDirPath() const
Definition woss.h:305
virtual bool isRunning() const
Definition woss.cpp:239
virtual Pressure * getAvgPressure(double frequency, double tx_depth, double start_rx_depth=WOSS_MIN_DEPTH, double start_rx_range=WOSS_MIN_RANGE, double end_rx_depth=WOSS_MAX_DEPTH, double end_rx_range=WOSS_MAX_RANGE) const =0
double getMaxFrequency() const
Definition woss.h:324
bool debug
Definition woss.h:542
FreqSCIt freq_begin() const
Definition woss.h:331
Woss & clearFrequencies()
Definition woss.h:248
virtual bool initialize()=0
Definition woss.cpp:226
Woss & insertFrequency(double freq)
Definition woss.h:219
Woss()
Definition woss.cpp:75
Time current_time
Definition woss.h:484
FreqSCIt freq_upper_bound(double frequency) const
Definition woss.h:363
FreqSet frequencies
Definition woss.h:512
Time end_time
Definition woss.h:489
Time start_time
Definition woss.h:479
volatile bool is_running
Definition woss.h:551
double total_great_circle_distance
Definition woss.h:525
FreqSCIt freq_end() const
Definition woss.h:337
double getMinFrequency() const
Definition woss.h:318
Woss & setDebug(bool flag)
Definition woss.h:189
Woss & setEvolutionTimeQuantum(double value)
Definition woss.h:292
const WossDbManager * db_manager
Definition woss.h:473
double getGreatCircleDistance() const
Definition woss.h:415
int total_runs
Definition woss.h:536
bool usingDebug() const
Definition woss.h:432
friend void destroyWossSpinlock()
Definition woss.cpp:56
bool clean_workdir
Definition woss.h:556
static pthread_spinlock_t woss_mutex
Definition woss.h:447
::std::string work_dir_path
Definition woss.h:467
Woss & setTotalRuns(int runs)
Definition woss.h:256
virtual TimeArr * getTimeArr(double frequency, double tx_depth, double rx_depth, double rx_range) const =0
Time getEndTime() const
Definition woss.h:402
double getBearing() const
Definition woss.h:427
int woss_id
Definition woss.h:461
Woss & setWossDbManager(const WossDbManager *const ptr)
Definition woss.h:211
virtual bool rmWorkDir(double curr_frequency, int curr_run=0)
Definition woss.cpp:209
CoordZ rx_coordz
Definition woss.h:506
virtual bool isValid() const =0
double total_distance
Definition woss.h:531
virtual bool timeEvolve(const Time &time_value)=0
Woss & eraseFrequency(double freq)
Definition woss.h:242
double getEvolutionTimeQuantum() const
Definition woss.h:408
Time getCurrentTime() const
Definition woss.h:396
FreqSCIt freq_lower_bound(double frequency) const
Definition woss.h:356
Provides the interface for the woss::Coord and woss::CoordZ classes.
Provides the interface for woss::ResReader class.
Definitions and library for woss::Time, woss::SimTime, woss::TimeReference and woss::TimeReferenceTcl...
void destroyWossSpinlock()
Definition woss.cpp:56
::std::set< double > FreqSet
Definition woss.h:72
::std::map< double, ResReader * > ResReaderMap
Definition woss.h:593
::std::vector< double > RangeVector
Definition woss.h:66