// Generated by gtkmmproc -- DO NOT MODIFY!


#include <gstreamermm/index.h>
#include <gstreamermm/private/index_p.h>

/* gstreamermm - a C++ wrapper for gstreamer
 *
 * Copyright 2008 The gstreamermm 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, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <gst/gstenumtypes.h>


namespace
{

extern "C"
{

static gboolean Index_Filter_gstreamermm_callback(GstIndex* index, GstIndexEntry* entry, void* data)
{
  Gst::Index::SlotFilter * the_slot =
    static_cast<Gst::Index::SlotFilter*>(data);

  try
  {
    return (*the_slot)(Glib::wrap(index, true), Glib::wrap(entry, true));
  }
  catch(...)
  {
    Glib::exception_handlers_invoke();
  }

  return false;
}

static void Index_Filter_gstreamermm_callback_destroy(void* data)
{
  Gst::Index::SlotFilter* the_slot = static_cast<Gst::Index::SlotFilter*>(data);
  if(the_slot)
    delete the_slot;
}

static gboolean Index_Resolver_gstreamermm_callback(GstIndex *index, GstObject *writer, gchar **writer_string, void* data)
{
  Gst::Index::SlotResolver * the_slot =
    static_cast<Gst::Index::SlotResolver*>(data);

  try
  {
    Glib::ustring cpp_writer_string;

    const gboolean result =
      (*the_slot)(Glib::wrap(index, true), Glib::wrap(writer, true),
        cpp_writer_string);

    if(writer_string)
      *writer_string = g_strdup(cpp_writer_string.c_str());

    return result;
  }
  catch(...)
  {
    Glib::exception_handlers_invoke();
  }

  return false;
}

static void Index_Resolver_gstreamermm_callback_destroy(void* data)
{
  delete static_cast<Gst::Index::SlotResolver*>(data);
}

} // extern "C"

} // anonymous namespace

namespace Gst
{

IndexAssociation::IndexAssociation()
: format(Gst::FORMAT_UNDEFINED),
  value(0)
{}

IndexAssociation::IndexAssociation(const GstIndexAssociation* castitem)
: format((castitem) ? static_cast<Gst::Format>(castitem->format) :
    Gst::FORMAT_UNDEFINED),
  value((castitem) ? castitem->value : 0)
{}

bool Index::is_readable() const
{
  return GST_INDEX_IS_READABLE(gobj());
}

bool Index::is_writable() const
{
  return GST_INDEX_IS_WRITABLE(gobj());
}

Gst::IndexEntry Index::get_assoc_entry(int id, gint64 value,
  IndexLookupMethod method, AssocFlags flags, Format format) const
{
  GstIndexEntry* gst_entry =
    gst_index_get_assoc_entry(const_cast<GstIndex*>(gobj()), id,
    (GstIndexLookupMethod) method, (GstAssocFlags) flags, (GstFormat) format,
    value);

  // Return a copy so that the original is not freed by wrapper.
  return Glib::wrap(gst_entry, true);
}

void Index::set_filter(const SlotFilter& slot)
{
  SlotFilter* slot_copy = new SlotFilter(slot); //Deleted in Index_Filter_gstreamermm_callback_destroy
  gst_index_set_filter_full(gobj(), &Index_Filter_gstreamermm_callback, slot_copy, &Index_Filter_gstreamermm_callback_destroy);
}

void Index::set_resolver(const SlotResolver& slot)
{
  SlotResolver* slot_copy = new SlotResolver(slot); 
  gst_index_set_resolver_full(gobj(), &Index_Resolver_gstreamermm_callback, slot_copy, &Index_Resolver_gstreamermm_callback_destroy);
}

void Index_Class::add_entry_vfunc_callback(GstIndex* self, GstIndexEntry* entry)
{
  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
      Glib::ObjectBase::_get_current_wrapper((GObject*)self));

  // Non-gtkmmproc-generated custom classes implicitly call the default
  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  // generated classes can use this optimisation, which avoids the unnecessary
  // parameter conversions if there is no possibility of the virtual function
  // being overridden:
  if(obj_base && obj_base->is_derived_())
  {
    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
    if(obj) // This can be NULL during destruction.
    {
      try // Trap C++ exceptions which would normally be lost because this is a C callback.
      {
        Gst::IndexEntry wrappedEntry(entry, true);
        // Call the virtual member method, which derived classes might override.
        obj->add_entry_vfunc(wrappedEntry);
        return;
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
    }
  }
  
  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
  );

  // Call the original underlying C function:
  if(base && base->add_entry)
    (*base->add_entry)(self, entry);

}
void Gst::Index::add_entry_vfunc(Gst::IndexEntry& entry) 
{
  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
  );

  if(base && base->add_entry)
    (*base->add_entry)(gobj(),(entry).gobj_copy()); // use gobj_copy() so the copy is permanent to the GstIndex.
}

} //namespace Gst

namespace
{


static void Index_signal_entry_added_callback(GstIndex* self, GstIndexEntry* p0,void* data)
{
  using namespace Gst;
  typedef sigc::slot< void,const Gst::IndexEntry& > SlotType;

  // Do not try to call a signal on a disassociated wrapper.
  if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
  {
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    try
    {
    #endif //GLIBMM_EXCEPTIONS_ENABLED
      if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
        (*static_cast<SlotType*>(slot))(Glib::wrap(p0, true)
);
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    }
    catch(...)
    {
      Glib::exception_handlers_invoke();
    }
    #endif //GLIBMM_EXCEPTIONS_ENABLED
  }
}

static const Glib::SignalProxyInfo Index_signal_entry_added_info =
{
  "entry-added",
  (GCallback) &Index_signal_entry_added_callback,
  (GCallback) &Index_signal_entry_added_callback
};


} // anonymous namespace

// static
GType Glib::Value<Gst::IndexCertainty>::value_type()
{
  return gst_index_certainty_get_type();
}

// static
GType Glib::Value<Gst::IndexEntryType>::value_type()
{
  return gst_index_entry_type_get_type();
}

// static
GType Glib::Value<Gst::IndexLookupMethod>::value_type()
{
  return gst_index_lookup_method_get_type();
}

// static
GType Glib::Value<Gst::AssocFlags>::value_type()
{
  return gst_assoc_flags_get_type();
}

// static
GType Glib::Value<Gst::IndexResolverMethod>::value_type()
{
  return gst_index_resolver_method_get_type();
}

// static
GType Glib::Value<Gst::IndexFlags>::value_type()
{
  return gst_index_flags_get_type();
}


namespace Glib
{

Gst::IndexEntry wrap(GstIndexEntry* object, bool take_copy /* = false */)
{
  return Gst::IndexEntry(object, take_copy);
}

} // namespace Glib


namespace Gst
{


IndexEntry::IndexEntry()
:
  gobject_ (0) // Allows creation of invalid wrapper, e.g. for output arguments to methods.
{}

IndexEntry::IndexEntry(const IndexEntry& src)
:
  gobject_ ((src.gobject_) ? gst_index_entry_copy(src.gobject_) : 0)
{}

IndexEntry::IndexEntry(GstIndexEntry* castitem, bool make_a_copy /* = false */)
{
  if(!make_a_copy)
  {
    // It was given to us by a function which has already made a copy for us to keep.
    gobject_ = castitem;
  }
  else
  {
    // We are probably getting it via direct access to a struct,
    // so we can not just take it - we have to take a copy of it.
    if(castitem)
      gobject_ = gst_index_entry_copy(castitem);
    else
      gobject_ = 0;
  }
}

IndexEntry& IndexEntry::operator=(const IndexEntry& src)
{
  GstIndexEntry *const new_gobject = (src.gobject_) ? gst_index_entry_copy(src.gobject_) : 0;

  if(gobject_)
    gst_index_entry_free(gobject_);

  gobject_ = new_gobject;

  return *this;
}

IndexEntry::~IndexEntry()
{
  if(gobject_)
    gst_index_entry_free(gobject_);
}

GstIndexEntry* IndexEntry::gobj_copy() const
{
  return gst_index_entry_copy(gobject_);
}


bool IndexEntry::assoc_map(Format format, gint64& value) const
{
  return gst_index_entry_assoc_map(const_cast<GstIndexEntry*>(gobj()), ((GstFormat)(format)), &value);
}


} // namespace Gst


namespace Gst
{


} // namespace Gst


namespace Glib
{

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

} /* namespace Glib */


namespace Gst
{


/* The *_Class implementation: */

const Glib::Class& Index_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_ = &Index_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(gst_index_get_type());

    // Add derived versions of interfaces, if the C type implements any interfaces:

  }

  return *this;
}


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

  klass->get_writer_id = &get_writer_id_vfunc_callback;
  klass->commit = &commit_vfunc_callback;
  klass->add_entry = &add_entry_vfunc_callback;
  
  klass->entry_added = &entry_added_callback;
}

gboolean Index_Class::get_writer_id_vfunc_callback(GstIndex* self, gint* writer_id, gchar* writer_string)
{
  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
      Glib::ObjectBase::_get_current_wrapper((GObject*)self));

  // Non-gtkmmproc-generated custom classes implicitly call the default
  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  // generated classes can use this optimisation, which avoids the unnecessary
  // parameter conversions if there is no possibility of the virtual function
  // being overridden:
  if(obj_base && obj_base->is_derived_())
  {
    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
    if(obj) // This can be NULL during destruction.
    {
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      try // Trap C++ exceptions which would normally be lost because this is a C callback.
      {
      #endif //GLIBMM_EXCEPTIONS_ENABLED
        // Call the virtual member method, which derived classes might override.
        return static_cast<int>(obj->get_writer_id_vfunc(*(writer_id)
, Glib::convert_const_gchar_ptr_to_ustring(writer_string)
));
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
      #endif //GLIBMM_EXCEPTIONS_ENABLED
    }
  }
  
  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
  );

  // Call the original underlying C function:
  if(base && base->get_writer_id)
    return (*base->get_writer_id)(self, writer_id, writer_string);


  typedef gboolean RType;
  return RType();
}
void Index_Class::commit_vfunc_callback(GstIndex* self, gint id)
{
  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
      Glib::ObjectBase::_get_current_wrapper((GObject*)self));

  // Non-gtkmmproc-generated custom classes implicitly call the default
  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  // generated classes can use this optimisation, which avoids the unnecessary
  // parameter conversions if there is no possibility of the virtual function
  // being overridden:
  if(obj_base && obj_base->is_derived_())
  {
    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
    if(obj) // This can be NULL during destruction.
    {
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      try // Trap C++ exceptions which would normally be lost because this is a C callback.
      {
      #endif //GLIBMM_EXCEPTIONS_ENABLED
        // Call the virtual member method, which derived classes might override.
        obj->commit_vfunc(id);
        return;
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
      #endif //GLIBMM_EXCEPTIONS_ENABLED
    }
  }
  
  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
  );

  // Call the original underlying C function:
  if(base && base->commit)
    (*base->commit)(self, id);

}

void Index_Class::entry_added_callback(GstIndex* self, GstIndexEntry* p0)
{
  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
      Glib::ObjectBase::_get_current_wrapper((GObject*)self));

  // Non-gtkmmproc-generated custom classes implicitly call the default
  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  // generated classes can use this optimisation, which avoids the unnecessary
  // parameter conversions if there is no possibility of the virtual function
  // being overridden:
  if(obj_base && obj_base->is_derived_())
  {
    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
    if(obj) // This can be NULL during destruction.
    {
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      try // Trap C++ exceptions which would normally be lost because this is a C callback.
      {
      #endif //GLIBMM_EXCEPTIONS_ENABLED
        // Call the virtual member method, which derived classes might override.
        obj->on_entry_added(Glib::wrap(p0, true)
);
        return;
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
      #endif //GLIBMM_EXCEPTIONS_ENABLED
    }
  }
  
  BaseClassType *const base = static_cast<BaseClassType*>(
        g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
    );

  // Call the original underlying C function:
  if(base && base->entry_added)
    (*base->entry_added)(self, p0);
}


Glib::ObjectBase* Index_Class::wrap_new(GObject* object)
{
  return new Index((GstIndex*)object);
}


/* The implementation: */

GstIndex* Index::gobj_copy()
{
  reference();
  return gobj();
}

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

}

Index::Index(GstIndex* castitem)
:
  Object((GstObject*)(castitem))
{}


Index::~Index()
{}


Index::CppClassType Index::index_class_; // initialize static member

GType Index::get_type()
{
  return index_class_.init().get_type();
}


GType Index::get_base_type()
{
  return gst_index_get_type();
}

Index::Index()
:
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
  Glib::ObjectBase(0),
  Object(Glib::ConstructParams(index_class_.init()))
{
  

}

void Index::commit(int id)
{
gst_index_commit(gobj(), id); 
}

int Index::get_group() const
{
  return gst_index_get_group(const_cast<GstIndex*>(gobj()));
}

int Index::new_group()
{
  return gst_index_new_group(gobj());
}

bool Index::set_group(int group_number)
{
  return gst_index_set_group(gobj(), group_number);
}

void Index::set_certainty(IndexCertainty certainty)
{
gst_index_set_certainty(gobj(), ((GstIndexCertainty)(certainty))); 
}

IndexCertainty Index::get_certainty() const
{
  return ((IndexCertainty)(gst_index_get_certainty(const_cast<GstIndex*>(gobj()))));
}

bool Index::get_writer_id(const Glib::RefPtr<Gst::Object>& writer, int& id) const
{
  return gst_index_get_writer_id(const_cast<GstIndex*>(gobj()), Glib::unwrap(writer), &id);
}

Gst::IndexEntry Index::add_format(int id, Format format)
{
  return Glib::wrap(gst_index_add_format(gobj(), id, ((GstFormat)(format))), true);
}

Gst::IndexEntry Index::add_association(int id, AssocFlags flags, int n, const Glib::ArrayHandle<const Gst::IndexAssociation>& list)
{
  return Glib::wrap(gst_index_add_associationv(gobj(), id, ((GstAssocFlags)(flags)), n, (const GstIndexAssociation*)((list).data())), true);
}

Gst::IndexEntry Index::add_id(int id, const Glib::ustring& description)
{
  return Glib::wrap(gst_index_add_id(gobj(), id, const_cast<gchar*>(description.c_str())), true);
}


Glib::SignalProxy1< void,const Gst::IndexEntry& > Index::signal_entry_added()
{
  return Glib::SignalProxy1< void,const Gst::IndexEntry& >(this, &Index_signal_entry_added_info);
}


#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy<Gst::Index::SlotResolver> Index::property_resolver() 
{
  return Glib::PropertyProxy<Gst::Index::SlotResolver>(this, "resolver");
}
#endif //GLIBMM_PROPERTIES_ENABLED

#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy_ReadOnly<Gst::Index::SlotResolver> Index::property_resolver() const
{
  return Glib::PropertyProxy_ReadOnly<Gst::Index::SlotResolver>(this, "resolver");
}
#endif //GLIBMM_PROPERTIES_ENABLED


void Gst::Index::on_entry_added(const Gst::IndexEntry& entry)
{
  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
  );

  if(base && base->entry_added)
    (*base->entry_added)(gobj(),const_cast<GstIndexEntry*>((entry).gobj()));
}

bool Gst::Index::get_writer_id_vfunc(int& writer_id, const Glib::ustring& writer_string) const
{
  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
  );

  if(base && base->get_writer_id)
    return (*base->get_writer_id)(const_cast<GstIndex*>(gobj()),&writer_id,const_cast<gchar*>(writer_string.c_str()));

  typedef bool RType;
  return RType();
}
void Gst::Index::commit_vfunc(gint id) 
{
  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
  );

  if(base && base->commit)
    (*base->commit)(gobj(),id);
}


} // namespace Gst


