#ifndef WRITEOUT_H
#define WRITEOUT_H

#include <ostream>
#include <fstream>
#include <map>

using namespace std;
 
class writeout
{
 public:
  writeout(const string& wdir, const string& signature, 
	   const int& rank, const int& procs);
  void newsub(string subname);
  map<string,ostream*> out;
  ostream *log;
  ~writeout();

 private:
  map<string,ofstream*> of;
  map<string,streambuf*> buf;
  ofstream logf;
  streambuf *logbuf;
  string fulldir;
  char cRank[20];
  int rank;
  int numprocs;
  string getdatfile(string subname);
  string timestring();
  string signature;
  static string longToStr (long arg);
};

#endif
