uniqEntryArr.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 ** Copyright (c) 1992-2010 VT MAK
00003 ** All rights reserved.
00004 ******************************************************************************/
00005 
00008 
00009 #ifndef uniqEntryArr_H_
00010 #define uniqEntryArr_H_
00011 
00012 #if DtDIS
00013 
00014 #include "lgrSim.h"
00015 #ifndef _MachineTypes_h
00016 #include <vlutil/vlMachineTypes.h>
00017 #endif
00018 
00019 namespace MAKLogger
00020 {
00021 
00022 struct DT_DLL_LGRSIM DtKeyValuePair
00023 {
00024    unsigned int key;
00025    unsigned int val;
00026 
00027 public:
00028    inline DtKeyValuePair() : key( 0 ), val( 0 ) {}
00029    inline ~DtKeyValuePair() {}
00030    inline DtKeyValuePair( unsigned int _key, unsigned int _val ) :
00031       key( _key ), val( _val ) {}
00032    inline DtKeyValuePair( const DtKeyValuePair& src ) :
00033       key( src.key ), val( src.val ) {}
00034 public:
00036    inline DtKeyValuePair& operator=( const DtKeyValuePair& src )
00037    {
00038       if ( this != &src )
00039       {
00040          key = src.key;  val = src.val;
00041       }
00042       return *this;
00043    }
00045    inline bool operator==( const DtKeyValuePair& rhs )
00046    {
00047       if ( this == &rhs )  return ( 1 == 1 );
00048       return ( key == rhs.key && val == rhs.val );
00049    }
00050    inline bool operator!=( const DtKeyValuePair& rhs )
00051    {
00052       if ( this == &rhs )  return ( 1 == 0 );
00053       return ( key != rhs.key || val != rhs.val );
00054    }
00056    inline unsigned int operator[]( int ix ) const
00057    {
00058       if ( ix < 0 || ix > 1 )
00059       {
00060          return (~(unsigned int)0);
00061       }
00062       else
00063       {
00064          return ( ( ix )  ?  val : key );
00065       }
00066    }
00067 };
00068 
00069 
00073 
00074 
00085 class DT_DLL_LGRSIM DtUniqueEntryArray
00086 {
00087 public:
00089    DtUniqueEntryArray();
00091    ~DtUniqueEntryArray();
00093    DtUniqueEntryArray( const DtUniqueEntryArray& src );
00095    DtUniqueEntryArray& operator=( const DtUniqueEntryArray& src );
00096 
00097 public:
00099    bool operator==( const DtUniqueEntryArray& rhs ) const;
00100    bool operator!=( const DtUniqueEntryArray& rhs ) const;
00102    inline unsigned int operator[]( int ix ) const;
00103 
00104 public:
00105    inline int count() const;
00106    inline bool isOK() const;
00107    inline unsigned int error() const;
00108    inline unsigned int minVal() const;
00109    inline unsigned int maxVal() const;
00110 
00111 public:
00112    int  lookup( unsigned int val ) const;
00113    int  remove( unsigned int val );
00114    int  append( unsigned int val );
00115    void reset();
00116 
00117 protected:
00118    void removeAt( int ix );
00119    bool insertAt( int ix );
00120    bool resizeTo( int ix );
00121 
00122 protected:
00123    unsigned int* myArray;
00124    int sz_nu, sz_na, _isOK;
00125    unsigned int  ErrFlg;
00126 };
00127 
00128 
00132 
00133 inline unsigned int DtUniqueEntryArray::operator[]( int ix ) const
00134 {
00135    return ( ( ix < 0 || ix >= sz_nu )  ?  (~(unsigned int)0) : myArray[ix] );
00136 }
00137 
00138 
00139 inline int DtUniqueEntryArray::count() const
00140 {
00141    return sz_nu;
00142 }
00143 
00144 
00145 inline bool DtUniqueEntryArray::isOK() const
00146 {
00147    return ( _isOK != 0 );
00148 }
00149 
00150 
00151 inline unsigned int DtUniqueEntryArray::error() const
00152 {
00153    return ErrFlg;
00154 }
00155 
00156 
00157 inline unsigned int DtUniqueEntryArray::minVal() const
00158 {
00159    return ( ( sz_nu <= 0 )  ?  (~(unsigned int)0) : myArray[0] );
00160 }
00161 
00162 
00163 inline unsigned int DtUniqueEntryArray::maxVal() const
00164 {
00165    return ( ( sz_nu <= 0 )  ?  (~(unsigned int)0) : myArray[( sz_nu - 1 )] );
00166 }
00167 
00168 
00172 
00173 
00187 class DT_DLL_LGRSIM DtUniqueEntryArrWData
00188 {
00189 public:
00191    DtUniqueEntryArrWData();
00193    ~DtUniqueEntryArrWData();
00195    DtUniqueEntryArrWData( const DtUniqueEntryArrWData& src );
00197    DtUniqueEntryArrWData& operator=( const DtUniqueEntryArrWData& src );
00198 
00200    bool operator==( const DtUniqueEntryArrWData& rhs ) const;
00201    bool operator!=( const DtUniqueEntryArrWData& rhs ) const;
00203    inline const DtKeyValuePair& operator[]( int ix ) const;
00204    inline unsigned int operator()( int ix, int jx ) const;
00205 
00206    inline int count() const;
00207    inline bool isOK() const;
00208    inline unsigned int error() const;
00209    inline unsigned int minVal() const;
00210    inline unsigned int maxVal() const;
00211 
00212    int  lookup( unsigned int key, unsigned int* pval=0 ) const;
00213    int  remove( unsigned int key, unsigned int* pval=0 );
00214    int  append( unsigned int key, unsigned int val, unsigned int* pval=0 );
00215    bool setVal( int ix, unsigned int val, unsigned int* pval=0 );
00216    void reset();
00217 
00218 
00219    void removeAt( int ix );
00220    bool insertAt( int ix );
00221    bool resizeTo( int ix );
00222 
00223    static const DtKeyValuePair dfltDummyEntry;
00224 
00225 protected:
00226    DtKeyValuePair* arr;
00227    int      sz_nu, sz_na, _isOK;
00228    unsigned int  ErrFlg;
00229 };
00230 
00231 
00235 
00236 inline const DtKeyValuePair& DtUniqueEntryArrWData::operator[]( int ix ) const
00237 {
00238    return ( ( ix < 0 || ix >= sz_nu )  ?
00239       DtUniqueEntryArrWData::dfltDummyEntry : arr[ix] );
00240 }
00241 
00242 
00243 inline unsigned int DtUniqueEntryArrWData::operator()( int ix, int jx ) const
00244 {
00245    return ( ( ix < 0 || ix >= sz_nu )  ?
00246       DtUniqueEntryArrWData::dfltDummyEntry[jx] : arr[ix][jx] );
00247 }
00248 
00249 
00250 inline int DtUniqueEntryArrWData::count() const
00251 {
00252    return sz_nu;
00253 }
00254 
00255 
00256 inline bool DtUniqueEntryArrWData::isOK() const
00257 {
00258    return ( _isOK != 0 );
00259 }
00260 
00261 
00262 inline unsigned int DtUniqueEntryArrWData::error() const
00263 {
00264    return ErrFlg;
00265 }
00266 
00267 
00268 inline unsigned int DtUniqueEntryArrWData::minVal() const
00269 {
00270    return ( ( sz_nu <= 0 )  ?  (~(unsigned int)0) : arr[0].key );
00271 }
00272 
00273 
00274 inline unsigned int DtUniqueEntryArrWData::maxVal() const
00275 {
00276    return ( ( sz_nu <= 0 )  ?  (~(unsigned int)0) : arr[( sz_nu - 1 )].key );
00277 }
00278 
00279 
00283 
00284 
00295 class DT_DLL_LGRSIM DtUniqueEntryArrayVPtr
00296 {
00297 public:
00298    typedef int   ( *cmpEntries  )( void*, void* );
00299    typedef void* ( *copyEntry   )( void* );
00300    typedef void  ( *deleteEntry )( void* );
00301 
00303    DtUniqueEntryArrayVPtr();
00305    ~DtUniqueEntryArrayVPtr();
00307    DtUniqueEntryArrayVPtr( const DtUniqueEntryArrayVPtr& src );
00309    DtUniqueEntryArrayVPtr& operator=( const DtUniqueEntryArrayVPtr& src );
00310 
00312    bool operator==( const DtUniqueEntryArrayVPtr& rhs ) const;
00313    bool operator!=( const DtUniqueEntryArrayVPtr& rhs ) const;
00315    inline void* operator[]( int ix ) const;
00316 
00319    bool init( cmpEntries cmpFnc, copyEntry cpyFnc, deleteEntry delFnc );
00320 
00321    inline int count() const;
00322    inline bool isOK() const;
00323    inline unsigned int error() const;
00324    inline void* minVal() const;
00325    inline void* maxVal() const;
00326 
00327    int  lookup( void* val ) const;
00328    int  remove( void* val );
00329    int  append( void* val );
00330    void empty();
00331 
00332 protected:
00333 
00334    bool duplicate( const DtUniqueEntryArrayVPtr& src );
00335    void reset( bool all );
00336    void removeAt( int ix );
00337    bool insertAt( int ix );
00338    bool resizeTo( int ix );
00339 
00340    cmpEntries  myCmpFnc;
00341    copyEntry   myCpyFnc;
00342    deleteEntry myDelFnc;
00343    void** myEntries;
00344    int    sz_nu, sz_na, myOkFlag;
00345    unsigned int  myErrorFlag;
00346 };
00347 
00348 
00352 
00353 inline void* DtUniqueEntryArrayVPtr::operator[]( int ix ) const
00354 {
00355    return ( ( ix < 0 || ix >= sz_nu )  ?  0 : myEntries[ix] );
00356 }
00357 
00358 
00359 inline int DtUniqueEntryArrayVPtr::count() const
00360 {
00361    return sz_nu;
00362 }
00363 
00364 
00365 inline bool DtUniqueEntryArrayVPtr::isOK() const
00366 {
00367    return ( myOkFlag != 0 );
00368 }
00369 
00370 
00371 inline unsigned int DtUniqueEntryArrayVPtr::error() const
00372 {
00373    return myErrorFlag;
00374 }
00375 
00376 
00377 inline void* DtUniqueEntryArrayVPtr::minVal() const
00378 {
00379    return ( ( sz_nu <= 0 )  ?  0 : myEntries[0] );
00380 }
00381 
00382 
00383 inline void* DtUniqueEntryArrayVPtr::maxVal() const
00384 {
00385    return ( ( sz_nu <= 0 )  ?  0 : myEntries[( sz_nu - 1 )] );
00386 }
00387 
00388 }
00389 
00390 #endif
00391 #endif   //! DtUniqueEntryArrWData_H_

Document ID: Generated on Tue Oct 11 19:41:03 EDT 2011 from SVN revision 107422
Copyright © 2005-2011 VT MÄK Inc. All Rights Reserved (www.mak.com)