Initial commit based on common repo commit ffeb9c9b
This commit is contained in:
164
libs/gempa/caps/encoderfactory.h
Normal file
164
libs/gempa/caps/encoderfactory.h
Normal file
@@ -0,0 +1,164 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2016 by gempa GmbH *
|
||||
* *
|
||||
* All Rights Reserved. *
|
||||
* *
|
||||
* NOTICE: All information contained herein is, and remains *
|
||||
* the property of gempa GmbH and its suppliers, if any. The intellectual *
|
||||
* and technical concepts contained herein are proprietary to gempa GmbH *
|
||||
* and its suppliers. *
|
||||
* Dissemination of this information or reproduction of this material *
|
||||
* is strictly forbidden unless prior written permission is obtained *
|
||||
* from gempa GmbH. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef GEMPA_CAPS_ENCODERFACTORY_H
|
||||
#define GEMPA_CAPS_ENCODERFACTORY_H
|
||||
|
||||
#include "mseed/encoder.h"
|
||||
|
||||
#include <gempa/caps/packet.h>
|
||||
|
||||
namespace Gempa {
|
||||
namespace CAPS {
|
||||
|
||||
/**
|
||||
* @brief Abstract base class of the encoder factory. Each
|
||||
* derived class must implement the create and the
|
||||
* supportsRecord method.
|
||||
*/
|
||||
class EncoderFactory {
|
||||
public:
|
||||
EncoderFactory();
|
||||
virtual ~EncoderFactory();
|
||||
/**
|
||||
* @brief Creates encoder from given parameter set
|
||||
* @param networkCode The nework code
|
||||
* @param stationCode The station code
|
||||
* @param locationCode The location code
|
||||
* @param channelCode The channel code
|
||||
* @param dt The data encoding
|
||||
* @param samplingFrequencyNumerator The numerator
|
||||
* @param samplingFrequencyDenominator The denominator
|
||||
* @param samplingFrequencyDenominator The timing quality
|
||||
* @return The encoder object or NULL if creation fails
|
||||
*/
|
||||
virtual Encoder* create(const std::string &networkCode,
|
||||
const std::string &stationCode,
|
||||
const std::string &locationCode,
|
||||
const std::string &channelCode,
|
||||
int dt,
|
||||
int samplingFrequencyNumerator,
|
||||
int samplingFrequencyDenominator) = 0;
|
||||
|
||||
/**
|
||||
* @brief Checks if an encoder factory
|
||||
* supports the given record.
|
||||
* @param rec The record to check
|
||||
* @return True if the data type is supported
|
||||
*/
|
||||
virtual bool supportsRecord(DataRecord *rec) = 0;
|
||||
|
||||
/**
|
||||
* @brief Returns a human readable error description
|
||||
* of the last error occured.
|
||||
* @return Error description
|
||||
*/
|
||||
const std::string& errorString() const;
|
||||
|
||||
protected:
|
||||
std::string _errorString;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Base class for all MSEED encoders
|
||||
*/
|
||||
class MSEEDEncoderFactory : public EncoderFactory {
|
||||
public:
|
||||
MSEEDEncoderFactory();
|
||||
|
||||
/**
|
||||
* @brief Sets the volume logical record length expressed as a
|
||||
* power of 2. A 512 byte record would be 9.
|
||||
* @param recLen The record length expressed as a power of 2
|
||||
* @return True if the record length is valid
|
||||
*/
|
||||
bool setRecordLength(uint recordLength);
|
||||
|
||||
protected:
|
||||
uint8_t _recordLength;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Implements a general Steim encoder factory
|
||||
* interface which implements the supportsRecord method
|
||||
* only.
|
||||
*/
|
||||
class SteimEncoderFactory : public MSEEDEncoderFactory {
|
||||
public:
|
||||
/**
|
||||
* @brief Checks if an encoder factory
|
||||
* supports the given record. In case of data type float or double we
|
||||
* return true but the values will casted implicitly to int32.
|
||||
* @param rec The record to check
|
||||
* @return True if the data type is supported
|
||||
*/
|
||||
bool supportsRecord(DataRecord *rec);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief The IdentiyEncoderFactory class implements the
|
||||
* encoder factory interface and supports the creation of
|
||||
* identiy encoders.
|
||||
*/
|
||||
class IdentityEncoderFactory : public MSEEDEncoderFactory {
|
||||
public:
|
||||
Encoder* create(const std::string &networkCode,
|
||||
const std::string &stationCode,
|
||||
const std::string &locationCode,
|
||||
const std::string &channelCode,
|
||||
int dt,
|
||||
int samplingFrequencyNumerator,
|
||||
int samplingFrequencyDenominator);
|
||||
bool supportsRecord(DataRecord *rec);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief The Steim1EncoderFactory class implements the
|
||||
* encoder factory interface and supports the creation of
|
||||
* Steim2 encoders.
|
||||
*/
|
||||
class Steim1EncoderFactory : public SteimEncoderFactory {
|
||||
public:
|
||||
Encoder* create(const std::string &networkCode,
|
||||
const std::string &stationCode,
|
||||
const std::string &locationCode,
|
||||
const std::string &channelCode,
|
||||
int dt,
|
||||
int samplingFrequencyNumerator,
|
||||
int samplingFrequencyDenominator);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The Steim2EncoderFactory class implements the
|
||||
* encoder factory interface and supports the creation of
|
||||
* Steim2 encoders.
|
||||
*/
|
||||
class Steim2EncoderFactory : public SteimEncoderFactory {
|
||||
public:
|
||||
Encoder* create(const std::string &networkCode,
|
||||
const std::string &stationCode,
|
||||
const std::string &locationCode,
|
||||
const std::string &channelCode,
|
||||
int dt,
|
||||
int samplingFrequencyNumerator,
|
||||
int samplingFrequencyDenominator);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user