/* src/bazaar.p/bz-size-result.c
 *
 * Copyright 2026 AUTOGEN
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * 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.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include "src/bazaar.p/bz-size-result.h"



struct _BzSizeResult
{
  GObject parent_instance;

  guint64 user_data_size;
  guint64 cache_size;
};

G_DEFINE_FINAL_TYPE (BzSizeResult, bz_size_result, G_TYPE_OBJECT);

enum
{
  PROP_0,

  PROP_USER_DATA_SIZE,
  PROP_CACHE_SIZE,

  LAST_PROP
};
static GParamSpec *props[LAST_PROP] = { 0 };

static void
bz_size_result_dispose (GObject *object)
{
  BzSizeResult *self = BZ_SIZE_RESULT (object);



  G_OBJECT_CLASS (bz_size_result_parent_class)->dispose (object);
}

static void
bz_size_result_get_property (GObject    *object,
                       guint       prop_id,
                       GValue     *value,
                       GParamSpec *pspec)
{
  BzSizeResult *self = BZ_SIZE_RESULT (object);

  switch (prop_id)
    {
    case PROP_USER_DATA_SIZE:
      g_value_set_uint64 (value, bz_size_result_get_user_data_size (self));
      break;
    case PROP_CACHE_SIZE:
      g_value_set_uint64 (value, bz_size_result_get_cache_size (self));
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
    }
}

static void
bz_size_result_set_property (GObject      *object,
                       guint         prop_id,
                       const GValue *value,
                       GParamSpec   *pspec)
{
  BzSizeResult *self = BZ_SIZE_RESULT (object);

  switch (prop_id)
    {
    case PROP_USER_DATA_SIZE:
      bz_size_result_set_user_data_size (self, g_value_get_uint64 (value));
      break;
    case PROP_CACHE_SIZE:
      bz_size_result_set_cache_size (self, g_value_get_uint64 (value));
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
    }
}

static void
bz_size_result_class_init (BzSizeResultClass *klass)
{
  GObjectClass *object_class = G_OBJECT_CLASS (klass);



  object_class->set_property = bz_size_result_set_property;
  object_class->get_property = bz_size_result_get_property;
  object_class->dispose      = bz_size_result_dispose;

  props[PROP_USER_DATA_SIZE] =
      g_param_spec_uint64 (
          "user-data-size",
          NULL, NULL,
          0, G_MAXUINT64, 0,
          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);

  props[PROP_CACHE_SIZE] =
      g_param_spec_uint64 (
          "cache-size",
          NULL, NULL,
          0, G_MAXUINT64, 0,
          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);

  g_object_class_install_properties (object_class, LAST_PROP, props);
}

static void
bz_size_result_init (BzSizeResult *self)
{
}

BzSizeResult *
bz_size_result_new (void){
  return g_object_new (BZ_TYPE_SIZE_RESULT, NULL);
}

guint64
bz_size_result_get_user_data_size (BzSizeResult *self){
  g_return_val_if_fail (BZ_IS_SIZE_RESULT (self), 0);
  return self->user_data_size;
}

guint64
bz_size_result_get_cache_size (BzSizeResult *self){
  g_return_val_if_fail (BZ_IS_SIZE_RESULT (self), 0);
  return self->cache_size;
}

void
bz_size_result_set_user_data_size (BzSizeResult *self,
    guint64 user_data_size){
  g_return_if_fail (BZ_IS_SIZE_RESULT (self));

  if (user_data_size == self->user_data_size)
    return;

  self->user_data_size = user_data_size;

  g_object_notify_by_pspec (G_OBJECT (self), props[PROP_USER_DATA_SIZE]);
}

void
bz_size_result_set_cache_size (BzSizeResult *self,
    guint64 cache_size){
  g_return_if_fail (BZ_IS_SIZE_RESULT (self));

  if (cache_size == self->cache_size)
    return;

  self->cache_size = cache_size;

  g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CACHE_SIZE]);
}



/* End of src/bazaar.p/bz-size-result.c */
