#ifndef CondFormats_SiStripObjects_CommissioningAnalysis_H
#define CondFormats_SiStripObjects_CommissioningAnalysis_H

#include "DataFormats/SiStripCommon/interface/SiStripFecKey.h"
#include "DataFormats/SiStripCommon/interface/SiStripFedKey.h"
#include <sstream>
#include <string>
#include <vector>
#include <cstdint>

/**
   @class CommissioningAnalysis
   @author M.Wingham, R.Bainbridge 
   
   @brief Abstract base for derived classes that provide analysis of
   commissioning histograms.
*/
class CommissioningAnalysis {
public:
  // ---------- con(de)structors ----------

  CommissioningAnalysis(const uint32_t& key, const std::string& my_name);

  CommissioningAnalysis(const std::string& my_name);

  virtual ~CommissioningAnalysis() { ; }

  // ---------- typedefs ----------

  typedef std::vector<float> VFloat;

  typedef std::vector<VFloat> VVFloat;

  typedef std::vector<uint16_t> VInt;

  typedef std::vector<VInt> VVInt;

  typedef std::vector<bool> VBool;

  typedef std::vector<VBool> VVBool;

  typedef std::vector<std::string> VString;

  // ---------- public interface ----------

  /** Identifies if analysis is valid or not. */
  virtual bool isValid() const { return true; }

  /** Returns error codes generated by analyses. */
  inline const VString& getErrorCodes() const;

  /** Returns FEC key object (encodes control structure). */
  inline const uint32_t& fecKey() const;

  /** Returns FED key object (encodes readout structure). */
  inline const uint32_t& fedKey() const;

  /** Returns DCU id. */
  inline const uint32_t& dcuId() const;

  /** Returns DetId. */
  inline const uint32_t& detId() const;

  // ---------- public print methods ----------

  /** Returns object name. */
  inline const std::string& myName() const;

  /** Prints analysis results. */
  virtual void print(std::stringstream&, uint32_t not_used = 0) = 0;

  /** Header information for analysis print(). */
  virtual void header(std::stringstream&) const;

  /** Navigate information for analysis print(). */
  virtual void summary(std::stringstream&) const;

  // ---------- public setter methods ----------

  /** Sets FEC key (encodes control structure). */
  inline void fecKey(const uint32_t&);

  /** Sets FED key (encodes readout structure). */
  inline void fedKey(const uint32_t&);

  /** Sets DCU id. */
  inline void dcuId(const uint32_t&);

  /** Sets DetId. */
  inline void detId(const uint32_t&);

  /** Sets error codes generated by analyses. */
  inline void setErrorCodes(const VString& errors);

  /** Adds error codes generated by analyses. */
  inline virtual void addErrorCode(const std::string& error);

  /** Resets analysis member data. */
  virtual void reset() = 0;

  // ---------- private methods ----------

private:
  /** Private default constructor. */
  CommissioningAnalysis() { ; }

  // ---------- private member data ----------

private:
  /** FEC key object. */
  uint32_t fecKey_;

  /** FEC key object. */
  uint32_t fedKey_;

  /** DCU Id. */
  uint32_t dcuId_;

  /** DetId. */
  uint32_t detId_;

  /** Object name. */
  std::string myName_;

  /** Error codes. */
  VString errors_;
};

// ---------- inline methods ----------

const CommissioningAnalysis::VString& CommissioningAnalysis::getErrorCodes() const { return errors_; }

const uint32_t& CommissioningAnalysis::fecKey() const { return fecKey_; }
const uint32_t& CommissioningAnalysis::fedKey() const { return fedKey_; }

const uint32_t& CommissioningAnalysis::dcuId() const { return dcuId_; }
const uint32_t& CommissioningAnalysis::detId() const { return detId_; }

const std::string& CommissioningAnalysis::myName() const { return myName_; }

void CommissioningAnalysis::fecKey(const uint32_t& key) { fecKey_ = key; }
void CommissioningAnalysis::fedKey(const uint32_t& key) { fedKey_ = key; }

void CommissioningAnalysis::dcuId(const uint32_t& dcu_id) { dcuId_ = dcu_id; }
void CommissioningAnalysis::detId(const uint32_t& det_id) { detId_ = det_id; }

void CommissioningAnalysis::setErrorCodes(const VString& errors) { errors_ = errors; }
void CommissioningAnalysis::addErrorCode(const std::string& error) { errors_.push_back(error); }

#endif  // CondFormats_SiStripObjects_CommissioningAnalysis_H
