85 lines
2.0 KiB
C++
85 lines
2.0 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)
|
|
, _context{nullptr} {}
|
|
|
|
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); }
|
|
|
|
void setTimingQuality(int quality) { _timingQuality = quality; }
|
|
int timingQuality() { return _timingQuality; }
|
|
|
|
void setContext(void *context) { _context = context; }
|
|
|
|
PacketPtr pop() {
|
|
if ( _packetQueue.empty() ) {
|
|
return PacketPtr();
|
|
}
|
|
|
|
PacketPtr rec = _packetQueue.front();
|
|
rec->context = _context;
|
|
_packetQueue.pop_front();
|
|
return rec;
|
|
}
|
|
|
|
protected:
|
|
typedef std::list<PacketPtr> PacketQueue;
|
|
SPClock _clk;
|
|
int _sampleCount;
|
|
PacketQueue _packetQueue;
|
|
int _timingQuality;
|
|
void *_context;
|
|
};
|
|
|
|
}
|
|
}
|
|
|
|
#endif // __ENCODER_H__
|
|
|