00001
00029
#ifndef IDX_RECORDID_H
00030
#define IDX_RECORDID_H
00031
00032
#include <fstream>
00033
#include <string>
00034
#include <pthread.h>
00035
00036
#include "BP_CosLw_Log.h"
00037
#include "CorbaServer.h"
00038
00039
00061 class IdxRecordId
00062 {
00063
00064
public:
00070
IdxRecordId(std::string logname)
00071
throw(OrbInit::InitializationError);
00072
00077
virtual ~IdxRecordId();
00078
00079
00090 struct IdxRecord
00091 {
00093 CosLwLog::RecordId
start_rcd_id;
00095 CosLwLog::RecordId
stop_rcd_id;
00097 unsigned long start_seconds;
00099 unsigned long start_nanos;
00101 unsigned long end_seconds;
00103 unsigned long end_nanos;
00104 };
00105
00113
IdxRecord get_last_record();
00114
00127
IdxRecord get_next_record_id(
IdxRecord last);
00128
00137
IdxRecord find_by_time(
const CosLwLog::LogTime& time);
00138
00147
IdxRecord find_by_recid(
const CosLwLog::RecordId& recid);
00148
00155
const bool is_the_future(
const CosLwLog::RecordId& recid)
const;
00156
00163 CosLwLog::RecordId
future_id();
00164
00165
00166
00167
private:
00168
00170 std::fstream _idx;
00171
00173 std::fstream _momento;
00174
00176
const std::string _idx_name;
00178
const std::string _momento_name;
00179
00181 CosLwLog::RecordId _recordId;
00182
00184 pthread_mutex_t _idx_mutex;
00185
00187 pthread_mutex_t _recdid_mutex;
00188
00190 pthread_mutex_t _momento_mutex;
00191
00200 std::string _make_idx_name(std::string log_name);
00201
00210 std::string _make_momento_name(std::string log_name);
00211
00222
unsigned long _find_middle(
long start,
long end);
00223
00232
IdxRecord _arch_find_by_time(
const unsigned long& seconds);
00233
00242
IdxRecord _arch_find_by_recid(
const CosLwLog::RecordId& recid);
00243
00248
void _init()
00249 throw(OrbInit::InitializationError);
00250
00257
void _make_momento_entry(const
IdxRecord& recd);
00258
00265
void _make_idx_entry(const
IdxRecord& recd);
00266
00274
unsigned long _arch_size();
00275 };
00276
00277 #endif