00001
#ifndef BOREALIS_STREAMBUFFER_H
00002
#define BOREALIS_STREAMBUFFER_H
00003
00004
#include "common.h"
00005
#include "StreamEvent.h"
00006
00007
BOREALIS_NAMESPACE_BEGIN
00008
00013 class StreamBuffer {
00014
00015
private:
00016
00017 Name m_name;
00018
00019
00020
bool m_init;
00021 ptr<dynbuf> m_bin_tuples;
00022
int m_tuple_size;
00023
char* m_begin;
00024
char* m_end;
00025
char* m_next;
00026
bool m_next_equals_begin;
00027
bool m_empty;
00028 Mutex m_buffer_lock;
00029
00035
char* find(string tuple);
00036
00040 ptr<StreamEvent> buffer_as_event(
char* begin,
char* end);
00041
00042
public:
00043
00044
StreamBuffer(Name name);
00045
~StreamBuffer();
00046 string
as_string()
const;
00047 string
repr()
const;
00048
00052
void init_buffer(
int tuple_size);
00053
00057
void reset_next();
00058
00062
void buffer(
const char* new_tuples,
int length,
int tuple_size);
00063
00067 bool is_duplicate(string tuple) {
00068
char* location;
00069 locking(m_buffer_lock) {
00070 location = find(tuple);
00071 }
00072
return location != NULL;
00073 }
00074
00084
char*
first_new(
char* buffer,
int buffer_size);
00085
00093 ptr<StreamEvent>
all_tuples_since(string first_tuple = string());
00094
00100 ptr<StreamEvent>
all_tuples_before(string last_tuple = string());
00101
00107 ptr<StreamEvent>
next_tuples();
00108
00112 string
last_tuple();
00113
00118
void trim(string tuple);
00119
00120 };
00121
00122
00123
BOREALIS_NAMESPACE_END
00124
00125
#endif