You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
1.8 KiB
C++

/*****************************************************************************
* 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 <gempa/caps/datetime.h>
#include <gempa/caps/pluginpacket.h>
#include <list>
#include <sys/types.h>
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 Time &time) { _clk.syncTime(time); }
const Time currentTime() const { return _clk.getTime(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<PacketPtr> PacketQueue;
SPClock _clk;
int _sampleCount;
PacketQueue _packetQueue;
int _timingQuality;
};
}
}
#endif // __ENCODER_H__