33#ifndef WOSS_CREATOR_CONTAINER_DEFINITIONS_H
34#define WOSS_CREATOR_CONTAINER_DEFINITIONS_H
61 CustomTransducer(
const std::string& name =
"",
double bearing = 0.0,
double vert_rot = 0.0,
double horiz_rot = 0.0,
double mult = 1.0,
double add = 0.0 )
111 template<
typename Data >
149 bool insert(
const Data& data,
const std::shared_ptr<Location>& tx,
const std::shared_ptr<Location>& rx );
166 Data
get(
const std::shared_ptr<Location>& tx,
const std::shared_ptr<Location>& rx )
const;
188 void erase(
const std::shared_ptr<Location>& tx,
const std::shared_ptr<Location>& rx );
204 void replace(
const Data& data,
const std::shared_ptr<Location>& tx,
const std::shared_ptr<Location>& rx );
238 using ICIter =
typename InnerContainer::iterator;
239 using ICRIter =
typename InnerContainer::reverse_iterator;
240 using ICCIter =
typename InnerContainer::const_iterator;
241 using ICCRIter =
typename InnerContainer::const_reverse_iterator;
247 using DCIter =
typename DataContainer::iterator;
248 using DCCIter =
typename DataContainer::const_iterator;
249 using DCRIter =
typename DataContainer::reverse_iterator;
250 using DCRCIter =
typename DataContainer::const_reverse_iterator;
289 template<
typename Data >
293 template<
typename Data >
297 template<
typename Data >
299 return data_container.empty();
303 template<
typename Data >
305 return data_container.size();
309 template<
typename Data >
311 if ( coordinates == ALL_COORDZ )
317 template<
typename Data >
319 auto it_all_loc = data_container.end();
321 for (
auto it = data_container.begin(); it != data_container.end(); it++ ) {
322 if ( it->first == ALL_LOCATIONS ) {
324 if ( coordinates == ALL_COORDZ )
329 if ( it->first->isEquivalentTo( coordinates ) ) {
331 std::cout <<
"WossCreatorContainer::find() tx coordinates found = "
332 << coordinates << std::endl;
337 if ( coordinates == ALL_COORDZ && it_all_loc != data_container.end() ) {
339 std::cout <<
"WossCreatorContainer::find() tx ALL_COORDZ found" << std::endl;
343 if (debug && coordinates != ALL_COORDZ )
344 std::cout <<
"WossCreatorContainer::find() tx coordinates not found = "
345 << coordinates << std::endl;
347 if (debug && coordinates == ALL_COORDZ )
348 std::cout <<
"WossCreatorContainer::find() tx ALL_COORDZ not found" << std::endl;
349 return data_container.end();
353 template<
typename Data >
355 auto it_all_loc = iter->second.end();
357 for (
auto it = iter->second.begin(); it != iter->second.end(); it++ ) {
358 if ( it->first == ALL_LOCATIONS ) {
360 if ( coordinates == ALL_COORDZ )
365 if ( it->first->isEquivalentTo( coordinates ) ) {
367 std::cout <<
"WossCreatorContainer::find() rx coordinates found = "
368 << coordinates << std::endl;
373 if ( coordinates == ALL_COORDZ && it_all_loc != iter->second.end() ) {
375 std::cout <<
"WossCreatorContainer::find() rx ALL_COORDZ found" << std::endl;
379 if (debug && coordinates != ALL_COORDZ )
380 std::cout <<
"WossCreatorContainer::find() rx coordinates not found = "
381 << coordinates << std::endl;
383 if (debug && coordinates == ALL_COORDZ )
384 std::cout <<
"WossCreatorContainer::find() rx ALL_COORDZ not found" << std::endl;
385 return iter->second.end();
389 template<
typename Data >
391 auto it = data_container.find(tx);
392 if ( it == data_container.end() ) {
393 data_container[tx][rx] = data;
396 auto it2 = it->second.find(rx);
397 if ( it2 == it->second.end() ) {
398 (it->second)[rx] = data;
405 template<
typename Data >
407 auto it = find( tx );
408 if ( it == data_container.end() ) {
409 data_container[ createLocation(tx) ][ createLocation(rx) ] = data;
412 auto it2 = find( rx, it );
413 if ( it2 == it->second.end() ) {
414 (it->second)[ createLocation(rx) ] = data;
421 template<
typename Data >
425 if ( tx != ALL_LOCATIONS ) {
426 if ( it == data_container.end() ) {
428 std::cout <<
"WossCreatorContainer::get() no tx location found = " << *tx
429 <<
"; trying ALL_LOCATIONS"<< std::endl;
435 std::cout <<
"WossCreatorContainer::get() tx location found = " << *tx << std::endl;
438 if ( it != data_container.end() ) {
439 auto it2 = it->second.find( rx );
441 if ( rx != ALL_LOCATIONS ) {
442 if ( it2 == it->second.end() ) {
444 std::cout <<
"WossCreatorContainer::get() no rx location found = " << *rx
445 <<
"; trying ALL_LOCATIONS"<< std::endl;
447 it2 = it->second.find( ALL_LOCATIONS );
451 std::cout <<
"WossCreatorContainer::get() rx location found = " << *rx << std::endl;
454 if ( it2 != it->second.end() )
458 std::cerr <<
"WARNING: WossCreatorContainer::get() no tx nor rx location found, returning default constructor!!" << std::endl;
464 template<
typename Data >
466 return data_container[ALL_LOCATIONS][ALL_LOCATIONS];
470 template<
typename Data >
474 if ( tx != ALL_COORDZ ) {
475 if ( it == data_container.end() )
479 if ( it != data_container.end() ) {
480 auto it2 =
const_cast< WossCreatorContainer< Data >&
>(*this).find( rx, it );
482 if ( rx != ALL_COORDZ ) {
483 if ( it2 == it->second.end() )
484 it2 =
const_cast< WossCreatorContainer< Data >&
>(*this).find( ALL_COORDZ, it );
487 if ( it2 != it->second.end() ) {
489 std::cout <<
"WossCreatorContainer::get() value found = " << it2->second << std::endl;
494 std::cerr <<
"WARNING: WossCreatorContainer::get() no tx nor rx coordinates found, returning default constructor!!" << std::endl;
500 template<
typename Data >
502 auto it = data_container.find(tx);
503 if ( it != data_container.end() )
504 it->second.erase( rx );
505 if ( it->second.empty() )
506 data_container.erase(it);
510 template<
typename Data >
512 for (
auto it = data_container.begin(); it != data_container.end(); ) {
513 bool tx_found =
false;
515 if ( it->first != ALL_LOCATIONS ) {
516 if ( it->first->isEquivalentTo( tx ) )
519 if ( tx == ALL_COORDZ )
524 for (
auto it2 = it->second.begin(); it2 != it->second.end(); ) {
525 bool rx_found =
false;
527 if ( it2->first != ALL_LOCATIONS ) {
528 if ( it2->first->isEquivalentTo( rx ) )
531 if ( rx == ALL_COORDZ )
536 it->second.erase(it2++);
543 if ( it->second.empty() )
544 data_container.erase(it++);
550 template<
typename Data >
552 data_container[tx][rx] = data;
556 template<
typename Data >
558 data_container[ createLocation(tx) ][ createLocation(rx) ] = data;
562 template<
typename Data >
564 data_container.clear();
600 bool insert(
const CustomTransducer& data,
const std::shared_ptr<Location>& tx,
const std::shared_ptr<Location>& rx );
642 void erase(
const std::shared_ptr<Location>& tx,
const std::shared_ptr<Location>& rx );
659 void replace(
const CustomTransducer& data,
const std::shared_ptr<Location>& tx,
const std::shared_ptr<Location>& rx );
680 using ICRIter = InnerContainer::reverse_iterator;
681 using ICCIter = InnerContainer::const_iterator ;
682 using ICCRIter = InnerContainer::const_reverse_iterator;
686 using DCCIter = DataContainer::const_iterator;
687 using DCRIter = DataContainer::reverse_iterator;
688 using DCRCIter = DataContainer::const_reverse_iterator;
726 auto it2 = it->second.find(rx);
727 if ( it2 == it->second.end() ) {
728 (it->second)[rx] = data;
736 auto it =
find( tx );
741 auto it2 =
find( rx, it );
742 if ( it2 == it->second.end() ) {
759 ICIter it2 = it->second.find( rx );
761 if ( it2 != it->second.end() ) {
762 it->second.erase( it2 );
766 if ( it->second.empty() ) {
774 bool tx_found =
false;
777 if ( it->first->isEquivalentTo( tx ) )
785 for (
ICIter it2 = it->second.begin(); it2 != it->second.end(); ) {
786 bool rx_found =
false;
789 if ( it2->first->isEquivalentTo( rx ) )
797 it->second.erase(it2++);
802 if ( it->second.empty() ) {
3D-Coordinates (lat, long, depth) class definitions and functions library
Definition coordinates-definitions.h:384
static T & instance()
Definition singleton-definitions.h:90
DataContainer::reverse_iterator DCRIter
Definition woss-creator-container.h:687
DataContainer::iterator DCIter
Definition woss-creator-container.h:685
ICIter find(const CoordZ &coordinates, const DCIter &iter)
InnerContainer::reverse_iterator ICRIter
Definition woss-creator-container.h:680
void setDebug(bool flag)
Definition woss-creator-container.h:672
std::map< std::shared_ptr< Location >, InnerContainer > DataContainer
Definition woss-creator-container.h:684
InnerContainer::const_reverse_iterator ICCRIter
Definition woss-creator-container.h:682
DataContainer data_container
Definition woss-creator-container.h:696
static const CoordZ ALL_COORDZ
Definition woss-creator-container.h:582
DataContainer::const_reverse_iterator DCRCIter
Definition woss-creator-container.h:688
CustomTransducer get(const std::shared_ptr< Location > &tx, const std::shared_ptr< Location > &rx) const
InnerContainer::iterator ICIter
Definition woss-creator-container.h:679
bool isUsingDebug() const
Definition woss-creator-container.h:674
std::map< std::shared_ptr< Location >, CustomTransducer > InnerContainer
Definition woss-creator-container.h:678
WossCreatorContainer()=default
InnerContainer::const_iterator ICCIter
Definition woss-creator-container.h:681
~WossCreatorContainer()=default
CustomTransducer get(const CoordZ &tx, const CoordZ &rx) const
DCIter find(const CoordZ &coordinates)
DataContainer::const_iterator DCCIter
Definition woss-creator-container.h:686
static std::shared_ptr< Location > ALL_LOCATIONS
Definition woss-creator-container.h:580
Class that stores WossCreator parameters.
Definition woss-creator-container.h:112
std::map< std::shared_ptr< Location >, Data > InnerContainer
Definition woss-creator-container.h:237
static const CoordZ ALL_COORDZ
Definition woss-creator-container.h:124
typename DataContainer::const_iterator DCCIter
Definition woss-creator-container.h:248
WossCreatorContainer()=default
bool insert(const Data &data, const CoordZ &tx, const CoordZ &rx)
Definition woss-creator-container.h:406
~WossCreatorContainer()=default
typename DataContainer::iterator DCIter
Definition woss-creator-container.h:247
DCIter find(const CoordZ &coordinates)
Definition woss-creator-container.cpp:45
typename InnerContainer::reverse_iterator ICRIter
Definition woss-creator-container.h:239
Data & accessAllLocations()
Definition woss-creator-container.h:465
typename InnerContainer::const_reverse_iterator ICCRIter
Definition woss-creator-container.h:241
bool debug
Definition woss-creator-container.h:284
bool insert(const Data &data, const std::shared_ptr< Location > &tx, const std::shared_ptr< Location > &rx)
Definition woss-creator-container.h:390
Data get(const std::shared_ptr< Location > &tx, const std::shared_ptr< Location > &rx) const
Definition woss-creator-container.cpp:153
DataContainer data_container
Definition woss-creator-container.h:279
void clear()
Definition woss-creator-container.h:563
void replace(const Data &data, const std::shared_ptr< Location > &tx, const std::shared_ptr< Location > &rx)
Definition woss-creator-container.h:551
static std::shared_ptr< Location > ALL_LOCATIONS
Definition woss-creator-container.h:119
std::shared_ptr< Location > createLocation(const CoordZ &coordinates)
Definition woss-creator-container.h:310
typename InnerContainer::iterator ICIter
Definition woss-creator-container.h:238
typename DataContainer::reverse_iterator DCRIter
Definition woss-creator-container.h:249
typename DataContainer::const_reverse_iterator DCRCIter
Definition woss-creator-container.h:250
typename InnerContainer::const_iterator ICCIter
Definition woss-creator-container.h:240
void setDebug(bool flag)
Definition woss-creator-container.h:224
int size() const
Definition woss-creator-container.h:304
void replace(const Data &data, const CoordZ &tx, const CoordZ &rx)
Definition woss-creator-container.h:557
void erase(const CoordZ &tx, const CoordZ &rx)
Definition woss-creator-container.h:511
std::map< std::shared_ptr< Location >, InnerContainer > DataContainer
Definition woss-creator-container.h:246
bool isUsingDebug() const
Definition woss-creator-container.h:230
void erase(const std::shared_ptr< Location > &tx, const std::shared_ptr< Location > &rx)
Definition woss-creator-container.h:501
bool isEmpty() const
Definition woss-creator-container.h:298
Provides the interface for woss::DefHandler class.
Definition ac-toolbox-arr-asc-reader.h:44
Initial set up of a transducer.
Definition woss-creator-container.h:52
double initial_vert_rotation
Definition woss-creator-container.h:86
double initial_bearing
Definition woss-creator-container.h:81
double add_costant
Definition woss-creator-container.h:101
friend std::ostream & operator<<(std::ostream &os, const CustomTransducer &instance)
Definition woss-creator-container.h:64
CustomTransducer(const std::string &name="", double bearing=0.0, double vert_rot=0.0, double horiz_rot=0.0, double mult=1.0, double add=0.0)
Definition woss-creator-container.h:61
double initial_horiz_rotation
Definition woss-creator-container.h:91
std::string type
Definition woss-creator-container.h:76
double multiply_costant
Definition woss-creator-container.h:96