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

#ifndef PLEXRAWCHANNELREADOUTTYPE_H
#define PLEXRAWCHANNELREADOUTTYPE_H

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

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

#include "Conventions/ReadoutType.h"
#include "RawData/RawChannelId.h"
#include <string>

class DbiValidityRec;

class PlexRawChannelReadoutType : public DbiTableRow
{

public:

// Constructors and destructors.

   PlexRawChannelReadoutType() :
     fRawChannelId(), fReadoutType(ReadoutType::kUnknown),
     fDescript("Unknown") { LEA_CTOR; }
   PlexRawChannelReadoutType(Detector::Detector_t det,
                             ElecType::Elec_t elec, 
                             Int_t crate, Int_t chadd,
                             ReadoutType::Readout_t rtype,
                             std::string add_descript ="") :
      fRawChannelId(det,elec,crate,chadd),
      fReadoutType(rtype), 
      fDescript(ReadoutType::AsString(rtype)+add_descript) { LEA_CTOR; };
   virtual ~PlexRawChannelReadoutType(){ LEA_DTOR; };

// State testing member functions

   RawChannelId           GetRawChannelId() const { return fRawChannelId; }
   ReadoutType::Readout_t GetReadoutType() const { return fReadoutType; } 
   std::string            GetDescript() const { return fDescript; }

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

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

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

// Data members

   RawChannelId           fRawChannelId;
   ReadoutType::Readout_t fReadoutType;
   std::string            fDescript;

// class-wide static

   static Bool_t fgDefensiveUnpkg;

ClassDef(PlexRawChannelReadoutType,0)

};

#endif  // PLEXRAWCHANNELREADOUTTYPE_H
