ARPDAS_QNX6 1.0
|
00001 #ifndef DQ_H_INCLUDED 00002 #define DQ_H_INCLUDED 00003 #include "tm.h" 00004 00005 // I prefer not to allocate and free these structures routinely, but 00006 // I'll start that way. It makes sense to keep a free list for the 00007 // basic types: tstamp_q, dq_tstamp_ref and dq_data_ref. Actually, 00008 // I guess that can be optimized via definition of new and delete 00009 // operators. 00010 00011 // Define a hierarchy here. A dq_descriptor can either hold 00012 // a timestamp or reference data rows in the DQ. 00013 // This works within DG because we don't have readers starting 00014 // and stopping. We have exactly one reader that will go 00015 // through all the data. 00016 00017 enum dqtype { dq_tstamp, dq_data }; 00018 00019 class dq_ref { 00020 public: 00021 dq_ref(dqtype mytype); 00022 dq_ref *next(dq_ref *dqr); 00023 dq_ref *next_dqr; 00024 dqtype type; 00025 }; 00026 00027 class dq_tstamp_ref : public dq_ref { 00028 public: 00029 dq_tstamp_ref( mfc_t MFCtr, time_t time ); 00030 tstamp_t TS; 00031 }; 00032 00033 class dq_data_ref : public dq_ref { 00034 public: 00035 dq_data_ref(mfc_t MFCtr, int mfrow, int Qrow_in, int nrows_in ); 00036 void append_rows( int nrows ); 00037 mfc_t MFCtr_start, MFCtr_next; 00038 int row_start, row_next; 00039 int Qrow; 00040 int n_rows; 00041 }; 00042 00043 /* Semantics of Data_Queue 00044 Data_Queue.first, .last are indices into row and range from 00045 [0..total_Qrows) 00046 .first is where the next row will be read from 00047 .last is where the next row will be written to 00048 first==last means either full or empty, depending on the value of full. 00049 00050 if collection is true, then allocate_rows will throw rather than block 00051 */ 00052 extern void tminitfunc(); 00053 class data_queue { 00054 public: 00055 data_queue( int n_Qrows, int low_water ); 00056 void init(); // allocate space for the queue 00057 00058 protected: 00059 int allocate_rows(unsigned char **rowp); 00060 void commit_rows( mfc_t MFCtr, int mfrow, int n_rows ); 00061 void commit_tstamp( mfc_t MFCtr, time_t time ); 00062 void retire_rows( dq_data_ref *dqd, int n_rows ); 00063 void retire_tstamp( dq_tstamp_ref *dqts ); 00064 virtual void lock(const char * by = 0, int line = -1); 00065 virtual void unlock(); 00066 00067 unsigned char *raw; 00068 unsigned char **row; 00069 tm_hdrw_t output_tm_type; 00070 int total_Qrows; 00071 int nbQrow; // may differ from nbrow if stripping MFCtr & Synch 00072 int nbDataHdr; 00073 int first; 00074 int last; 00075 bool full; 00076 00077 dq_ref *first_dqr; 00078 dq_ref *last_dqr; 00079 int dq_low_water; 00080 }; 00081 00082 #endif