/// QasTools: Desktop toolset for the Linux sound system ALSA.
/// \copyright See COPYING file.

#pragma once

#include <cstddef>

namespace Utility
{

/// @brief Setup base class
///
class Setup
{
  public:
  // -- Construction

  Setup ( Setup * parent_n );

  virtual ~Setup ();

  // -- Parent

  Setup *
  parent () const
  {
    return _parent;
  }

  // -- Change id

  std::size_t
  change_id () const
  {
    return _change_id;
  }

  protected:
  // -- Protected methods

  void
  notify_change ();

  template < typename T >
  bool
  change ( T & store_n, const T & value_n )
  {
    if ( store_n != value_n ) {
      store_n = value_n;
      notify_change ();
      return true;
    }
    return false;
  }

  private:
  // -- Attributes
  Setup * _parent = nullptr;
  std::size_t _change_id = 0;
};

} // namespace Utility
