NavKey Class Reference

#include <NavKey.h>

List of all members.

Public Types

enum  ETag { kInt, kFloat, kString }
enum  { kMaxStringSize = 8 }

Public Member Functions

 NavKey (bool i)
 NavKey (unsigned char i)
 NavKey (Int_t i=0)
 NavKey (UInt_t i)
 NavKey (Long_t i)
 NavKey (Double_t f)
 NavKey (const NavKey &k)
 NavKey (const char *s)
virtual ~NavKey ()
Int_t CompareValue (NavKey that) const
Bool_t CompareType (NavKey that) const
Long_t ForceLong_t ()
std::string GetType () const
std::string GetValue () const

Private Attributes

ETag fTag
union {
   Double_t   fFloat
   Long_t   fInt
   char   fString [kMaxStringSize]
}; 

Static Private Attributes

static char fValueStr [15]

Detailed Description

Definition at line 30 of file NavKey.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
kMaxStringSize 

Definition at line 36 of file NavKey.h.

00036 { kMaxStringSize = 8 };

Enumerator:
kInt 
kFloat 
kString 

Definition at line 35 of file NavKey.h.

00035 { kInt, kFloat, kString };


Constructor & Destructor Documentation

NavKey::NavKey ( bool  i  )  [inline]

Definition at line 39 of file NavKey.h.

References fInt, fTag, kInt, and LEA_CTOR.

00039 { LEA_CTOR; fInt   = i;   fTag = kInt; }

NavKey::NavKey ( unsigned char  i  )  [inline]

Definition at line 40 of file NavKey.h.

References fInt, fTag, kInt, and LEA_CTOR.

00041                                 { LEA_CTOR; fInt   = i;   fTag = kInt; }

NavKey::NavKey ( Int_t  i = 0  )  [inline]

Definition at line 42 of file NavKey.h.

References fInt, fTag, kInt, and LEA_CTOR.

00042 { LEA_CTOR; fInt   = i;   fTag = kInt; }

NavKey::NavKey ( UInt_t  i  )  [inline]

Definition at line 43 of file NavKey.h.

References fInt, fTag, kInt, and LEA_CTOR.

00043 { LEA_CTOR; fInt   = i;   fTag = kInt; }

NavKey::NavKey ( Long_t  i  )  [inline]

Definition at line 44 of file NavKey.h.

References fInt, fTag, kInt, and LEA_CTOR.

00044 { LEA_CTOR; fInt   = i;   fTag = kInt; }

NavKey::NavKey ( Double_t  f  )  [inline]

Definition at line 45 of file NavKey.h.

References fFloat, fTag, kFloat, and LEA_CTOR.

00045 { LEA_CTOR; fFloat = f; fTag = kFloat; }

NavKey::NavKey ( const NavKey k  )  [inline]

Definition at line 46 of file NavKey.h.

References LEA_CTOR.

00046 { LEA_CTOR; *this = k; }

NavKey::NavKey ( const char *  s  ) 

Definition at line 165 of file NavKey.cxx.

References fString, fTag, Msg::kError, kMaxStringSize, kString, LEA_CTOR, and MSG.

00165                                  {
00166 //
00167 //
00168 //  Purpose: Constructor for character string value.
00169 //
00170 //  Arguments: 
00171 //    string       in    Initialising char string
00172 //
00173 //  Return:    n/a
00174 //
00175 //  Contact:   N. West
00176 //
00177 //  Specification:-
00178 //  =============
00179 //
00180 //  o Construct NavKey from character string value.  If string too
00181 //    long truncate it.
00182 
00183 //  Program Notes:-
00184 //  =============
00185 
00186 //  None.
00187 
00188   LEA_CTOR   //Leak Checking
00189 
00190   strncpy( fString, string, kMaxStringSize );
00191   fString[kMaxStringSize-1] = '\0';
00192   fTag = kString;
00193 
00194   if ( strlen( string ) >= kMaxStringSize ) {
00195     MSG("Nav", Msg::kError) << "String "  << string 
00196        << " too long, truncated to " << fString << endl;
00197   }  
00198 }

virtual NavKey::~NavKey (  )  [inline, virtual]

Definition at line 48 of file NavKey.h.

References LEA_DTOR.

00048 { LEA_DTOR; }


Member Function Documentation

Bool_t NavKey::CompareType ( NavKey  that  )  const [inline]

Definition at line 52 of file NavKey.h.

References fTag.

00052 {return fTag == that.fTag;}

Int_t NavKey::CompareValue ( NavKey  that  )  const

Definition at line 45 of file NavKey.cxx.

References ANtpDefaultValue::kFloat, ANtpDefaultValue::kInt, Msg::kWarning, and MSG.

Referenced by NavSet::DoSelectSlice(), NavSet::GetZone(), AlgStripSRList::MakeXtalkMap(), NavValidate::Test_6(), NavSet::Update(), and NavSet::XLessThanY().

00045                                             {
00046 //
00047 //
00048 //  Purpose:  Compare this NavKey with that NavKey
00049 //
00050 //  Arguments: 
00051 //    that         in    The NavKey to be compared with.
00052 //
00053 //  Return:  this - that:-
00054 //             =  1   this > that
00055 //             =  0   this = that
00056 //             = -1   this < that
00057 //             = 999  that NavKey is not of same type.
00058 //
00059 //  Contact:   N. West
00060 //
00061 //  Specification:-
00062 //  =============
00063 //
00064 //  o Compare two NavKeys.
00065 
00066 //  Program Notes:-
00067 //  =============
00068 
00069 //  None.
00070 
00071   if ( ! CompareType(that) ) {
00072     
00073     MSG("Nav", Msg::kWarning) << "Cannot compare NavKeys:-" << endl
00074        << "   this:" << GetType()      << " " << GetValue()       << endl
00075        << "   that:" << that.GetType() << " " << that.GetValue()  << endl;
00076 
00077     return 999;
00078   }
00079 
00080   switch (fTag) {
00081     case kInt:
00082       return ( fInt > that.fInt ) ? 1 : ( fInt < that.fInt ) ? -1 : 0;
00083     case kFloat:
00084       return ( fFloat > that.fFloat ) ? 1 : 
00085                                      ( fFloat < that.fFloat) ? -1 : 0;    
00086     default:
00087       Int_t test = strcmp(fString, that.fString);
00088       return ( test > 0 ) ? 1 : ( test < 0 ) ? -1 : 0;
00089   }
00090 
00091 }

Long_t NavKey::ForceLong_t (  )  [inline]

Definition at line 53 of file NavKey.h.

References fInt.

Referenced by NavGenLattice::Rebuild().

00053 { return fInt; }  // Regardless of fTag

string NavKey::GetType (  )  const

Definition at line 95 of file NavKey.cxx.

References fTag, kFloat, and kInt.

00095                              {
00096 //
00097 //
00098 //  Purpose:  Return NavKey type as string.
00099 //
00100 //  Arguments: None.
00101 //
00102 //  Return:  NavKey type as string.  
00103 //
00104 //  Contact:   N. West
00105 //
00106 //  Specification:-
00107 //  =============
00108 //
00109 //  o Return NavKey type as string.
00110 
00111 //  Program Notes:-
00112 //  =============
00113 
00114 //  None.
00115 
00116   switch (fTag) {
00117     case kInt:   return "Int";
00118     case kFloat: return "Float";
00119     default:     return "String";
00120    }
00121 
00122 }

string NavKey::GetValue (  )  const

Definition at line 126 of file NavKey.cxx.

References fFloat, fInt, fString, fTag, fValueStr, kFloat, and kInt.

Referenced by NavValidate::Test_6().

00126                               {
00127 //
00128 //
00129 //  Purpose:  Return NavKey value as string.
00130 //
00131 //  Arguments: None.
00132 //
00133 //  Return:  NavKey value as string.  
00134 //
00135 //  Contact:   N. West
00136 //
00137 //  Specification:-
00138 //  =============
00139 //
00140 //  o Return NavKey value as string.
00141 
00142 //  Program Notes:-
00143 //  =============
00144 
00145 //  None.
00146 
00147   switch (fTag) {
00148     case kInt:
00149       sprintf( fValueStr, "%ld", fInt);
00150       break;
00151     case kFloat:
00152       sprintf( fValueStr, "%g", fFloat );
00153       break;
00154    default:
00155       sprintf( fValueStr, "%s", fString);
00156       break;
00157   }
00158 
00159   return fValueStr;
00160 
00161 }


Member Data Documentation

union { ... } [private]
Double_t NavKey::fFloat

Definition at line 65 of file NavKey.h.

Referenced by GetValue(), and NavKey().

Long_t NavKey::fInt

Definition at line 66 of file NavKey.h.

Referenced by ForceLong_t(), GetValue(), and NavKey().

char NavKey::fString[kMaxStringSize]

Definition at line 67 of file NavKey.h.

Referenced by GetValue(), and NavKey().

ETag NavKey::fTag [private]

Definition at line 63 of file NavKey.h.

Referenced by CompareType(), GetType(), GetValue(), and NavKey().

char NavKey::fValueStr [static, private]

Definition at line 70 of file NavKey.h.

Referenced by GetValue().


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1