// Generated by gmmproc 2.39.93 -- 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/gst.h>
#include <gstreamermm/element.h>

namespace Gst
{

URIType URIHandler::get_type_vfunc()
{
  BaseClassType *const base = static_cast<BaseClassType*>(
    g_type_interface_peek_parent(
      g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type())
      )  );

  if(base && base->get_type)
  {
    return static_cast<URIType>((*base->get_type)(CppObjectType::get_type()));
  }

  return URIType();
}

GstURIType URIHandler_Class::get_type_vfunc_callback(GType type)
{
  gpointer self = g_object_new(type, NULL);
  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
      Glib::ObjectBase::_get_current_wrapper((GObject*)self));

  if(obj_base && obj_base->is_derived_())
  {
    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
    if(obj)
    {
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      try
      {
      #endif //GLIBMM_EXCEPTIONS_ENABLED
        return static_cast<GstURIType>(obj->get_type_vfunc());
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
      #endif //GLIBMM_EXCEPTIONS_ENABLED
    }
  }

  BaseClassType *const base = static_cast<BaseClassType*>(
    g_type_interface_peek_parent(
      g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type())
      )  );

  if(base && base->get_type)
  {
    return (*base->get_type)(type);
  }

  return GstURIType();
}

const gchar * const * URIHandler::get_protocols_vfunc() const
{
  BaseClassType *const base = static_cast<BaseClassType*>(
    g_type_interface_peek_parent(
      g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type())
      )  );

  if(base && base->get_protocols)
  {
    return (*base->get_protocols)(CppObjectType::get_type());
  }
  static const gchar* protocols[] = {NULL};
  return protocols;
}

const gchar * const * URIHandler_Class::get_protocols_vfunc_callback(GType type)
{
  gpointer self = g_object_new(type, NULL);
  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
      Glib::ObjectBase::_get_current_wrapper((GObject*)self));

  if(obj_base && obj_base->is_derived_())
  {
    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
    if(obj)
    {
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      try
      {
      #endif //GLIBMM_EXCEPTIONS_ENABLED
        return obj->get_protocols_vfunc();
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
      #endif //GLIBMM_EXCEPTIONS_ENABLED
    }
  }

  BaseClassType *const base = static_cast<BaseClassType*>(
    g_type_interface_peek_parent(
      g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type())
      )  );

  if(base && base->get_protocols)
  {
    return (*base->get_protocols)(type);
  }
  static const gchar *protocols[] = { NULL };
  return protocols;
}
}

namespace
{
} // 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->get_type = &get_type_vfunc_callback;
  klass->get_protocols = &get_protocols_vfunc_callback;
  
}

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 g_strdup((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)
  {
    gchar* retval = (*base->get_uri)(self);
    return retval;
  }

  typedef gchar* RType;
  return RType();
}
gboolean URIHandler_Class::set_uri_vfunc_callback(GstURIHandler* self, const gchar* uri, GError** error)
{
  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)
, error));
      #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 retval = (*base->set_uri)(self, uri, error);
    return retval;
  }

  typedef gboolean RType;
  return RType();
}


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::ustring URIHandler::filename_to_uri(const Glib::ustring& filename)
{
  GError* gerror = 0;
  Glib::ustring retvalue = Glib::convert_return_gchar_ptr_to_ustring(gst_filename_to_uri(filename.c_str(), &(gerror)));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}


Glib::RefPtr<Gst::Element> URIHandler::make_element_from_uri(const URIType type, const Glib::ustring& uri, const Glib::ustring& name)
{
  GError* gerror = 0;
  Glib::RefPtr<Gst::Element> retvalue = Glib::wrap(gst_element_make_from_uri((GstURIType)(type), uri.c_str(), name.c_str(), &(gerror)));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}


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

std::vector<Glib::ustring> URIHandler::get_protocols() const
{
  return Glib::ArrayHandler<Glib::ustring>::array_to_vector(gst_uri_handler_get_protocols(const_cast<GstURIHandler*>(gobj())), Glib::OWNERSHIP_NONE);
}

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

bool URIHandler::set_uri(const Glib::ustring& uri)
{
  GError* gerror = 0;
  bool retvalue = gst_uri_handler_set_uri(gobj(), uri.c_str(), &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}


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 retval(Glib::convert_const_gchar_ptr_to_ustring((*base->get_uri)(const_cast<GstURIHandler*>(gobj()))));
    return retval;
  }

  typedef Glib::ustring RType;
  return RType();
}
bool Gst::URIHandler::set_uri_vfunc(const Glib::ustring& uri, GError** error) 
{
  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 retval((*base->set_uri)(gobj(),uri.c_str(),error));
    return retval;
  }

  typedef bool RType;
  return RType();
}


} // namespace Gst


