/***************************************************************************** * encoder.h * * Abstract Encoder interface * * (c) 2000 Andres Heinloo, GFZ Potsdam * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2, or (at your option) any later * version. For more information, see http://www.gnu.org/ * * ================ * Change log * =============== * * 01.01.2013 Adapted code to CAPS client library requirements (gempa GmbH) *****************************************************************************/ #ifndef CAPS_MSEED_ENCODER_H #define CAPS_MSEED_ENCODER_H #include "packet.h" #include "spclock.h" #include #include #include #include namespace Gempa { namespace CAPS { class Encoder { public: Encoder(int freqn, int freqd) : _clk(freqn, freqd), _sampleCount(0), _timingQuality(-1) {} virtual ~Encoder() {} virtual void push(void *sample) = 0; virtual void flush() = 0; virtual void reset() { _sampleCount = 0; } virtual int type() const = 0; const SPClock& clk() { return _clk; } void setStartTime(const SPClock::INT_TIME &time) { _clk.sync_time(time); } const SPClock::INT_TIME currentTime() const { return _clk.get_time(0); } int timingQuality() { return _timingQuality; } void setTimingQuality(int quality) { _timingQuality = quality; } PacketPtr pop() { if ( _packetQueue.empty() ) return PacketPtr(); PacketPtr rec = _packetQueue.front(); _packetQueue.pop_front(); return rec; } protected: typedef std::list PacketQueue; SPClock _clk; int _sampleCount; PacketQueue _packetQueue; int _timingQuality; }; } } #endif // __ENCODER_H__