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.
144 lines
3.8 KiB
C++
144 lines
3.8 KiB
C++
/***************************************************************************
|
|
* Copyright (C) 2009 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_METAPACKET_H
|
|
#define GEMPA_CAPS_METAPACKET_H
|
|
|
|
#include <gempa/caps/api.h>
|
|
#include <gempa/caps/packet.h>
|
|
|
|
#include <stdint.h>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace Gempa {
|
|
namespace CAPS {
|
|
|
|
struct SC_GEMPA_CAPS_API MetaResponseHeader {
|
|
struct Time {
|
|
int64_t seconds;
|
|
int32_t microSeconds;
|
|
};
|
|
|
|
Time startTime;
|
|
Time endTime;
|
|
|
|
bool get(std::streambuf &buf) {
|
|
Endianess::Reader get(buf);
|
|
|
|
get(startTime.seconds);
|
|
get(startTime.microSeconds);
|
|
|
|
get(endTime.seconds);
|
|
get(endTime.microSeconds);
|
|
|
|
return get.good;
|
|
}
|
|
|
|
int dataSize() const {
|
|
return sizeof(startTime.seconds) + sizeof(startTime.microSeconds) +
|
|
sizeof(endTime.seconds) + sizeof(endTime.microSeconds);
|
|
}
|
|
};
|
|
|
|
class MetaDataRecord : public DataRecord {
|
|
public:
|
|
struct MetaHeader {
|
|
Header dataHeader;
|
|
TimeStamp endTime;
|
|
|
|
bool get(std::streambuf &buf) {
|
|
Endianess::Reader get(buf);
|
|
|
|
get(endTime.year);
|
|
get(endTime.yday);
|
|
get(endTime.hour);
|
|
get(endTime.minute);
|
|
get(endTime.second);
|
|
get(endTime.usec);
|
|
|
|
return get.good;
|
|
}
|
|
|
|
bool put(std::streambuf &buf) const;
|
|
|
|
int dataSize() const {
|
|
return dataHeader.dataSize() +
|
|
sizeof(endTime.year) +
|
|
sizeof(endTime.yday) +
|
|
sizeof(endTime.hour) +
|
|
sizeof(endTime.minute) +
|
|
sizeof(endTime.second) +
|
|
sizeof(endTime.usec);
|
|
}
|
|
|
|
void setEndTime(const Time ×tamp);
|
|
};
|
|
|
|
public:
|
|
MetaDataRecord();
|
|
|
|
//! Returns the data vector to be filled by the caller
|
|
Buffer *data();
|
|
|
|
virtual const char *formatName() const;
|
|
|
|
virtual bool readMetaData(std::streambuf &buf, int size,
|
|
Header &header,
|
|
Time &startTime, Time &endTime) {
|
|
return false;
|
|
}
|
|
|
|
virtual const Header *header() const;
|
|
|
|
//! Sets a custom header and updates all internal structures
|
|
//! based on the current data. If the data has changed, make
|
|
//! sure to call this method again. If the flag skip reading
|
|
//! is set get will not read the header information from stream
|
|
void setHeader(const MetaHeader &header);
|
|
|
|
virtual Time startTime() const;
|
|
virtual Time endTime() const;
|
|
|
|
virtual bool canTrim() const { return false; }
|
|
virtual bool canMerge() const { return false; }
|
|
|
|
virtual bool trim(const Time &start, const Time &end) const { return false; }
|
|
|
|
virtual size_t dataSize(bool withHeader) const;
|
|
|
|
virtual ReadStatus get(std::streambuf &buf, int size,
|
|
const Time &start, const Time &end,
|
|
int maxBytes);
|
|
|
|
virtual bool put(std::streambuf &buf, bool withHeader) const { return false; }
|
|
|
|
PacketType packetType() const { return MetaDataPacket; }
|
|
|
|
private:
|
|
MetaHeader _header;
|
|
|
|
mutable Time _startTime;
|
|
mutable Time _endTime;
|
|
};
|
|
|
|
}
|
|
}
|
|
|
|
|
|
#endif
|