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
63
67 typedef ::std::set< double > FreqSet;
68 typedef FreqSet::iterator FreqSIt;
69 typedef FreqSet::const_iterator FreqSCIt;
70 typedef FreqSet::reverse_iterator FreqSRIt;
71 typedef FreqSet::const_reverse_iterator FreqSCRIt;
72
73
74 static const int WOSS_MIN_DEPTH = 0;
76 static const int WOSS_MAX_DEPTH = INT_MAX;
78 static const int WOSS_MIN_RANGE = -INT_MAX;
80 static const int WOSS_MAX_RANGE = INT_MAX;
89 class Woss {
90
91
92 public:
93
94
98 Woss();
99
110 Woss( const CoordZ& tx, const CoordZ& rx, const Time& start_t, const Time& end_t, double start_freq, double end_freq, double freq_step ) ;
111
112 virtual ~Woss();
113
114
119 virtual bool initialize() = 0;
120
121
127 virtual bool run() = 0;
128
129
135 virtual bool timeEvolve( const Time& time_value ) = 0;
136
137
142 virtual bool isValid() const = 0;
143
144
155 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;
156
165 virtual Pressure* getPressure( double frequency, double tx_depth, double rx_depth, double rx_range ) const = 0;
166
167
176 virtual TimeArr* getTimeArr( double frequency, double tx_depth, double rx_depth, double rx_range ) const = 0;
177
178
184 Woss& setDebug( bool flag ) { debug = flag; return *this; }
185
191 Woss& setCleanWorkDir( bool flag ) { clean_workdir = flag; return *this; }
192
193
199 Woss& setWorkDirPath( const ::std::string& path ) { work_dir_path = path; return *this; }
200
206 Woss& setWossDbManager( const WossDbManager* const ptr ) { db_manager = ptr; return *this; }
207
208
214 Woss& insertFrequency( double freq ) { frequencies.insert(freq); return *this; }
215
223 Woss& insertFrequencies( double freq_start, double freq_end, double freq_step );
224
230 Woss& setFrequencies( const FreqSet& freq_set ) { frequencies = freq_set; return *this; }
231
237 Woss& eraseFrequency( double freq ) { frequencies.erase(freq); return *this; }
238
243 Woss& clearFrequencies() { frequencies.clear(); return *this; }
244
245
251 Woss& setTotalRuns( int runs ) { total_runs = runs; return *this; }
252
258 Woss& setTxCoordZ( const CoordZ& coordz ) { tx_coordz = coordz; return *this; }
259
265 Woss& setRxCoordZ( const CoordZ& coordz ) { rx_coordz = coordz; return *this; }
266
267
273 Woss& setStartTime( const Time& start_t ) { start_time = start_t; return *this; }
274
280 Woss& setEndTime( const Time& end_t ) { end_time = end_t; return *this; }
281
287 Woss& setEvolutionTimeQuantum( double value ) { evolution_time_quantum = value; return *this; }
288
289
294 int getWossId() const { return woss_id; }
295
300 ::std::string getWorkDirPath() const { return work_dir_path; }
301
302
307 const FreqSet& getFrequencies() const { return frequencies; }
308
313 double getMinFrequency() const { return( *( frequencies.begin() ) ); }
314
319 double getMaxFrequency() const { return( *( frequencies.rbegin() ) ); }
320
321
326 FreqSCIt freq_begin() const { return( frequencies.begin() ); }
327
332 FreqSCIt freq_end() const { return( frequencies.end() ); }
333
338 FreqSCRIt freq_rbegin() const { return( frequencies.rbegin() ); }
339
344 FreqSCRIt freq_rend() const { return( frequencies.rend() ); }
345
351 FreqSCIt freq_lower_bound( double frequency ) const { return( frequencies.lower_bound( frequency ) ); }
352
358 FreqSCIt freq_upper_bound( double frequency ) const { return( frequencies.upper_bound( frequency ) ); }
359
360
365 int getTotalRuns() const { return total_runs; }
366
367
372 CoordZ getTxCoordZ() const { return tx_coordz; }
373
378 CoordZ getRxCoordZ() const { return rx_coordz; }
379
380
385 Time getStartTime() const { return start_time; }
386
391 Time getCurrentTime() const { return current_time; }
392
397 Time getEndTime() const { return end_time; }
398
404
411
416 double getDistance() const { return total_distance; }
417
422 double getBearing() const { return bearing; }
423
427 bool usingDebug() const { return debug; }
428
432 virtual bool isRunning() const;
433
434
435 protected:
436
437
438#ifdef WOSS_MULTITHREAD
442 static pthread_spinlock_t woss_mutex;
443
444 friend void destroyWossSpinlock();
445#endif // WOSS_MULTITHREAD
446
450 static int woss_counter;
451
456
457
461 ::std::string work_dir_path;
462
463
468
469
474
479
484
491
496
501
502
507
508
513 double bearing;
514
520
526
531
532
536 bool debug;
537
538
539 bool has_run_once;
540
541
545 volatile bool is_running;
546
551
558 virtual bool mkWorkDir( double curr_frequency, int curr_run = 0 );
559
566 virtual bool rmWorkDir( double curr_frequency, int curr_run = 0 );
567
568 virtual bool rmWorkDir();
569
570
571 };
572
573
574#ifdef WOSS_MULTITHREAD
578 void destroyWossSpinlock();
579#endif // WOSS_MULTITHREAD
580
581
585 typedef ::std::map< double, ResReader* > ResReaderMap;
586 typedef ResReaderMap::iterator RRMIter;
587 typedef ResReaderMap::reverse_iterator RRMRIter;
588 typedef ResReaderMap::const_iterator RRMCIter;
589 typedef ResReaderMap::const_reverse_iterator RRMCRIter;
590 typedef ::std::pair< RRMIter, bool > RRMPair;
591
592
599 class WossResReader : public Woss {
600
601
602 public:
603
604
609
620 WossResReader( const CoordZ& tx, const CoordZ& rx, const Time& start_t, const Time& end_t,
621 double start_freq, double end_freq, double freq_step )
622 : Woss( tx, rx, start_t, end_t, start_freq, end_freq, freq_step ) { }
623
624
625 virtual ~WossResReader() { clearResReaderMap(); }
626
627
633 virtual bool initResReader( double curr_frequency ) = 0;
634
635
636 protected:
637
638
643
644
648 void clearResReaderMap();
649
650
651 };
652
653}
654
655#endif /* WOSS_PROGRAM_DEFINITIONS_H */
656
657
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:599
WossResReader()
Definition woss.h:608
ResReaderMap res_reader_map
Definition woss.h:642
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:620
Abstract class that provides the interface for initializing and running a channel simulator.
Definition woss.h:89
Woss & setWorkDirPath(const ::std::string &path)
Definition woss.h:199
Woss & setStartTime(const Time &start_t)
Definition woss.h:273
virtual bool mkWorkDir(double curr_frequency, int curr_run=0)
Definition woss.cpp:188
CoordZ getRxCoordZ() const
Definition woss.h:378
Time getStartTime() const
Definition woss.h:385
double getDistance() const
Definition woss.h:416
Woss & insertFrequencies(double freq_start, double freq_end, double freq_step)
Definition woss.cpp:160
double evolution_time_quantum
Definition woss.h:490
FreqSCRIt freq_rbegin() const
Definition woss.h:338
Woss & setCleanWorkDir(bool flag)
Definition woss.h:191
virtual bool run()=0
double bearing
Definition woss.h:513
CoordZ tx_coordz
Definition woss.h:495
static int woss_counter
Definition woss.h:450
int getWossId() const
Definition woss.h:294
FreqSCRIt freq_rend() const
Definition woss.h:344
virtual Pressure * getPressure(double frequency, double tx_depth, double rx_depth, double rx_range) const =0
Woss & setRxCoordZ(const CoordZ &coordz)
Definition woss.h:265
Woss & setFrequencies(const FreqSet &freq_set)
Definition woss.h:230
Woss & setTxCoordZ(const CoordZ &coordz)
Definition woss.h:258
CoordZ getTxCoordZ() const
Definition woss.h:372
int getTotalRuns() const
Definition woss.h:365
const FreqSet & getFrequencies() const
Definition woss.h:307
Woss & setEndTime(const Time &end_t)
Definition woss.h:280
::std::string getWorkDirPath() const
Definition woss.h:300
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:319
bool debug
Definition woss.h:536
FreqSCIt freq_begin() const
Definition woss.h:326
Woss & clearFrequencies()
Definition woss.h:243
virtual bool initialize()=0
Definition woss.cpp:226
Woss & insertFrequency(double freq)
Definition woss.h:214
Woss()
Definition woss.cpp:75
Time current_time
Definition woss.h:478
FreqSCIt freq_upper_bound(double frequency) const
Definition woss.h:358
FreqSet frequencies
Definition woss.h:506
Time end_time
Definition woss.h:483
Time start_time
Definition woss.h:473
volatile bool is_running
Definition woss.h:545
double total_great_circle_distance
Definition woss.h:519
FreqSCIt freq_end() const
Definition woss.h:332
double getMinFrequency() const
Definition woss.h:313
Woss & setDebug(bool flag)
Definition woss.h:184
Woss & setEvolutionTimeQuantum(double value)
Definition woss.h:287
const WossDbManager * db_manager
Definition woss.h:467
double getGreatCircleDistance() const
Definition woss.h:410
int total_runs
Definition woss.h:530
bool usingDebug() const
Definition woss.h:427
friend void destroyWossSpinlock()
Definition woss.cpp:56
bool clean_workdir
Definition woss.h:550
static pthread_spinlock_t woss_mutex
Definition woss.h:442
::std::string work_dir_path
Definition woss.h:461
Woss & setTotalRuns(int runs)
Definition woss.h:251
virtual TimeArr * getTimeArr(double frequency, double tx_depth, double rx_depth, double rx_range) const =0
Time getEndTime() const
Definition woss.h:397
double getBearing() const
Definition woss.h:422
int woss_id
Definition woss.h:455
Woss & setWossDbManager(const WossDbManager *const ptr)
Definition woss.h:206
virtual bool rmWorkDir(double curr_frequency, int curr_run=0)
Definition woss.cpp:209
CoordZ rx_coordz
Definition woss.h:500
virtual bool isValid() const =0
double total_distance
Definition woss.h:525
virtual bool timeEvolve(const Time &time_value)=0
Woss & eraseFrequency(double freq)
Definition woss.h:237
double getEvolutionTimeQuantum() const
Definition woss.h:403
Time getCurrentTime() const
Definition woss.h:391
FreqSCIt freq_lower_bound(double frequency) const
Definition woss.h:351
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:67
::std::map< double, ResReader * > ResReaderMap
Definition woss.h:585