/****************************************************************************/
/* Copyright (c) 2015 MBARI                                                 */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  : Power Buoy Data Logger log file writer class                  */
/* Filename : ZSVWriter.hpp                                                 */
/* Author   : Henthorn                                                      */
/* Project  : Power Buoy                                                    */
/* Version  : 1.0                                                           */
/* Created  : 04/21/2015                                                    */
/* Modified :                                                               */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/****************************************************************************/
/*                                                                          */
/* This class is meant to be used with data source objects to write source  */
/* data to a log file in a particular format. Need a different format?      */
/* Derive a new class from ZSVWriter and provide the updated function       */
/* write_to_log(const char*) that simply uses gzputs() in place of fputs(). */
/*                                                                          */
/****************************************************************************/
#ifndef _ZSVWRITER_
#define _ZSVWRITER_

#include <zlib.h>
#include "CSVWriter.hpp"

class ZSVWriter : public CSVWriter {

public:

   // ZSVWriter constructor opens a log file for writing.
   // Default to files spanning 60 minutes.
   //
   ZSVWriter(const char *dirname, const char *filename,
             unsigned char new_file_interval = 60);

   virtual ~ZSVWriter();

   virtual int open_log();    // Opens zip file
   virtual void close_log() { gzclose(_zfile); }
   virtual bool file_open() { return (_zfile != NULL); }

protected:

   // Uses gzputs instead of fputs
   //
   virtual int write_to_log(const char* buf);

   gzFile _zfile;
};

#endif

