Initial commit based on common repo commit ffeb9c9b
This commit is contained in:
104
libs/gempa/caps/sessiontable.h
Normal file
104
libs/gempa/caps/sessiontable.h
Normal file
@@ -0,0 +1,104 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2013 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_SESSIONTABLE_H
|
||||
#define GEMPA_CAPS_SESSIONTABLE_H
|
||||
|
||||
#include "packet.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
|
||||
|
||||
namespace Gempa {
|
||||
namespace CAPS {
|
||||
|
||||
struct SessionTableItem {
|
||||
SessionTableItem() : samplingFrequency(0), samplingFrequencyDivider(0),
|
||||
fSamplingFrequency(0.0), dataType(DT_Unknown),
|
||||
dataSize(0), userData(NULL) {}
|
||||
std::string streamID;
|
||||
std::string net;
|
||||
std::string sta;
|
||||
std::string loc;
|
||||
std::string cha;
|
||||
uint16_t samplingFrequency;
|
||||
uint16_t samplingFrequencyDivider;
|
||||
double fSamplingFrequency;
|
||||
PacketType type;
|
||||
DataType dataType;
|
||||
int dataSize;
|
||||
UOM uom;
|
||||
Time startTime;
|
||||
Time endTime;
|
||||
void *userData;
|
||||
|
||||
bool splitStreamID();
|
||||
};
|
||||
|
||||
|
||||
class SC_GEMPA_CAPS_API SessionTable : public std::map<int, SessionTableItem> {
|
||||
public:
|
||||
enum Status {Success, Error, EOD};
|
||||
|
||||
typedef std::function<void (SessionTableItem*)> CallbackFunc;
|
||||
|
||||
public:
|
||||
//! Default constructor
|
||||
SessionTable();
|
||||
virtual ~SessionTable() {}
|
||||
|
||||
//! Resets state
|
||||
void reset();
|
||||
|
||||
SessionTableItem* getItem(int id) {
|
||||
SessionTable::iterator it = find(id);
|
||||
if ( it == end() ) return NULL;
|
||||
|
||||
return &it->second;
|
||||
}
|
||||
|
||||
Status handleResponse(const char *src_data, int data_len);
|
||||
|
||||
void setItemAddedFunc(const CallbackFunc &func) { _itemAddedFunc = func; }
|
||||
void setItemAboutToBeRemovedFunc(const CallbackFunc &func) {
|
||||
_itemAboutToBeRemovedFunc = func;
|
||||
}
|
||||
|
||||
private:
|
||||
enum ResponseState {
|
||||
Unspecific,
|
||||
Requests
|
||||
};
|
||||
|
||||
typedef std::map<std::string, int> StreamIDLookupTable;
|
||||
|
||||
private:
|
||||
void registerItem(int id, SessionTableItem &item);
|
||||
void removeStream(const std::string & streamID);
|
||||
|
||||
private:
|
||||
ResponseState _state;
|
||||
StreamIDLookupTable _streamIDLookup;
|
||||
CallbackFunc _itemAddedFunc;
|
||||
CallbackFunc _itemAboutToBeRemovedFunc;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user