00001 #pragma ident "$Id: SourceID.cpp 1889 2009-05-11 15:47:23Z afarris $"
00002
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "SourceID.hpp"
00032
00033
00034 namespace gpstk
00035 {
00036
00037 std::map< SourceID::SourceType, std::string > SourceID::stStrings;
00038
00039
00040 SourceID::Initializer SourceIDsingleton;
00041
00042
00043 SourceID::Initializer::Initializer()
00044 {
00045 stStrings[Unknown] = "UnknownSource";
00046 stStrings[GPS] = "GPS";
00047 stStrings[Galileo] = "Galileo";
00048 stStrings[Glonass] = "Glonass";
00049 stStrings[Geosync] = "Geosync";
00050 stStrings[LEO] = "LEO";
00051 stStrings[Transit] = "Transit";
00052 stStrings[DGPS] = "DGPS";
00053 stStrings[RTK] = "RTK";
00054 stStrings[INS] = "INS";
00055 stStrings[Mixed] = "Mixed";
00056 }
00057
00058
00059
00060
00061 SourceID& SourceID::operator=(const SourceID& right)
00062 {
00063
00064 if ( this == &right )
00065 {
00066 return (*this);
00067 }
00068
00069 type = right.type;
00070 sourceName = right.sourceName;
00071
00072 return *this;
00073
00074 }
00075
00076
00077
00078
00079 std::ostream& SourceID::dump(std::ostream& s) const
00080 {
00081
00082 s << SourceID::stStrings[type] << " "
00083 << sourceName;
00084
00085 return s;
00086
00087 }
00088
00089
00090
00091
00092
00093 bool SourceID::isValid() const
00094 {
00095
00096 return !(type==Unknown || sourceName=="");
00097
00098 }
00099
00100
00101
00102
00103 SourceID::SourceType SourceID::newSourceType(const std::string& s)
00104 {
00105
00106 SourceType newId =
00107 static_cast<SourceType>(SourceID::stStrings.rbegin()->first + 1);
00108
00109 SourceID::stStrings[newId] = s;
00110
00111 return newId;
00112
00113 }
00114
00115
00116
00117
00118 bool SourceID::operator==(const SourceID& right) const
00119 {
00120
00121 return (type==right.type && sourceName==right.sourceName);
00122
00123 }
00124
00125
00126
00127
00128
00129
00130 bool SourceID::operator<(const SourceID& right) const
00131 {
00132
00133 if (type == right.type)
00134 {
00135 return sourceName < right.sourceName;
00136 }
00137 else
00138 {
00139 return type < right.type;
00140 }
00141
00142 }
00143
00144
00145
00146 namespace StringUtils
00147 {
00148
00149
00150 std::string asString(const SourceID& p)
00151 {
00152
00153 std::ostringstream oss;
00154 p.dump(oss);
00155
00156 return oss.str();
00157
00158 }
00159
00160 }
00161
00162
00163
00164
00165 std::ostream& operator<<( std::ostream& s,
00166 const SourceID& p )
00167 {
00168
00169 p.dump(s);
00170
00171 return s;
00172
00173 }
00174
00175
00176 }