MAK Data Logger API Documentation for HLA
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
uniqEntryArr.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 1992-2025 MAK Technologies, Inc
3 ** All rights reserved.
4 ******************************************************************************/
5 
8 
9 #ifndef uniqEntryArr_H_
10 #define uniqEntryArr_H_
11 
12 #if DtDIS
13 
14 #include <lgrSim/lgrSim.h>
15 #ifndef _MachineTypes_h
16 #include <vlutil/vlMachineTypes.h>
17 #endif
18 
19 namespace MAKLogger
20 {
21 
22 struct DT_DLL_LGRSIM DtKeyValuePair
23 {
24  unsigned int key;
25  unsigned int val;
26 
27 public:
28  inline DtKeyValuePair() : key( 0 ), val( 0 ) {}
29  inline ~DtKeyValuePair() {}
30  inline DtKeyValuePair( unsigned int _key, unsigned int _val ) :
31  key( _key ), val( _val ) {}
32  inline DtKeyValuePair( const DtKeyValuePair& src ) :
33  key( src.key ), val( src.val ) {}
34 public:
36  inline DtKeyValuePair& operator=( const DtKeyValuePair& src )
37  {
38  if ( this != &src )
39  {
40  key = src.key; val = src.val;
41  }
42  return *this;
43  }
45  inline bool operator==( const DtKeyValuePair& rhs )
46  {
47  if ( this == &rhs ) return ( 1 == 1 );
48  return ( key == rhs.key && val == rhs.val );
49  }
50  inline bool operator!=( const DtKeyValuePair& rhs )
51  {
52  if ( this == &rhs ) return ( 1 == 0 );
53  return ( key != rhs.key || val != rhs.val );
54  }
56  inline unsigned int operator[]( int ix ) const
57  {
58  if ( ix < 0 || ix > 1 )
59  {
60  return (~(unsigned int)0);
61  }
62  else
63  {
64  return ( ( ix ) ? val : key );
65  }
66  }
67 };
68 
69 
73 
74 
85 class DT_DLL_LGRSIM DtUniqueEntryArray
86 {
87 public:
89  DtUniqueEntryArray();
91  ~DtUniqueEntryArray();
93  DtUniqueEntryArray( const DtUniqueEntryArray& src );
95  DtUniqueEntryArray& operator=( const DtUniqueEntryArray& src );
96 
97 public:
99  bool operator==( const DtUniqueEntryArray& rhs ) const;
100  bool operator!=( const DtUniqueEntryArray& rhs ) const;
102  inline unsigned int operator[]( int ix ) const;
103 
104 public:
105  inline int count() const;
106  inline bool isOK() const;
107  inline unsigned int error() const;
108  inline unsigned int minVal() const;
109  inline unsigned int maxVal() const;
110 
111 public:
112  int lookup( unsigned int val ) const;
113  int remove( unsigned int val );
114  int append( unsigned int val );
115  void reset();
116 
117 protected:
118  void removeAt( int ix );
119  bool insertAt( int ix );
120  bool resizeTo( int ix );
121 
122 protected:
123  unsigned int* myArray;
124  int sz_nu, sz_na, _isOK;
125  unsigned int ErrFlg;
126 };
127 
128 
132 
133 inline unsigned int DtUniqueEntryArray::operator[]( int ix ) const
134 {
135  return ( ( ix < 0 || ix >= sz_nu ) ? (~(unsigned int)0) : myArray[ix] );
136 }
137 
138 
139 inline int DtUniqueEntryArray::count() const
140 {
141  return sz_nu;
142 }
143 
144 
145 inline bool DtUniqueEntryArray::isOK() const
146 {
147  return ( _isOK != 0 );
148 }
149 
150 
151 inline unsigned int DtUniqueEntryArray::error() const
152 {
153  return ErrFlg;
154 }
155 
156 
157 inline unsigned int DtUniqueEntryArray::minVal() const
158 {
159  return ( ( sz_nu <= 0 ) ? (~(unsigned int)0) : myArray[0] );
160 }
161 
162 
163 inline unsigned int DtUniqueEntryArray::maxVal() const
164 {
165  return ( ( sz_nu <= 0 ) ? (~(unsigned int)0) : myArray[( sz_nu - 1 )] );
166 }
167 
168 
172 
173 
187 class DT_DLL_LGRSIM DtUniqueEntryArrWData
188 {
189 public:
191  DtUniqueEntryArrWData();
193  ~DtUniqueEntryArrWData();
195  DtUniqueEntryArrWData( const DtUniqueEntryArrWData& src );
197  DtUniqueEntryArrWData& operator=( const DtUniqueEntryArrWData& src );
198 
200  bool operator==( const DtUniqueEntryArrWData& rhs ) const;
201  bool operator!=( const DtUniqueEntryArrWData& rhs ) const;
203  inline const DtKeyValuePair& operator[]( int ix ) const;
204  inline unsigned int operator()( int ix, int jx ) const;
205 
206  inline int count() const;
207  inline bool isOK() const;
208  inline unsigned int error() const;
209  inline unsigned int minVal() const;
210  inline unsigned int maxVal() const;
211 
212  int lookup( unsigned int key, unsigned int* pval=0 ) const;
213  int remove( unsigned int key, unsigned int* pval=0 );
214  int append( unsigned int key, unsigned int val, unsigned int* pval=0 );
215  bool setVal( int ix, unsigned int val, unsigned int* pval=0 );
216  void reset();
217 
218 
219  void removeAt( int ix );
220  bool insertAt( int ix );
221  bool resizeTo( int ix );
222 
223  static const DtKeyValuePair dfltDummyEntry;
224 
225 protected:
226  DtKeyValuePair* arr;
227  int sz_nu, sz_na, _isOK;
228  unsigned int ErrFlg;
229 };
230 
231 
235 
236 inline const DtKeyValuePair& DtUniqueEntryArrWData::operator[]( int ix ) const
237 {
238  return ( ( ix < 0 || ix >= sz_nu ) ?
239  DtUniqueEntryArrWData::dfltDummyEntry : arr[ix] );
240 }
241 
242 
243 inline unsigned int DtUniqueEntryArrWData::operator()( int ix, int jx ) const
244 {
245  return ( ( ix < 0 || ix >= sz_nu ) ?
246  DtUniqueEntryArrWData::dfltDummyEntry[jx] : arr[ix][jx] );
247 }
248 
249 
250 inline int DtUniqueEntryArrWData::count() const
251 {
252  return sz_nu;
253 }
254 
255 
256 inline bool DtUniqueEntryArrWData::isOK() const
257 {
258  return ( _isOK != 0 );
259 }
260 
261 
262 inline unsigned int DtUniqueEntryArrWData::error() const
263 {
264  return ErrFlg;
265 }
266 
267 
268 inline unsigned int DtUniqueEntryArrWData::minVal() const
269 {
270  return ( ( sz_nu <= 0 ) ? (~(unsigned int)0) : arr[0].key );
271 }
272 
273 
274 inline unsigned int DtUniqueEntryArrWData::maxVal() const
275 {
276  return ( ( sz_nu <= 0 ) ? (~(unsigned int)0) : arr[( sz_nu - 1 )].key );
277 }
278 
279 
283 
284 
295 class DT_DLL_LGRSIM DtUniqueEntryArrayVPtr
296 {
297 public:
298  typedef int ( *cmpEntries )( void*, void* );
299  typedef void* ( *copyEntry )( void* );
300  typedef void ( *deleteEntry )( void* );
301 
303  DtUniqueEntryArrayVPtr();
305  ~DtUniqueEntryArrayVPtr();
307  DtUniqueEntryArrayVPtr( const DtUniqueEntryArrayVPtr& src );
309  DtUniqueEntryArrayVPtr& operator=( const DtUniqueEntryArrayVPtr& src );
310 
312  bool operator==( const DtUniqueEntryArrayVPtr& rhs ) const;
313  bool operator!=( const DtUniqueEntryArrayVPtr& rhs ) const;
315  inline void* operator[]( int ix ) const;
316 
319  bool init( cmpEntries cmpFnc, copyEntry cpyFnc, deleteEntry delFnc );
320 
321  inline int count() const;
322  inline bool isOK() const;
323  inline unsigned int error() const;
324  inline void* minVal() const;
325  inline void* maxVal() const;
326 
327  int lookup( void* val ) const;
328  int remove( void* val );
329  int append( void* val );
330  void empty();
331 
332 protected:
333 
334  bool duplicate( const DtUniqueEntryArrayVPtr& src );
335  void reset( bool all );
336  void removeAt( int ix );
337  bool insertAt( int ix );
338  bool resizeTo( int ix );
339 
340  cmpEntries myCmpFnc;
341  copyEntry myCpyFnc;
342  deleteEntry myDelFnc;
343  void** myEntries;
344  int sz_nu, sz_na, myOkFlag;
345  unsigned int myErrorFlag;
346 };
347 
348 
352 
353 inline void* DtUniqueEntryArrayVPtr::operator[]( int ix ) const
354 {
355  return ( ( ix < 0 || ix >= sz_nu ) ? 0 : myEntries[ix] );
356 }
357 
358 
359 inline int DtUniqueEntryArrayVPtr::count() const
360 {
361  return sz_nu;
362 }
363 
364 
365 inline bool DtUniqueEntryArrayVPtr::isOK() const
366 {
367  return ( myOkFlag != 0 );
368 }
369 
370 
371 inline unsigned int DtUniqueEntryArrayVPtr::error() const
372 {
373  return myErrorFlag;
374 }
375 
376 
377 inline void* DtUniqueEntryArrayVPtr::minVal() const
378 {
379  return ( ( sz_nu <= 0 ) ? 0 : myEntries[0] );
380 }
381 
382 
383 inline void* DtUniqueEntryArrayVPtr::maxVal() const
384 {
385  return ( ( sz_nu <= 0 ) ? 0 : myEntries[( sz_nu - 1 )] );
386 }
387 
388 }
389 
390 #endif
391 #endif
Defines IMPORT/EXPORT macros for lgrSim library.
#define DT_DLL_LGRSIM
Definition: lgrSim.h:21

Document ID: Generated on Thu Dec 18 15:35:09 EST 2025 from SVN revision 282494
Copyright © 2024 MAK Technologies. All Rights Reserved (www.mak.com)