#include <iostream>
#include <iomanip>

#include "JDetector/JHydrophone.hh"

#include "JSupport/JMeta.hh"

#include "Jeep/JContainer.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"


/**
 * \file
 *
 * Auxiliary program to print hydrophone configuration.
 * \author mdejong
 */
int main(int argc, char **argv)
{
  using namespace std;
  using namespace JPP;

  typedef JContainer< vector<JHydrophone> >  container_type;

  string file_name;
  int    string;
  int    debug;

  try {

    JParser<> zap("Auxiliary program to print hydrophone configuration.");

    zap['f'] = make_field(file_name,   "hydrophone file");
    zap['S'] = make_field(string)                                            = -1;
    zap['d'] = make_field(debug)                                             = 1;

    zap(argc, argv);
  }
  catch(const exception &error) {
    FATAL(error.what() << endl);
  }

  container_type data;

  data.load(file_name.c_str());

  if (string != 0) {

    for (const auto& hydrophone : data) {
      if (hydrophone.getString() == string || string == -1) {
	cout << hydrophone << endl;
      }
    }
    
  } else {
    
    cout << data << endl;
  }
}