Dumper.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: Dumper.cpp 1972 2009-06-23 17:01:38Z architest $"
00002 
00008 //============================================================================
00009 //
00010 //  This file is part of GPSTk, the GPS Toolkit.
00011 //
00012 //  The GPSTk is free software; you can redistribute it and/or modify
00013 //  it under the terms of the GNU Lesser General Public License as published
00014 //  by the Free Software Foundation; either version 2.1 of the License, or
00015 //  any later version.
00016 //
00017 //  The GPSTk is distributed in the hope that it will be useful,
00018 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 //  GNU Lesser General Public License for more details.
00021 //
00022 //  You should have received a copy of the GNU Lesser General Public
00023 //  License along with GPSTk; if not, write to the Free Software Foundation,
00024 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 //
00026 //  Dagoberto Salazar - gAGE ( http://www.gage.es ). 2009
00027 //
00028 //============================================================================
00029 
00030 
00031 #include "Dumper.hpp"
00032 
00033 
00034 namespace gpstk
00035 {
00036 
00037       // Index initially assigned to this class
00038    int Dumper::classIndex = 8200000;
00039 
00040 
00041       // Returns an index identifying this object.
00042    int Dumper::getIndex() const
00043    { return index; }
00044 
00045 
00046       // Returns a string identifying this object.
00047    std::string Dumper::getClassName() const
00048    { return "Dumper"; }
00049 
00050 
00051 
00052       /* Dumps data from a satTypeValueMap object.
00053        *
00054        * @param gData     Data object holding the data.
00055        */
00056    satTypeValueMap& Dumper::Process( satTypeValueMap& gData )
00057       throw(ProcessingException)
00058    {
00059 
00060       try
00061       {
00062 
00063             // Iterate through all items in the GNSS Data Structure
00064          for( satTypeValueMap::const_iterator it = gData.begin();
00065               it!= gData.end();
00066               it++ )
00067          {
00068 
00069                // First, print satellite (system and PRN)
00070             *outStr << (*it).first << " ";
00071 
00072                // Now, print TypeIDs
00073             printTypeID( (*it).second );
00074 
00075                // Print end of line
00076             *outStr << std::endl;
00077 
00078          }  // End of 'for( satTypeValueMap::const_iterator it = ...'
00079 
00080          return gData;
00081 
00082       }
00083       catch(Exception& u)
00084       {
00085             // Throw an exception if something unexpected happens
00086          ProcessingException e( getClassName() + ":"
00087                                 + StringUtils::asString( getIndex() ) + ":"
00088                                 + u.what() );
00089 
00090          GPSTK_THROW(e);
00091 
00092       }
00093 
00094    }  // End of method 'Dumper::Process()'
00095 
00096 
00097 
00098       /* Dumps data from a gnnsRinex object.
00099        *
00100        * @param gData    Data object holding the data.
00101        */
00102    gnssRinex& Dumper::Process( gnssRinex& gData )
00103       throw(ProcessingException)
00104    {
00105 
00106       try
00107       {
00108 
00109             // Iterate through all items in the GNSS Data Structure
00110          for( satTypeValueMap::const_iterator it = gData.body.begin();
00111               it!= gData.body.end();
00112               it++ )
00113          {
00114 
00115                // First, print year, Day-Of-Year and Seconds of Day (if enabled)
00116             if( printTime )
00117             {
00118                *outStr << gData.header.epoch.year() << " "
00119                        << gData.header.epoch.DOY() << " "
00120                        << gData.header.epoch.DOYsecond() << " ";
00121             }
00122 
00123                // Second, print SourceID information (if enabled)
00124             if( printStation )
00125             {
00126                *outStr << gData.header.source << " ";
00127             }
00128 
00129                // Then, print satellite (system and PRN)
00130             *outStr << (*it).first << " ";
00131 
00132                // Now, print TypeIDs
00133             printTypeID( (*it).second );
00134 
00135                // Print end of line
00136             *outStr << std::endl;
00137 
00138          }  // End of 'for( satTypeValueMap::const_iterator it = ...'
00139 
00140          return gData;
00141 
00142       }
00143       catch(Exception& u)
00144       {
00145             // Throw an exception if something unexpected happens
00146          ProcessingException e( getClassName() + ":"
00147                                 + StringUtils::asString( getIndex() ) + ":"
00148                                 + u.what() );
00149 
00150          GPSTK_THROW(e);
00151 
00152       }
00153 
00154    }  // End of method 'Dumper::Process()'
00155 
00156 
00157 
00158       /* Method to add a set of TypeIDs to be printed.
00159        *
00160        * @param printSet      TypeIDSet of data values to be added to the
00161        *                      ones being printed.
00162        */
00163    Dumper& Dumper::addTypeSet( const TypeIDSet& printSet )
00164    {
00165 
00166          // Iterate over 'printSet' and add its components to 'printTypeSet'
00167       for( TypeIDSet::const_iterator pos = printSet.begin();
00168            pos != printSet.end();
00169            ++pos )
00170       {
00171          printTypeSet.insert(*pos);
00172       }
00173 
00174       return (*this);
00175 
00176    }  // End of method 'Dumper::addTypeSet()'
00177 
00178 
00179 
00180       // Print TypeIDs information.
00181    void Dumper::printTypeID( const typeValueMap& tvMap )
00182    {
00183 
00184          // Iterate through all 'tvMap'
00185       for( typeValueMap::const_iterator itObs = tvMap.begin();
00186            itObs != tvMap.end();
00187            itObs++ )
00188       {
00189 
00190             // Check if we have specific TypeIDs to be printed or not
00191          if( printTypeSet.size() > 0 )
00192          {
00193 
00194                // Check if current TypeID is in 'printTypeSet'
00195             if( printTypeSet.find((*itObs).first) != printTypeSet.end() )
00196             {
00197                if( printType )
00198                {
00199                   *outStr << (*itObs).first << " ";
00200                }
00201 
00202                *outStr << (*itObs).second << " ";
00203             }
00204 
00205          }
00206          else
00207          {
00208                // No specific TypeIDs, so lets print them all
00209             if( printType )
00210             {
00211                *outStr << (*itObs).first << " ";
00212             }
00213 
00214             *outStr << (*itObs).second << " ";
00215 
00216          }  // End of 'if( printTypeSet.size() > 0 )'
00217 
00218       }  // End of 'for( typeValueMap::const_iterator itObs = ... )'
00219 
00220       return;
00221 
00222    }  // End of method 'Dumper::printTypeID()'
00223 
00224 
00225 
00226 }  // End of namespace gpstk

Generated on Tue May 22 03:30:57 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1