UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Selector.h
1 /* Selector.h */
2 /* $Id: Selector.h,v 1.13 2009/05/12 13:14:37 vlad Exp $ */
3 #ifndef __Selector_h
4 #define __Selector_h
5 
6 #include <malloc.h>
7 #include <stdlib.h>
8 
9 #include <mix/Types.h>
10 #include <ldb/trset.h>
11 
12 
13 /***********************************************************************
14  * Types for selector state description.
15  ***********************************************************************/
16 enum SelectorSortBy {
17  sUnknownOrUndefined = -1,
18  sRawOrder = 0,
19  sCableDepthOrder,
20  sMagnitogramOrder,
21  sMagnitogramInverseOrder,
22  sChannelOrder,
23  sChannelInverseOrder,
24  sSPNumberOrder,
25  sRPNumberOrder,
26  sDPNumberOrder,
27  sCableDepthAzDipOrder,
28  sCableDepthDipAzOrder,
29  sAzimuthDipOrder,
30  sDipAzimuthOrder,
31  sSPOffsetOrder,
32  sOffsetSPOrder,
33  sRPOffsetOrder,
34 
35  sNslNssNrlNrs,
36  sNrlNrsNslNss
37 };
38 
39 /* Max number of remembered NTR */
40 #define MAX_nNTR 10
41 
42 /* Pair of trace type+component */
43 typedef struct
44 {
45  Logic enable; /* toggle on/off flag */
46  char TYPE; /* type of the trace */
47  char COMP; /* component of the trace */
48  int nNTR; /* real number of NTRs in trace set */
49  int NTRs[MAX_nNTR]; /* list of trace numbers but not more than MAX_nNTR */
50 
51 } TypeCompPair;
52 
53 
54 /* max string length for szNTRs and szNMGLs */
55 #define SS_NUMLIST_LEN 1024
56 
57 /* visible part of szNTRs and szNMGLs strings */
58 #define SS_NUMLIST_WIDTH 15
59 
60 /***********************************************************************
61  * Selector structure is combined from component and trace number lists.
62  ***********************************************************************/
64 {
65  enum SelectorSortBy eSortBy;
66  int nPairs; /* COMP+TYPE selection */
67  TypeCompPair *pPairs;
68  int nNTRs; /* NTR selection */
69  int *pNTRs;
70  char szNTRs[SS_NUMLIST_LEN+1]; /* string representation */
71  int nNMGLs; /* NMGL selection */
72  int *pNMGLs;
73  char szNMGLs[SS_NUMLIST_LEN+1]; /* string representation */
74  int nNSPs; /* NSP selection */
75  int *pNSPs;
76  char szNRPs[SS_NUMLIST_LEN+1]; /* string representation */
77  int nNRPs; /* NRP selection */
78  int *pNRPs;
79  char szNSPs[SS_NUMLIST_LEN+1]; /* string representation */
80  int nNDPs; /* NDP selection */
81  int *pNDPs;
82  char szNDPs[SS_NUMLIST_LEN+1]; /* string representation */
83  int nVERs; /* VER selection */
84  int *pVERs;
85 
86  char szNSSs[SS_NUMLIST_LEN+1]; /* string representation */
87  int nNSSs; /* NSS selection */
88  int *pNSSs;
89  char szNSLs[SS_NUMLIST_LEN+1]; /* string representation */
90  int nNSLs; /* NSL selection */
91  int *pNSLs;
92  char szNRSs[SS_NUMLIST_LEN+1]; /* string representation */
93  int nNRSs; /* NRS selection */
94  int *pNRSs;
95  char szNRLs[SS_NUMLIST_LEN+1]; /* string representation */
96  int nNRLs; /* NRL selection */
97  int *pNRLs;
98 
99  char szVERs[SS_NUMLIST_LEN+1]; /* string representation */
100  int nLrange[2]; /* L range selection */
101 
102  char *szExpr;
103 };
104 
105 
106 #ifdef __cplusplus
107 extern "C" {
108 #endif /* __cplusplus */
109 
110 /* Paste all type+comp pairs from input modification. */
111 ErrCode PasteTypeCompPairs (TrSet* its, int* n_pairs, TypeCompPair** pairs);
112 
113 /* Compose string with TYPE,COMP pair and NTR list. */
114 char* ComposeTypeCompLabel (char* szLabelBuf, TypeCompPair* pair);
115 
116 /* Copy selector to uninitialized variable */
117 void CopySelector (struct SelectorSet* dst,
118  const struct SelectorSet* src);
119 
120 /* Release memory under the selector and assign zeros to it's contents */
121 void FreeSelector (struct SelectorSet* dst);
122 
124 ErrCode SaveSelector ();
125 
127 ErrCode LoadSelector ();
128 
130 const char* SelectorSortByToString (enum SelectorSortBy eSortBy);
131 
134 enum SelectorSortBy SelectorSortByFromString (const char* szSortBy);
135 
136 #ifdef __cplusplus
137 };
138 #endif /* __cplusplus */
139 
140 
141 
142 #ifdef __cplusplus
143 
144 /* Build index table. */
145 ErrCode SelectTraces (SelectorSet& ss, TrSet* ts, TrIndexTable* it);
146 
147 /* Class SelectorSet object initialization and save/load operations */
148 class SelectorSetObject
149 {
150 private:
151  SelectorSet *selset;
152 
153 public:
154  SelectorSetObject (SelectorSet* ss)
155  : selset(ss)
156  {
157  if(NULL == selset)
158  return;
159 
160  selset->eSortBy = sRawOrder;
161  selset->nPairs = 0;
162  selset->pPairs = NULL;
163  selset->nNTRs = 0;
164  selset->pNTRs = NULL;
165  selset->nNMGLs = 0;
166  selset->pNMGLs = NULL;
167  selset->nNSPs = 0;
168  selset->pNSPs = NULL;
169  selset->nNRPs = 0;
170  selset->pNRPs = NULL;
171  selset->nNDPs = 0;
172  selset->pNDPs = NULL;
173  selset->nNSLs = 0;
174  selset->pNSLs = NULL;
175  selset->nNSSs = 0;
176  selset->pNSSs = NULL;
177  selset->nNRLs = 0;
178  selset->pNRLs = NULL;
179  selset->nNRSs = 0;
180  selset->pNRSs = NULL;
181  selset->nVERs = 0;
182  selset->pVERs = NULL;
183  selset->szNTRs[0] = '\0';
184  selset->szNMGLs[0] = '\0';
185  selset->szNSPs[0] = '\0';
186  selset->szNDPs[0] = '\0';
187  selset->szNRPs[0] = '\0';
188  selset->szNSLs[0] = '\0';
189  selset->szNSSs[0] = '\0';
190  selset->szNRLs[0] = '\0';
191  selset->szNRSs[0] = '\0';
192  selset->szVERs[0] = '\0';
193  selset->nLrange[0] = 0;
194  selset->nLrange[1] = 0;
195  selset->szExpr = NULL;
196  };
197  virtual ~SelectorSetObject ()
198  {
199  if(NULL == selset)
200  return;
201  FreeSelector(selset);
202  };
203 
204  ErrCode save (const char* szFilePath);
205  ErrCode load (const char* szFilePath);
206 };
207 #endif /* __cplusplus */
208 
209 
210 #ifndef __SelectorVars
211 
212 /* Actual state of state selector */
213 extern struct SelectorSet rSelSet;
214 
215 
216 extern char *SelectorSet_szSortBy[];
217 extern int SelectorSet_nSortBy;
218 
219 
220 #endif /* __SelectorVars */
221 
222 #endif /* Selector.h */
Definition: trset.h:56
Definition: Selector.h:43
Definition: Selector.h:63
Definition: trset.h:96