OSDN Git Service

.
[csp-qt/common_source_project-fm7.git] / source / src / fifo.h
index 6477cf3..fad118b 100644 (file)
 
 #include "common.h"
 
-class csp_state_data_saver;
 class DLL_PREFIX FIFO
 {
-private:
+protected:
        int size;
        int* buf;
        int cnt, rpt, wpt;
-
-       const _TCHAR *_ns = "FIFO::BEGIN";
-       const _TCHAR *_ne = "FIFO::END";
+       int empty_warn_val, fill_warn_val;
+       bool empty_warn_flag, fill_warn_flag;
 public:
-       FIFO(int s);
-       void release();
-       void clear();
-       void write(int val);
-       int read();
-       int read_not_remove(int pt);
-       void write_not_push(int pt, int d);
-       int count();
-       bool full();
-       bool empty();
-       void save_state(void *f);
-       bool load_state(void *f);
-
-       void save_state_helper(csp_state_data_saver *state_saver, uint32_t *sumseed, bool *__stat);
-       bool load_state_helper(csp_state_data_saver *state_saver, uint32_t *sumseed, bool *__stat);
-       
+       FIFO(int s, int empty_warn = -1, int fill_warn = -1);
+       virtual void release();
+       virtual void clear();
+       virtual void write(int val, bool *p_fill_warn = nullptr);
+       virtual int read(bool *p_empty_warn = nullptr);
+       virtual int read_not_remove(int pt, bool *p_empty_warn = nullptr);
+       virtual void write_not_push(int pt, int d, bool *p_fill_warn = nullptr);
+       virtual int count();
+       virtual bool full();
+       virtual bool empty();
+       virtual bool is_fill_warn() { return fill_warn_flag; }
+       virtual bool is_fill_warn_or_empty_warn() { return ((fill_warn_flag) || (empty_warn_flag)); }
+       virtual bool is_empty_warn() { return empty_warn_flag; }
+       virtual void modify_fill_warn_val(int n) { fill_warn_val = n; }
+       virtual void modify_empty_warn_val(int n) { empty_warn_val = n; }
+       virtual void clear_fill_warn() { fill_warn_flag = false; }
+       virtual void clear_empty_warn() { empty_warn_flag = false; }
+       virtual bool process_state(void *f, bool loading);
 };
 
 #endif