40#ifndef WOSS_CREATOR_CONTAINER_DEFINITIONS_H
41#define WOSS_CREATOR_CONTAINER_DEFINITIONS_H
67 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 )
71 friend std::ostream& operator<<( std::ostream& os,
const CustomTransducer& instance ) {
123 template<
typename Data >
268 typedef typename InnerContainer::iterator ICIter;
269 typedef typename InnerContainer::reverse_iterator ICRIter;
270 typedef typename InnerContainer::const_iterator ICCIter;
271 typedef typename InnerContainer::const_reverse_iterator ICCRIter;
278 typedef typename DataContainer::iterator DCIter;
279 typedef typename DataContainer::const_iterator DCCIter;
280 typedef typename DataContainer::reverse_iterator DCRIter;
281 typedef typename DataContainer::const_reverse_iterator DCRCIter;
299 ICIter
find(
const CoordZ& coordinates,
const DCIter& iter );
325 template<
typename Data >
328 template<
typename Data >
332 template<
typename Data >
340 template<
typename Data >
346 template<
typename Data >
348 return data_container.empty();
352 template<
typename Data >
354 return data_container.size();
358 template<
typename Data >
360 if ( coordinates == ALL_COORDZ )
return NULL;
365 template<
typename Data >
367 DCIter it_all_loc = data_container.end();
369 for ( DCIter it = data_container.begin(); it != data_container.end(); it++ ) {
370 if ( it->first == ALL_LOCATIONS ) {
372 if ( coordinates == ALL_COORDZ )
break;
375 if ( it->first->isEquivalentTo( coordinates ) ) {
376 if (debug) ::std::cout <<
"WossCreatorContainer::find() tx coordinates found = "
377 << coordinates << ::std::endl;
382 if ( coordinates == ALL_COORDZ && it_all_loc != data_container.end() ) {
383 if (debug) ::std::cout <<
"WossCreatorContainer::find() tx ALL_COORDZ found" << ::std::endl;
387 if (debug && coordinates != ALL_COORDZ ) ::std::cout <<
"WossCreatorContainer::find() tx coordinates not found = "
388 << coordinates << ::std::endl;
390 if (debug && coordinates == ALL_COORDZ ) ::std::cout <<
"WossCreatorContainer::find() tx ALL_COORDZ not found" << ::std::endl;
391 return data_container.end();
395 template<
typename Data >
397 ICIter it_all_loc = iter->second.end();
399 for ( ICIter it = iter->second.begin(); it != iter->second.end(); it++ ) {
400 if ( it->first == ALL_LOCATIONS ) {
402 if ( coordinates == ALL_COORDZ )
break;
405 if ( it->first->isEquivalentTo( coordinates ) ) {
406 if (debug) ::std::cout <<
"WossCreatorContainer::find() rx coordinates found = "
407 << coordinates << ::std::endl;
412 if ( coordinates == ALL_COORDZ && it_all_loc != iter->second.end() ) {
413 if (debug) ::std::cout <<
"WossCreatorContainer::find() rx ALL_COORDZ found" << ::std::endl;
417 if (debug && coordinates != ALL_COORDZ ) ::std::cout <<
"WossCreatorContainer::find() rx coordinates not found = "
418 << coordinates << ::std::endl;
420 if (debug && coordinates == ALL_COORDZ ) ::std::cout <<
"WossCreatorContainer::find() rx ALL_COORDZ not found" << ::std::endl;
421 return iter->second.end();
425 template<
typename Data >
427 DCIter it = data_container.find(tx);
428 if ( it == data_container.end() ) {
429 data_container[tx][rx] = data;
432 ICIter it2 = it->second.find(rx);
433 if ( it2 == it->second.end() ) {
434 (it->second)[rx] = data;
441 template<
typename Data >
443 DCIter it = find( tx );
444 if ( it == data_container.end() ) {
445 data_container[ createLocation(tx) ][ createLocation(rx) ] = data;
448 ICIter it2 = find( rx, it );
449 if ( it2 == it->second.end() ) {
450 (it->second)[ createLocation(rx) ] = data;
457 template<
typename Data >
461 if ( tx != ALL_LOCATIONS ) {
462 if ( it == data_container.end() ) {
463 if ( debug ) ::std::cout <<
"WossCreatorContainer::get() no tx location found = " << *tx
464 <<
"; trying ALL_LOCATIONS"<< ::std::endl;
469 if ( debug ) ::std::cout <<
"WossCreatorContainer::get() tx location found = " << *tx << ::std::endl;
473 if ( it != data_container.end() ) {
474 ICIter it2 = it->second.find( rx );
476 if ( rx != ALL_LOCATIONS ) {
478 if ( it2 == it->second.end() ) {
479 if ( debug ) ::std::cout <<
"WossCreatorContainer::get() no rx location found = " << *rx
480 <<
"; trying ALL_LOCATIONS"<< ::std::endl;
482 it2 = it->second.find( ALL_LOCATIONS );
485 if ( debug ) ::std::cout <<
"WossCreatorContainer::get() rx location found = " << *rx << ::std::endl;
489 if ( it2 != it->second.end() )
return it2->second;
492 ::std::cerr <<
"WARNING: WossCreatorContainer::get() no tx nor rx location found, returning default constructor!!" << ::std::endl;
498 template<
typename Data >
500 return data_container[ALL_LOCATIONS][ALL_LOCATIONS];
504 template<
typename Data >
508 if ( tx != ALL_COORDZ ) {
512 if ( it != data_container.end() ) {
513 ICIter it2 =
const_cast< WossCreatorContainer< Data >&
>(*this).find( rx, it );
515 if ( rx != ALL_COORDZ ) {
516 if ( it2 == it->second.end() ) it2 =
const_cast< WossCreatorContainer< Data >&
>(*this).find( ALL_COORDZ, it );
519 if ( it2 != it->second.end() ) {
520 if ( debug ) ::std::cout <<
"WossCreatorContainer::get() value found = " << it2->second << ::std::endl;
525 ::std::cerr <<
"WARNING: WossCreatorContainer::get() no tx nor rx coordinates found, returning default constructor!!" << ::std::endl;
531 template<
typename Data >
533 DCIter it = data_container.find(tx);
534 if ( it != data_container.end() ) it->second.erase( rx );
535 if ( it->second.empty() ) data_container.erase(it);
539 template<
typename Data >
541 for ( DCIter it = data_container.begin(); it != data_container.end(); ) {
543 if ( it->first->isEquivalentTo( tx ) ) {
545 for ( ICIter it2 = it->second.begin(); it2 != it->second.end(); ) {
546 if ( it2->first->isEquivalentTo( rx ) ) it->second.erase(it2++);
552 if ( it->second.empty() ) data_container.erase(it++);
558 template<
typename Data >
560 data_container[tx][rx] = data;
564 template<
typename Data >
566 data_container[ createLocation(tx) ][ createLocation(rx) ] = data;
570 template<
typename Data >
580 data_container.clear();
592 template<
typename Data >
599 static Location*
const ALL_LOCATIONS;
601 static const CoordZ ALL_COORDZ;
609 bool isEmpty()
const;
632 bool insert( Data* data,
const CoordZ& tx,
const CoordZ& rx );
658 Data*& accessAllLocations();
682 void replace( Data*
const data,
const CoordZ& tx,
const CoordZ& rx );
688 void setDebug(
bool flag ) { debug = flag; }
690 bool isUsingDebug()
const {
return debug; }
696 typedef ::std::map< Location*, Data* > InnerContainer;
697 typedef typename InnerContainer::iterator ICIter;
698 typedef typename InnerContainer::reverse_iterator ICRIter;
699 typedef typename InnerContainer::const_iterator ICCIter;
700 typedef typename InnerContainer::const_reverse_iterator ICCRIter;
703 typedef ::std::map< Location*, InnerContainer > DataContainer;
705 typedef typename DataContainer::iterator DCIter;
706 typedef typename DataContainer::const_iterator DCCIter;
707 typedef typename DataContainer::reverse_iterator DCRIter;
708 typedef typename DataContainer::const_reverse_iterator DCRCIter;
711 DCIter find(
const CoordZ& coordinates );
713 ICIter find(
const CoordZ& coordinates,
const DCIter& iter );
719 DataContainer data_container;
728 template<
typename Data >
731 template<
typename Data >
735 template<
typename Data >
743 template<
typename Data >
749 template<
typename Data >
751 return data_container.empty();
755 template<
typename Data >
757 return data_container.size();
761 template<
typename Data >
763 if ( coordinates == ALL_COORDZ )
return NULL;
764 return new Location( coordinates );
768 template<
typename Data >
770 DCIter it_all_loc = data_container.end();
772 for ( DCIter it = data_container.begin(); it != data_container.end(); it++ ) {
773 if ( it->first == ALL_LOCATIONS ) {
775 if ( coordinates == ALL_COORDZ )
break;
778 if ( it->first->isEquivalentTo( coordinates ) ) {
779 if (debug) ::std::cout <<
"WossCreatorContainer*::find() tx coordinates found = "
780 << coordinates << ::std::endl;
785 if ( coordinates == ALL_COORDZ && it_all_loc != data_container.end() ) {
786 if (debug) ::std::cout <<
"WossCreatorContainer*::find() tx ALL_COORDZ found" << ::std::endl;
790 if (debug && coordinates != ALL_COORDZ ) ::std::cout <<
"WossCreatorContainer*::find() tx coordinates not found = "
791 << coordinates << ::std::endl;
793 if (debug && coordinates == ALL_COORDZ ) ::std::cout <<
"WossCreatorContainer*::find() tx ALL_COORDZ not found" << ::std::endl;
794 return data_container.end();
798 template<
typename Data >
800 ICIter it_all_loc = iter->second.end();
802 for ( ICIter it = iter->second.begin(); it != iter->second.end(); it++ ) {
803 if ( it->first == ALL_LOCATIONS ) {
805 if ( coordinates == ALL_COORDZ )
break;
808 if ( it->first->isEquivalentTo( coordinates ) ) {
809 if (debug) ::std::cout <<
"WossCreatorContainer*::find() rx coordinates found = "
810 << coordinates << ::std::endl;
815 if ( coordinates == ALL_COORDZ && it_all_loc != iter->second.end() ) {
816 if (debug) ::std::cout <<
"WossCreatorContainer*::find() rx ALL_COORDZ found" << ::std::endl;
820 if (debug && coordinates != ALL_COORDZ ) ::std::cout <<
"WossCreatorContainer*::find() rx coordinates not found = "
821 << coordinates << ::std::endl;
823 if (debug && coordinates == ALL_COORDZ ) ::std::cout <<
"WossCreatorContainer*::find() rx ALL_COORDZ not found" << ::std::endl;
824 return iter->second.end();
828 template<
typename Data >
830 DCIter it = data_container.find(tx);
831 if ( it == data_container.end() ) {
832 data_container[tx][rx] = data;
835 ICIter it2 = it->second.find(rx);
836 if ( it2 == it->second.end() ) {
837 (it->second)[rx] = data;
847 template<
typename Data >
849 DCIter it = find( tx );
850 if ( it == data_container.end() ) {
851 data_container[ createLocation(tx) ][ createLocation(rx) ] = data;
854 ICIter it2 = find( rx, it );
855 if ( it2 == it->second.end() ) {
856 (it->second)[ createLocation(rx) ] = data;
866 template<
typename Data >
870 if ( tx != ALL_LOCATIONS ) {
871 if ( it == data_container.end() ) {
872 if ( debug ) ::std::cout <<
"WossCreatorContainer*::get() no tx location found = " << *tx
873 <<
"; trying ALL_LOCATIONS"<< ::std::endl;
878 if ( debug ) ::std::cout <<
"WossCreatorContainer*::get() tx location found = " << *tx << ::std::endl;
882 if ( it != data_container.end() ) {
883 ICIter it2 = it->second.find( rx );
885 if ( rx != ALL_LOCATIONS ) {
887 if ( it2 == it->second.end() ) {
888 if ( debug ) ::std::cout <<
"WossCreatorContainer*::get() no rx location found = " << *rx
889 <<
"; trying ALL_LOCATIONS"<< ::std::endl;
891 it2 = it->second.find( ALL_LOCATIONS );
894 if ( debug ) ::std::cout <<
"WossCreatorContainer*::get() rx location found = " << *rx << ::std::endl;
897 if ( it2 != it->second.end() )
return it2->second->
clone();
900 if ( debug ) ::std::cerr <<
"WARNING: WossCreatorContainer*::get() no tx nor rx location found, returning default constructor!!" << ::std::endl;
906 template<
typename Data >
908 return data_container[ALL_LOCATIONS][ALL_LOCATIONS];
912 template<
typename Data >
916 if ( tx != ALL_COORDZ ) {
920 if ( it != data_container.end() ) {
923 if ( rx != ALL_COORDZ ) {
927 if ( it2 != it->second.end() )
return it2->second->clone();
929 if ( debug ) ::std::cerr <<
"WARNING: WossCreatorContainer*::get() no tx nor rx coordinates found, returning default constructor!!" << ::std::endl;
935 template<
typename Data >
937 DCIter it = data_container.find(tx);
938 if ( it != data_container.end() ) {
940 ICIter it2 = it->second.find( rx );
942 if ( it2 != it->second.end() ) {
945 it->second.erase( it2 );
949 if ( it->second.empty() ) {
951 data_container.erase(it);
956 template<
typename Data >
958 for ( DCIter it = data_container.begin(); it != data_container.end(); ) {
960 if ( it->first->isEquivalentTo( tx ) ) {
962 for ( ICIter it2 = it->second.begin(); it2 != it->second.end(); ) {
963 if ( it2->first->isEquivalentTo( rx ) ) {
966 it->second.erase(it2++);
973 if ( it->second.empty() ) {
975 data_container.erase(it++);
982 template<
typename Data >
984 if ( data_container[tx][rx] != NULL )
delete data_container[tx][rx];
985 data_container[tx][rx] = data;
989 template<
typename Data >
991 Location* tx_loc = createLocation(tx);
992 Location* rx_loc = createLocation(rx);
994 if ( data_container[tx_loc][rx_loc] != NULL )
delete data_container[tx_loc][rx_loc];
995 data_container[tx_loc][rx_loc] = data;
999 template<
typename Data >
1001 for( DCIter it = data_container.begin(); it != data_container.end(); it++ ) {
1003 for( ICIter it2 = it->second.begin(); it2 != it->second.end(); it2++ ) {
1010 data_container.clear();
1126 typedef ::std::map< Location*, CustomTransducer >
InnerContainer;
1127 typedef InnerContainer::iterator ICIter;
1128 typedef InnerContainer::reverse_iterator ICRIter;
1129 typedef InnerContainer::const_iterator ICCIter;
1130 typedef InnerContainer::const_reverse_iterator ICCRIter;
1133 typedef ::std::map< Location*, InnerContainer >
DataContainer;
1135 typedef DataContainer::iterator DCIter;
1136 typedef DataContainer::const_iterator DCCIter;
1137 typedef DataContainer::reverse_iterator DCRIter;
1138 typedef DataContainer::const_reverse_iterator DCRCIter;
1141 DCIter
find(
const CoordZ& coordinates );
1143 ICIter
find(
const CoordZ& coordinates,
const DCIter& iter );
1169 if ( coordinates ==
ALL_COORDZ )
return NULL;
1170 return new Location( coordinates );
1180 ICIter it2 = it->second.find(rx);
1181 if ( it2 == it->second.end() ) {
1182 (it->second)[rx] = data;
1190 DCIter it =
find( tx );
1195 ICIter it2 =
find( rx, it );
1196 if ( it2 == it->second.end() ) {
1213 ICIter it2 = it->second.find( rx );
1215 if ( it2 != it->second.end() ) {
1216 it->second.erase( it2 );
1220 if ( it->second.empty() ) {
1229 if ( it->first->isEquivalentTo( tx ) ) {
1231 for ( ICIter it2 = it->second.begin(); it2 != it->second.end(); ) {
1232 if ( it2->first->isEquivalentTo( rx ) ) {
1233 it->second.erase(it2++);
1240 if ( it->second.empty() ) {
3D-Coordinates (lat, long, depth) class definitions and functions library
Definition coordinates-definitions.h:403
Class that stores the coordinates of moving entity.
Definition location-definitions.h:60
virtual Location * clone() const
Definition location-definitions.h:111
CustomTransducer get(Location *const tx, Location *const rx) const
CustomTransducer get(const CoordZ &tx, const CoordZ &rx) const
Class that stores WossCreator parameters.
Definition woss-creator-container.h:124
Data get(Location *const tx, Location *const rx) const
Definition woss-creator-container.cpp:157
static const CoordZ ALL_COORDZ
Definition woss-creator-container.h:138
bool insert(const Data &data, Location *const tx, Location *const rx)
Definition woss-creator-container.h:426
bool insert(const Data &data, const CoordZ &tx, const CoordZ &rx)
Definition woss-creator-container.h:442
DCIter find(const CoordZ &coordinates)
Definition woss-creator-container.cpp:64
Data & accessAllLocations()
Definition woss-creator-container.h:499
void replace(const Data &data, Location *const tx, Location *const rx)
Definition woss-creator-container.h:559
bool debug
Definition woss-creator-container.h:319
void erase(Location *const tx, Location *const rx)
Definition woss-creator-container.h:532
DataContainer data_container
Definition woss-creator-container.h:313
void clear()
Definition woss-creator-container.h:571
~WossCreatorContainer()
Definition woss-creator-container.cpp:59
WossCreatorContainer()
Definition woss-creator-container.cpp:52
Location * createLocation(const CoordZ &coordinates)
Definition woss-creator-container.h:359
void setDebug(bool flag)
Definition woss-creator-container.h:252
::std::map< Location *, Data > InnerContainer
Definition woss-creator-container.h:267
int size() const
Definition woss-creator-container.h:353
void replace(const Data &data, const CoordZ &tx, const CoordZ &rx)
Definition woss-creator-container.h:565
void erase(const CoordZ &tx, const CoordZ &rx)
Definition woss-creator-container.h:540
bool isUsingDebug() const
Definition woss-creator-container.h:258
static Location *const ALL_LOCATIONS
Definition woss-creator-container.h:133
bool isEmpty() const
Definition woss-creator-container.h:347
::std::map< Location *, InnerContainer > DataContainer
Definition woss-creator-container.h:277
Implementation of woss::Location class.
Initial set up of a transducer.
Definition woss-creator-container.h:57
double initial_vert_rotation
Definition woss-creator-container.h:95
double initial_bearing
Definition woss-creator-container.h:90
double add_costant
Definition woss-creator-container.h:110
::std::string type
Definition woss-creator-container.h:84
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:67
double initial_horiz_rotation
Definition woss-creator-container.h:100
double multiply_costant
Definition woss-creator-container.h:105