// Generated by gmmproc 2.66.1 -- DO NOT MODIFY!


#include <glibmm.h>

#include <giomm/liststore.h>
#include <giomm/private/liststore_p.h>


/* Copyright (C) 2016 The giomm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <gio/gio.h>
#include <memory>

namespace
{
extern "C"
{
int ListStoreBase_CompareDataFunc(gconstpointer a, gconstpointer b, gpointer user_data)
{
  auto slot = static_cast<Gio::ListStoreBase::SlotCompare*>(user_data);

  const Glib::RefPtr<const Glib::ObjectBase> item_a =
    Glib::wrap(static_cast<Glib::Object::BaseObjectType*>(const_cast<gpointer>(a)), true);
  const Glib::RefPtr<const Glib::ObjectBase> item_b =
    Glib::wrap(static_cast<Glib::Object::BaseObjectType*>(const_cast<gpointer>(b)), true);

  return (*slot)(item_a, item_b);
}
}
} // anonymous namespace

namespace Gio
{
void ListStoreBase::splice(guint position, guint n_removals,
  const std::vector<Glib::RefPtr<Glib::ObjectBase>>& additions)
{
  const std::size_t n_additions = additions.size();
  std::unique_ptr<gpointer[]> g_additions{new gpointer[n_additions]};
  for (std::size_t i = 0; i < n_additions; i++)
  {
    g_additions[i] = additions[i]->gobj();
  }
  g_list_store_splice(gobj(), position, n_removals, g_additions.get(), n_additions);
}

} // namespace Gio

namespace
{
} // anonymous namespace


namespace Glib
{

Glib::RefPtr<Gio::ListStoreBase> wrap(GListStore* object, bool take_copy)
{
  return Glib::RefPtr<Gio::ListStoreBase>( dynamic_cast<Gio::ListStoreBase*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
  //We use dynamic_cast<> in case of multiple inheritance.
}

} /* namespace Glib */


namespace Gio
{


/* The *_Class implementation: */

const Glib::Class& ListStoreBase_Class::init()
{
  if(!gtype_) // create the GType if necessary
  {
    // Glib::Class has to know the class init function to clone custom types.
    class_init_func_ = &ListStoreBase_Class::class_init_function;

    // This is actually just optimized away, apparently with no harm.
    // Make sure that the parent type has been created.
    //CppClassParent::CppObjectType::get_type();

    // Create the wrapper type, with the same class/instance size as the base type.
    register_derived_type(g_list_store_get_type());

    // Add derived versions of interfaces, if the C type implements any interfaces:
  ListModel::add_interface(get_type());

  }

  return *this;
}


void ListStoreBase_Class::class_init_function(void* g_class, void* class_data)
{
  const auto klass = static_cast<BaseClassType*>(g_class);
  CppClassParent::class_init_function(klass, class_data);


}


Glib::ObjectBase* ListStoreBase_Class::wrap_new(GObject* object)
{
  return new ListStoreBase((GListStore*)object);
}


/* The implementation: */

GListStore* ListStoreBase::gobj_copy()
{
  reference();
  return gobj();
}

ListStoreBase::ListStoreBase(const Glib::ConstructParams& construct_params)
:
  Glib::Object(construct_params)
{

}

ListStoreBase::ListStoreBase(GListStore* castitem)
:
  Glib::Object((GObject*)(castitem))
{}


ListStoreBase::ListStoreBase(ListStoreBase&& src) noexcept
: Glib::Object(std::move(src))
  , ListModel(std::move(src))
{}

ListStoreBase& ListStoreBase::operator=(ListStoreBase&& src) noexcept
{
  Glib::Object::operator=(std::move(src));
  ListModel::operator=(std::move(src));
  return *this;
}


ListStoreBase::~ListStoreBase() noexcept
{}


ListStoreBase::CppClassType ListStoreBase::liststorebase_class_; // initialize static member

GType ListStoreBase::get_type()
{
  return liststorebase_class_.init().get_type();
}


GType ListStoreBase::get_base_type()
{
  return g_list_store_get_type();
}


ListStoreBase::ListStoreBase(GType item_type)
:
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
  Glib::ObjectBase(nullptr),
  Glib::Object(Glib::ConstructParams(liststorebase_class_.init(), "item_type", item_type, nullptr))
{
  

}

Glib::RefPtr<ListStoreBase> ListStoreBase::create(GType item_type)
{
  return Glib::RefPtr<ListStoreBase>( new ListStoreBase(item_type) );
}

void ListStoreBase::insert(guint position, const Glib::RefPtr<Glib::ObjectBase>& item)
{
  g_list_store_insert(gobj(), position, (item)->gobj());
}

guint ListStoreBase::insert_sorted(const Glib::RefPtr<Glib::ObjectBase>& item, const SlotCompare& slot)
{
  // Use the original slot (not a copy).
  auto slot_copy = const_cast<SlotCompare*>(&slot);

  return g_list_store_insert_sorted(gobj(), (item)->gobj(), &ListStoreBase_CompareDataFunc, slot_copy);
}

void ListStoreBase::sort(const SlotCompare& slot)
{
  // Use the original slot (not a copy).
  auto slot_copy = const_cast<SlotCompare*>(&slot);

  g_list_store_sort(gobj(), &ListStoreBase_CompareDataFunc, slot_copy);
}

void ListStoreBase::append(const Glib::RefPtr<Glib::ObjectBase>& item)
{
  g_list_store_append(gobj(), (item)->gobj());
}

void ListStoreBase::remove(guint position)
{
  g_list_store_remove(gobj(), position);
}

void ListStoreBase::remove_all()
{
  g_list_store_remove_all(gobj());
}


Glib::PropertyProxy_ReadOnly< GType > ListStoreBase::property_item_type() const
{
  return Glib::PropertyProxy_ReadOnly< GType >(this, "item-type");
}


} // namespace Gio


