// ---------------------------------------------------------------------------
// - Taggable.hpp                                                            -
// - standard object library - taggable abstract 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-2019 amaury darsch                                   -
// ---------------------------------------------------------------------------

#ifndef  AFNIX_TAGGABLE_HPP
#define  AFNIX_TAGGABLE_HPP

#ifndef  AFNIX_NAMEABLE_HPP
#include "Nameable.hpp"
#endif

namespace afnix {

  /// The Taggable class is an abstract class which represents a serializable
  /// object by name and info.
  /// @author amaury darsch

  class Taggable : public virtual Serial, public Nameable {
  protected:
    /// the taggable name
    String  d_name;
    /// the taggable info
    String  d_info;
    
  public:
    /// create a default taggable
    Taggable (void) =default;

    /// create a taggable by name
    /// @param name the taggable name
    Taggable (const String& name);

    /// create a taggable by name and info
    /// @param name the taggable name
    /// @param info the taggable info
    Taggable (const String& name, const String& info);
    
    /// copy construct this taggable object
    /// @param that the taggable to copy
    Taggable (const Taggable& that);

    /// copy move this taggable object
    /// @param that the taggable to move
    Taggable (Taggable&& that) noexcept;

    /// assign a taggable into this one
    /// @param that the taggable to assign
    Taggable& operator = (const Taggable& that);

    /// move a taggable into this one
    /// @param that the taggable to move
    Taggable& operator = (Taggable&& that) noexcept;

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

    /// deserialize this taggable
    /// @param is the input stream
    void rdstream (InputStream& os);
    
    /// @return the object name
    String getname (void) const;

    /// set the taggable name
    /// @param name the name to set
    virtual void setname (const String& name);
    
    /// @return the taggable info
    virtual String getinfo (void) const;

    /// set the taggable info
    /// @param info the info to set
    virtual void setinfo (const String& info);

  public:
    /// @return true if the given quark is defined
    bool isquark (const long quark, const bool hflg) const;

    /// apply this object with a set of arguments and a quark
    /// @param 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);
  };
}

#endif
