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

#ifndef PLEXRAWCHANNELTOPINDIODE_H
#define PLEXRAWCHANNELTOPINDIODE_H

////////////////////////////////////////////////////////////////////////
// PlexRawChannelToPinDiode
//
// Package: Plex
//
// Concept:
//
//
// R. hatcher 2001-07-16
////////////////////////////////////////////////////////////////////////

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

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

class DbiValidityRec;

class PlexRawChannelToPinDiode : public DbiTableRow
{

public:

// Constructors and destructors.

   PlexRawChannelToPinDiode() { LEA_CTOR; }
   PlexRawChannelToPinDiode(Detector::Detector_t det,
                            ElecType::Elec_t elec, 
                            Int_t crate, Int_t chadd,
                            Char_t eastwest, Char_t racklevel,
                            Int_t rackbay, Int_t inrack,
                            Int_t inbox, Int_t gain) :
     fRawChannelId(det,elec,crate,chadd),
     fPlexPinDiodeId(det,elec,eastwest,racklevel,rackbay,inrack,inbox,gain) 
     { LEA_CTOR; };
   virtual ~PlexRawChannelToPinDiode(){ LEA_DTOR; };

// State testing member functions

   virtual Int_t   GetAggregateNo() const { return fAggregate; }
   RawChannelId    GetRawChannelId() const { return fRawChannelId; }
   PlexPinDiodeId  GetPlexPinDiodeId() const { return fPlexPinDiodeId; }


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

// 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.

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

// Data members

   Int_t                  fAggregate;
   RawChannelId           fRawChannelId;
   PlexPinDiodeId         fPlexPinDiodeId;

// class-wide static

   static Bool_t fgDefensiveUnpkg;

ClassDef(PlexRawChannelToPinDiode,0)

};

#endif  // PLEXRAWCHANNELTOPINDIODE_H
