DataStatus.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: DataStatus.hpp 1895 2009-05-12 19:34:29Z afarris $"
00002 
00003 //============================================================================
00004 //
00005 //  This file is part of GPSTk, the GPS Toolkit.
00006 //
00007 //  The GPSTk is free software; you can redistribute it and/or modify
00008 //  it under the terms of the GNU Lesser General Public License as published
00009 //  by the Free Software Foundation; either version 2.1 of the License, or
00010 //  any later version.
00011 //
00012 //  The GPSTk is distributed in the hope that it will be useful,
00013 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 //  GNU Lesser General Public License for more details.
00016 //
00017 //  You should have received a copy of the GNU Lesser General Public
00018 //  License along with GPSTk; if not, write to the Free Software Foundation,
00019 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 //
00021 //  Copyright 2007, The University of Texas at Austin
00022 //
00023 //============================================================================
00024 
00032 #ifndef DATASTATUS_HPP
00033 #define DATASTATUS_HPP
00034 
00035 #include <iostream>
00036 
00037 namespace gpstk
00038 {
00039    class DataStatus
00040    {
00041       std::ios_base::iostate state;
00042 
00043    public:
00044 
00045       DataStatus() : state(std::ios_base::goodbit) {};
00046 
00049       bool good() const 
00050       {return rdstate() == std::ios_base::goodbit;}
00051 
00052       std::ios_base::iostate rdstate() const
00053       {return state;}
00054 
00055       void clear(std::ios_base::iostate s = std::ios_base::goodbit)
00056       {state=s;}
00057 
00058       void setstate(std::ios_base::iostate s)
00059       {clear(rdstate() | s);}
00060 
00061       void clearstate(std::ios_base::iostate s)
00062       {state &= ~s;}
00063 
00064       bool operator()() const
00065       {return good();}
00066 
00067       operator void*() const 
00068       {return good() ? const_cast<DataStatus*>(this) : 0;}
00069    };
00070 
00072    static const std::ios_base::iostate crcbit = std::ios_base::iostate(0x01);
00073    static const std::ios_base::iostate fmtbit = std::ios_base::iostate(0x02);
00074    static const std::ios_base::iostate lenbit = std::ios_base::iostate(0x04);
00075    static const std::ios_base::iostate parbit = std::ios_base::iostate(0x08);
00076 
00077    class CRCDataStatus : public DataStatus
00078    {
00079    public:
00080       bool crcerr() const {return (rdstate() & crcbit) != 0;}
00081       bool fmterr() const {return (rdstate() & fmtbit) != 0;}
00082       bool lenerr() const {return (rdstate() & lenbit) != 0;}
00083       bool parerr() const {return (rdstate() & parbit) != 0;}
00084    };
00085 } // namespace gpstk
00086 
00087 #endif // DATASTATUS_HPP

Generated on Wed Feb 8 03:30:58 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1