// Generated by gtkmmproc -- DO NOT MODIFY!


#include <glibmm.h>

#include <gstreamermm/urihandler.h>
#include <gstreamermm/private/urihandler_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>
#include <gstreamermm/element.h>

namespace
{


static void URIHandler_signal_new_uri_callback(GstURIHandler* self, const gchar* p0,void* data)
{
  using namespace Gst;
  typedef sigc::slot< void,const Glib::ustring& > 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::convert_const_gchar_ptr_to_ustring(p0)
);
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    }
    catch(...)
    {
      Glib::exception_handlers_invoke();
    }
    #endif //GLIBMM_EXCEPTIONS_ENABLED
  }
}

static const Glib::SignalProxyInfo URIHandler_signal_new_uri_info =
{
  "new-uri",
  (GCallback) &URIHandler_signal_new_uri_callback,
  (GCallback) &URIHandler_signal_new_uri_callback
};


} // anonymous namespace

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


namespace Glib
{

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

} // namespace Glib


namespace Gst
{


/* The *_Class implementation: */

const Glib::Interface_Class& URIHandler_Class::init()
{
  if(!gtype_) // create the GType if necessary
  {
    // Glib::Interface_Class has to know the interface init function
    // in order to add interfaces to implementing types.
    class_init_func_ = &URIHandler_Class::iface_init_function;

    // We can not derive from another interface, and it is not necessary anyway.
    gtype_ = gst_uri_handler_get_type();
  }

  return *this;
}

void URIHandler_Class::iface_init_function(void* g_iface, void*)
{
  BaseClassType *const klass = static_cast<BaseClassType*>(g_iface);

  //This is just to avoid an "unused variable" warning when there are no vfuncs or signal handlers to connect.
  //This is a temporary fix until I find out why I can not seem to derive a GtkFileChooser interface. murrayc
  g_assert(klass != 0); 

  klass->get_uri = &get_uri_vfunc_callback;
  klass->set_uri = &set_uri_vfunc_callback;

  klass->new_uri = &new_uri_callback;
}

const gchar* URIHandler_Class::get_uri_vfunc_callback(GstURIHandler* self)
{
  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 (obj->get_uri_vfunc()).c_str();
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
      #endif //GLIBMM_EXCEPTIONS_ENABLED
    }
  }

  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
)  );

  // Call the original underlying C function:
  if(base && base->get_uri)
  {
    const gchar* result = (*base->get_uri)(self);
    return result;
  }


  typedef const gchar* RType;
  return RType();
}
gboolean URIHandler_Class::set_uri_vfunc_callback(GstURIHandler* self, const gchar* uri)
{
  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->set_uri_vfunc(Glib::convert_const_gchar_ptr_to_ustring(uri)
));
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
      #endif //GLIBMM_EXCEPTIONS_ENABLED
    }
  }

  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
)  );

  // Call the original underlying C function:
  if(base && base->set_uri)
  {
    gboolean result = (*base->set_uri)(self, uri);
    return result;
  }


  typedef gboolean RType;
  return RType();
}

void URIHandler_Class::new_uri_callback(GstURIHandler* self, const gchar* 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_new_uri(Glib::convert_const_gchar_ptr_to_ustring(p0)
);
        return;
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
      #endif //GLIBMM_EXCEPTIONS_ENABLED
    }
  }

  BaseClassType *const base = static_cast<BaseClassType*>(
        g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
)    );

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


Glib::ObjectBase* URIHandler_Class::wrap_new(GObject* object)
{
  return new URIHandler((GstURIHandler*)(object));
}


/* The implementation: */

URIHandler::URIHandler()
:
  Glib::Interface(urihandler_class_.init())
{}

URIHandler::URIHandler(GstURIHandler* castitem)
:
  Glib::Interface((GObject*)(castitem))
{}

URIHandler::URIHandler(const Glib::Interface_Class& interface_class)
: Glib::Interface(interface_class)
{
}

URIHandler::~URIHandler()
{}

// static
void URIHandler::add_interface(GType gtype_implementer)
{
  urihandler_class_.init().add_interface(gtype_implementer);
}

URIHandler::CppClassType URIHandler::urihandler_class_; // initialize static member

GType URIHandler::get_type()
{
  return urihandler_class_.init().get_type();
}


GType URIHandler::get_base_type()
{
  return gst_uri_handler_get_type();
}


bool URIHandler::protocol_is_valid(const Glib::ustring& protocol)
{
  return gst_uri_protocol_is_valid(protocol.c_str());
}


bool URIHandler::protocol_is_supported(const URIType type, const Glib::ustring& protocol)
{
  return gst_uri_protocol_is_supported((GstURIType)(type), protocol.c_str());
}


bool URIHandler::uri_is_valid(const Glib::ustring& uri)
{
  return gst_uri_is_valid(uri.c_str());
}


bool URIHandler::uri_has_protocol(const Glib::ustring& uri, const Glib::ustring& protocol)
{
  return gst_uri_has_protocol(uri.c_str(), protocol.c_str());
}


Glib::ustring URIHandler::get_protocol(const Glib::ustring& uri)
{
  return Glib::convert_return_gchar_ptr_to_ustring(gst_uri_get_protocol(uri.c_str()));
}


Glib::ustring URIHandler::get_location(const Glib::ustring& uri)
{
  return Glib::convert_return_gchar_ptr_to_ustring(gst_uri_get_location(uri.c_str()));
}


Glib::ustring URIHandler::construct_uri(const Glib::ustring& protocol, const Glib::ustring& location)
{
  return Glib::convert_return_gchar_ptr_to_ustring(gst_uri_construct(protocol.c_str(), location.c_str()));
}


Glib::RefPtr<Gst::Element> URIHandler::make_element_from_uri(const URIType type, const Glib::ustring& uri, const Glib::ustring& name)
{
  return Glib::wrap(gst_element_make_from_uri((GstURIType)(type), uri.c_str(), name.c_str()));
}


guint URIHandler::get_uri_type() const
{
  return gst_uri_handler_get_uri_type(const_cast<GstURIHandler*>(gobj()));
}

Glib::StringArrayHandle URIHandler::get_protocols() const
{
  return Glib::StringArrayHandle(gst_uri_handler_get_protocols(const_cast<GstURIHandler*>(gobj())), Glib::OWNERSHIP_NONE);
}

Glib::ustring URIHandler::get_uri() const
{
  return Glib::convert_const_gchar_ptr_to_ustring(gst_uri_handler_get_uri(const_cast<GstURIHandler*>(gobj())));
}

bool URIHandler::set_uri(const Glib::ustring& uri)
{
  return gst_uri_handler_set_uri(gobj(), uri.c_str());
}

void URIHandler::new_uri(const Glib::ustring& uri)
{
  gst_uri_handler_new_uri(gobj(), uri.c_str());
}


Glib::SignalProxy1< void,const Glib::ustring& > URIHandler::signal_new_uri()
{
  return Glib::SignalProxy1< void,const Glib::ustring& >(this, &URIHandler_signal_new_uri_info);
}


void Gst::URIHandler::on_new_uri(const Glib::ustring& uri)
{
  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
)  );

  if(base && base->new_uri)
    (*base->new_uri)(gobj(),uri.c_str());
}

Glib::ustring Gst::URIHandler::get_uri_vfunc() const
{
  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
)  );

  if(base && base->get_uri)
  {
    Glib::ustring result(Glib::convert_const_gchar_ptr_to_ustring((*base->get_uri)(const_cast<GstURIHandler*>(gobj()))));
    return result;
  }

  typedef Glib::ustring RType;
  return RType();
}
bool Gst::URIHandler::set_uri_vfunc(const Glib::ustring& uri) 
{
  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
)  );

  if(base && base->set_uri)
  {
    bool result((*base->set_uri)(gobj(),uri.c_str()));
    return result;
  }

  typedef bool RType;
  return RType();
}


} // namespace Gst


