]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RAW/AliRawEquipmentHeader.cxx
Fix for coverity (AdC)
[u/mrichter/AliRoot.git] / RAW / AliRawEquipmentHeader.cxx
index 329528fa048b4a5e665406c66259418114908c32..6525fb1971a5c9337dcb757e2c26d2a561a4a6a2 100644 (file)
@@ -13,7 +13,7 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-// @(#)alimdc:$Name$:$Id$
+// @(#) $Id$
 // Author: Fons Rademakers  26/11/99
 
 //////////////////////////////////////////////////////////////////////////
 #include <Bytes.h>
 
 #include "AliRawEquipmentHeader.h"
+#include "AliDAQ.h"
 
+#include <Riostream.h>
+
+using std::cout;
+using std::endl;
 ClassImp(AliRawEquipmentHeader)
 
 //______________________________________________________________________________
@@ -40,6 +45,15 @@ AliRawEquipmentHeader::AliRawEquipmentHeader():
     fTypeAttribute[i] = 0;
 }
 
+//______________________________________________________________________________
+UInt_t AliRawEquipmentHeader::SwapWord(UInt_t x) const
+{
+   // Swap the endianess of the integer value 'x'
+
+   return (((x & 0x000000ffU) << 24) | ((x & 0x0000ff00U) <<  8) |
+           ((x & 0x00ff0000U) >>  8) | ((x & 0xff000000U) >> 24));
+}
+
 //______________________________________________________________________________
 void AliRawEquipmentHeader::Swap()
 {
@@ -47,12 +61,12 @@ void AliRawEquipmentHeader::Swap()
    // has already been swapped. This method is only called when the
    // header is read from the DATE event builder (GDC).
 
-   fSize                 = net2host(fSize);
-   fEquipmentType        = net2host(fEquipmentType);
-   fEquipmentID          = net2host(fEquipmentID);
-   fBasicElementSizeType = net2host(fBasicElementSizeType);
+   fSize                 = SwapWord(fSize);
+   fEquipmentType        = SwapWord(fEquipmentType);
+   fEquipmentID          = SwapWord(fEquipmentID);
+   fBasicElementSizeType = SwapWord(fBasicElementSizeType);
    for (int i = 0; i < kAttributeWords; i++)
-      fTypeAttribute[i] = net2host(fTypeAttribute[i]);
+      fTypeAttribute[i] = SwapWord(fTypeAttribute[i]);
 }
 
 //______________________________________________________________________________
@@ -66,3 +80,17 @@ void AliRawEquipmentHeader::Reset()
   for(Int_t i = 0; i < kAttributeWords; i++)
     fTypeAttribute[i] = 0;
 }
+
+//_____________________________________________________________________________
+void AliRawEquipmentHeader::Print( const Option_t* opt ) const
+{
+  // Dumps the equipment header
+  // fields
+
+  cout << opt << "  Equipment size: " << fSize << endl;
+  cout << opt << "  Equipment type: " << fEquipmentType << endl;
+  Int_t ddlIndex;
+  cout << opt << "  Equipment ID: " << fEquipmentID << " ( " << AliDAQ::DetectorNameFromDdlID(fEquipmentID,ddlIndex) << " )" << endl;
+  cout << opt << "  Type attribute: " << fTypeAttribute[0] << "-" << fTypeAttribute[1] << "-" << fTypeAttribute[2] << endl;
+  cout << opt << "  Basic element size type: " << fBasicElementSizeType << endl;
+}