#include #include #include #include #include //--------------------------------------------------------------------------------------- // USER event description //--------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------- // BUFFER description //--------------------------------------------------------------------------------------- class LogBuffer { public: int MAXEVT; char *log_buf; //-- event buffer int wr_p, rd_p, loop_flag, fill_level; LogBuffer(LogBuffer *buf, int size) { printf("Logbuffer:: Constructor, size=%d\n",size); sleep(1); MAXEVT=size; wr_p=buf->wr_ptr; rd_p=buf->rd_ptr; loop_flag=buf->loop_ptr; fill_level=buf->level_ptr; //log_buf = new char [size]; log_buf = buf->buf; } ~LogBuffer() { printf("Logbuffer:: Destructor\n"); //delete log_buf; } int write(char *text, int size) { //if (wr_p==rd_p && loop_flag>0) { fill_level=MAXEVT*loop_flag+wr_p-rd_p; return 1; } printf("LogBuffer:write():: 1:: size=%d wr=%d\n",size,wr_p); for (int bc=0; bcMAXEVT) size=MAXEVT; if (size<=wr_p) { rd_p=wr_p-size; loop_flag=0;} else { rd_p=MAXEVT-(size-wr_p); loop_flag=1; } int ic=0; printf("LogBuffer:read():: 2:: size=%d rd=%d wr=%d \n",size,rd_p,wr_p ); for (int bc=0; bc0) ic++; if (rd_p==0) loop_flag--; } return ic; } int level() { return MAXEVT*loop_flag+wr_p-rd_p; } }; //---------------------------------------------------------------------------------------