// $Id: UgliDbiGeometry.h,v 1.9 2005/08/26 19:00:02 rhatcher Exp $

#ifndef UGLIDBIGEOMETRY_H
#define UGLIDBIGEOMETRY_H

////////////////////////////////////////////////////////////////////////
// UgliDbiGeometry
//
// Package: UgliGeometry
//
// Concept:
//
//
// R. Hatcher 2001-08-08
////////////////////////////////////////////////////////////////////////

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

#include "Conventions/Detector.h"

class DbiValidityRec;

#include <iosfwd>

class UgliDbiGeometry;
std::ostream& operator<<(std::ostream& os, const UgliDbiGeometry& udg);

class UgliDbiGeometry : public DbiTableRow
{

public:

// Constructors and destructors.

   UgliDbiGeometry() : fXYisUV(false) 
      { LEA_CTOR; 
        for (int i=0; i<3; i++) {
           fHallXYZMin[i]=0;
           fHallXYZMax[i]=0;
        }
      };

   UgliDbiGeometry(Detector::Detector_t /*det*/, Bool_t xyisuv, 
                   const Float_t *hall_xyz_min, const Float_t *hall_xyz_max) : 
      fXYisUV(xyisuv) 
      { LEA_CTOR; 
        for (int i=0; i<3; i++) {
           fHallXYZMin[i]=hall_xyz_min[i];
           fHallXYZMax[i]=hall_xyz_max[i];
        }
      };
   virtual ~UgliDbiGeometry(){ LEA_DTOR; };

// State testing member functions

   Bool_t           GetXYisUV() const { return fXYisUV; }
   const Float_t*   GetHallXYZMin() const { return fHallXYZMin; }
   const Float_t*   GetHallXYZMax() const { return fHallXYZMax; }

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

// I/O  member functions

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

   virtual std::ostream& FormatToOStream(std::ostream& os, 
                                         Option_t *option="",
                                         const DbiValidityRec* vrec=0) const;
   virtual void          Print(Option_t *option="") const;

   static const char*    GetTableDescr();
   static void           SetDefensiveUnpkg(Bool_t defensive) 
      { fgDefensiveUnpkg = defensive; }
   static Bool_t         GetDefensiveUnpkg() { return fgDefensiveUnpkg; }

private:  

// Constructors and destructors.

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

// Data members

   Bool_t                 fXYisUV;
   Float_t                fHallXYZMin[3];
   Float_t                fHallXYZMax[3];

// class-wide static

   static Bool_t fgDefensiveUnpkg;

ClassDef(UgliDbiGeometry,0)

};

#endif  // UGLIDBIGEOMETRY_H
