Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

StreamBuffer.h

Go to the documentation of this file.
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 // Circular buffer of tuples produced or received on that stream 00020 bool m_init; // Buffer has been initialized... default false 00021 ptr<dynbuf> m_bin_tuples; // Buffer of tuples 00022 int m_tuple_size; // Size of tuples in this buffer 00023 char* m_begin; // Points to what is currently the oldest tuples 00024 char* m_end; // Points to what is currently the end of the most recent tuple 00025 char* m_next; // Points to the position for the next buffer_as_next_event. 00026 bool m_next_equals_begin; 00027 bool m_empty; // If we buffer but trim fast enough, buffer is empty 00028 Mutex m_buffer_lock; // Thread safety 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

Generated on Fri Nov 12 15:15:22 2004 for Borealis by doxygen 1.3.8