// ---------------------------------------------------------------------------
// - Folio.hpp                                                               -
// - afnix:sps library - folio class definition                              -
// ---------------------------------------------------------------------------
// - This program is free software;  you can redistribute it  and/or  modify -
// - it provided that this copyright notice is kept intact.                  -
// -                                                                         -
// - This program  is  distributed in  the hope  that it will be useful, but -
// - without  any  warranty;  without  even   the   implied    warranty   of -
// - merchantability or fitness for a particular purpose.  In no event shall -
// - the copyright holder be liable for any  direct, indirect, incidental or -
// - special damages arising in any way out of the use of this software.     -
// ---------------------------------------------------------------------------
// - copyright (c) 1999-2005 amaury darsch                                   -
// ---------------------------------------------------------------------------

#ifndef  AFNIX_FOLIO_HPP
#define  AFNIX_FOLIO_HPP

#ifndef  AFNIX_INPUT_HPP
#include "Input.hpp"
#endif

#ifndef  AFNIX_OUTPUT_HPP
#include "Output.hpp"
#endif

#ifndef  AFNIX_SHEET_HPP
#include "Sheet.hpp"
#endif

namespace afnix {

  /// The Folio class is a folio of sheets. Because of the sheet format, 
  /// a folio look like a 3-dimensional array of cells. Like the 
  /// sheet, the folio is defined with a name and a vector of sheets.
  /// @author amaury darsch

  class Folio : public Persist {
  private:
    /// the folio name
    String d_name;
    /// the sheet vector
    Vector d_vsht;

  public:
    /// create an empty folio
    Folio (void);

    /// create a new folio with a name
    /// @param name the folio name
    Folio (const String& name);

    /// create a new folio with a stream
    /// @param is the input stream to use
    Folio (Input* is);

    /// @return the object name
    String repr (void) const;

    /// write the folio to an output stream
    /// @param os the output stream
    void write (Output& os);

    /// serialize this folio
    /// @param os the output stream
    void wrstream (Output& os) const;

    /// deserialize this folio
    /// @param is the input stream
    void rdstream (Input& os);

    /// @return the folio name
    String getname (void) const;

    /// set the folio name
    /// @param name the name to set
    void setname (const String& name);

    /// @return the folio length
    long length (void) const;

    /// add a new sheet in this folio
    /// @param sheet the sheet to add
    void add (Sheet* sheet);

    /// @return a sheet by index
    Sheet* get (const long index) const;

    /// set a folio by index and sheet
    /// @param index the sheet index
    /// @param sheet the sheet to set
    void set (const long index, Sheet* sheet);

    /// generate a new folio
    /// @param argv the argument vector
    static Object* mknew (Vector* argv);

    /// apply this folio with a set of arguments and a quark
    /// @param robj  robj the current runnable
    /// @param nset  the current nameset    
    /// @param quark the quark to apply these arguments
    /// @param argv  the arguments to apply
    Object* apply (Runnable* robj, Nameset* nset, const long quark,
                   Vector* argv);
    
  private:
    // make the copy constructor private
    Folio (const Folio&);
    // make the assignment operator private
    Folio& operator = (const Folio&);
  };
}

#endif
