// $Id: PlexPixelToRawChannel.h,v 1.9 2005/08/26 18:47:03 rhatcher Exp $

#ifndef PLEXPIXELTORAWCHANNEL_H
#define PLEXPIXELTORAWCHANNEL_H

////////////////////////////////////////////////////////////////////////
// PlexPixelToRawChannel
//
// Package: Plex
//
// Concept: 
//
//
// R. Hatcher 2001-06-27
////////////////////////////////////////////////////////////////////////

#include "DatabaseInterface/DbiTableRow.h"
#include "LeakChecker/Lea.h"

#include "RawData/RawChannelId.h"
#include "Plex/PlexPixelSpotId.h"

class DbiValidityRec;

class PlexPixelToRawChannel : public DbiTableRow
{

public:

// Constructors and destructors.

   PlexPixelToRawChannel() { LEA_CTOR; }
   PlexPixelToRawChannel(Detector::Detector_t det,
                         ElecType::Elec_t elec,
                         Char_t eastwest, Char_t racklevel, 
                         Int_t rackbay, Int_t inrack,
                         Int_t tube, Int_t pixel,
                         Int_t crate, Int_t chadd) :
      fPlexPixelSpotId(det,elec,eastwest,racklevel,rackbay,inrack,tube,pixel,0),
      fRawChannelId(det,elec,crate,chadd) { LEA_CTOR; }
   virtual ~PlexPixelToRawChannel(){ LEA_DTOR; };

// State testing member functions

   virtual Int_t    GetAggregateNo() const { return fAggregate; }
   PlexPixelSpotId  GetPlexPixelSpotId() const { return fPlexPixelSpotId; }
   RawChannelId     GetRawChannelId() const { return fRawChannelId; }

  virtual DbiTableRow* CreateTableRow() const { return new PlexPixelToRawChannel; }

// I/O  member functions

   virtual void Fill(DbiResultSet& rs,
                     const DbiValidityRec* vrec);
   virtual void Store(DbiOutRowStream& ors,
                      const DbiValidityRec* vrec) const;

   static void   SetDefensiveUnpkg(Bool_t defensive) 
      { fgDefensiveUnpkg = defensive; }
   static Bool_t GetDefensiveUnpkg() { return fgDefensiveUnpkg; }

private:  

// Constructors and destructors.

   PlexPixelToRawChannel(const PlexPixelToRawChannel& from)
     : DbiTableRow(from) { LEA_CTOR; *this = from; }

// Data members

   Int_t            fAggregate;
   PlexPixelSpotId  fPlexPixelSpotId;
   RawChannelId     fRawChannelId;
   
// class-wide static

   static Bool_t fgDefensiveUnpkg;

ClassDef(PlexPixelToRawChannel,0)

};

#endif  // PLEXPIXELTORAWCHANNEL_H
