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


#include <glibmm.h>

#include <gstreamermm/object.h>
#include <gstreamermm/private/object_p.h>


/* gstreamermm - a C++ wrapper for gstreamer
 *
 * Copyright 2008-2016 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 <glibmm/threads.h>


namespace Gst
{

Object::Object(const Glib::ConstructParams& construct_params)
:
  Glib::Object(construct_params)
{
  // Get rid of the floating reference for newly constructed Gst::Objects.
  gst_object_ref_sink(gobj());
}

Object::Object(GstObject* castitem)
:
  Glib::Object(reinterpret_cast<GObject*>(castitem))
{
  if(G_LIKELY(g_object_is_floating(castitem)))
  {
    //The floating reference is convenience for C,
    //but is useless and difficult for us:
    gst_object_ref_sink(gobj());
  }
}

bool Object::is_element() const
{
  return GST_IS_ELEMENT(gobj());
}

bool Object::is_element_factory() const
{
  return GST_IS_ELEMENT_FACTORY(gobj());
}

bool Object::is_pad() const
{
  return GST_IS_PAD(gobj());
}

bool Object::is_pad_template() const
{
  return GST_IS_PAD_TEMPLATE(gobj());
}

bool Object::is_bin() const
{
  return GST_IS_BIN(gobj());
}

int Object::get_refcount() const
{
  return GST_OBJECT_REFCOUNT(gobj());
}

} // namespace Gst

namespace
{


static void Object_signal_deep_notify_callback(GstObject* self, GstObject* p0,GParamSpec* p1,void* data)
{
  using namespace Gst;
  using SlotType = sigc::slot< void,const Glib::RefPtr<Gst::Object>&,GParamSpec* >;

  auto obj = dynamic_cast<Object*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
  // Do not try to call a signal on a disassociated wrapper.
  if(obj)
  {
    try
    {
      if(const auto slot = Glib::SignalProxyNormal::data_to_slot(data))
        (*static_cast<SlotType*>(slot))(Glib::wrap(p0, true)
, p1);
    }
    catch(...)
    {
       Glib::exception_handlers_invoke();
    }
  }
}

static const Glib::SignalProxyInfo Object_signal_deep_notify_info =
{
  "deep-notify",
  (GCallback) &Object_signal_deep_notify_callback,
  (GCallback) &Object_signal_deep_notify_callback
};


} // anonymous namespace

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


namespace Glib
{

Glib::RefPtr<Gst::Object> wrap(GstObject* object, bool take_copy)
{
  return Glib::RefPtr<Gst::Object>( dynamic_cast<Gst::Object*> (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& Object_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_ = &Object_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_object_get_type());

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

  }

  return *this;
}


void Object_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);


  klass->deep_notify = &deep_notify_callback;
}


void Object_Class::deep_notify_callback(GstObject* self, GstObject* p0, GParamSpec* p1)
{
  const auto 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_())
  {
    const auto 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.
      {
        // Call the virtual member method, which derived classes might override.
        obj->on_deep_notify(Glib::wrap(p0, true)
, p1);
        return;
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
    }
  }

  const auto 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->deep_notify)
    (*base->deep_notify)(self, p0, p1);
}


Glib::ObjectBase* Object_Class::wrap_new(GObject* object)
{
  return new Object((GstObject*)object);
}


/* The implementation: */

GstObject* Object::gobj_copy()
{
  reference();
  return gobj();
}


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

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


Object::~Object() noexcept
{}


Object::CppClassType Object::object_class_; // initialize static member

GType Object::get_type()
{
  return object_class_.init().get_type();
}


GType Object::get_base_type()
{
  return gst_object_get_type();
}


guint32 Object::get_flags() const
{
  return gobj()->flags;
}

bool Object::set_name(const Glib::ustring& name)
{
  return gst_object_set_name(gobj(), name.c_str());
}

Glib::ustring Object::get_name() const
{
  return Glib::convert_return_gchar_ptr_to_ustring(gst_object_get_name(const_cast<GstObject*>(gobj())));
}

bool Object::set_parent(const Glib::RefPtr<Gst::Object>& parent)
{
  return gst_object_set_parent(gobj(), Glib::unwrap(parent));
}

Glib::RefPtr<Gst::Object> Object::get_parent()
{
  return Glib::wrap(gst_object_get_parent(gobj()));
}

Glib::RefPtr<const Gst::Object> Object::get_parent() const
{
  return const_cast<Object*>(this)->get_parent();
}

void Object::unparent()
{
  gst_object_unparent(gobj());
}

void Object::set_control_rate(Gst::ClockTime control_rate)
{
  gst_object_set_control_rate(gobj(), ((GstClockTime)(control_rate)));
}

Gst::ClockTime Object::get_control_rate() const
{
  return ((Gst::ClockTime)(gst_object_get_control_rate(const_cast<GstObject*>(gobj()))));
}

Gst::ClockTime Object::suggest_next_sync() const
{
  return ((Gst::ClockTime)(gst_object_suggest_next_sync(const_cast<GstObject*>(gobj()))));
}

bool Object::sync_values(Gst::ClockTime timestamp)
{
  return gst_object_sync_values(gobj(), ((GstClockTime)(timestamp)));
}

void Object::set_control_bindings_disabled(bool disabled)
{
  gst_object_set_control_bindings_disabled(gobj(), static_cast<int>(disabled));
}

bool Object::has_asctive_control_bindings() const
{
  return gst_object_has_active_control_bindings(const_cast<GstObject*>(gobj()));
}

bool Object::check_uniqueness(const Glib::ListHandle<const Gst::Object>& list, const Glib::ustring& name)
{
  return gst_object_check_uniqueness((list).data(), name.c_str());
}

bool Object::has_ancestor(const Glib::RefPtr<const Gst::Object>& ancestor) const
{
  return gst_object_has_ancestor(const_cast<GstObject*>(gobj()), const_cast<GstObject*>(Glib::unwrap(ancestor)));
}

bool Object::has_as_ancestor(const Glib::RefPtr<Gst::Object>& ancestor) const
{
  return gst_object_has_as_ancestor(const_cast<GstObject*>(gobj()), Glib::unwrap(ancestor));
}

bool Object::has_as_parent(const Glib::RefPtr<Gst::Object>& parent) const
{
  return gst_object_has_as_parent(const_cast<GstObject*>(gobj()), Glib::unwrap(parent));
}

Glib::ustring Object::get_path_string()
{
  return Glib::convert_return_gchar_ptr_to_ustring(gst_object_get_path_string(gobj()));
}


Glib::SignalProxy< void,const Glib::RefPtr<Gst::Object>&,GParamSpec* > Object::signal_deep_notify()
{
  return Glib::SignalProxy< void,const Glib::RefPtr<Gst::Object>&,GParamSpec* >(this, &Object_signal_deep_notify_info);
}


Glib::PropertyProxy< Glib::ustring > Object::property_name() 
{
  return Glib::PropertyProxy< Glib::ustring >(this, "name");
}

Glib::PropertyProxy_ReadOnly< Glib::ustring > Object::property_name() const
{
  return Glib::PropertyProxy_ReadOnly< Glib::ustring >(this, "name");
}

Glib::PropertyProxy< Glib::RefPtr<Gst::Object> > Object::property_parent() 
{
  return Glib::PropertyProxy< Glib::RefPtr<Gst::Object> >(this, "parent");
}

Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Gst::Object> > Object::property_parent() const
{
  return Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Gst::Object> >(this, "parent");
}


void Gst::Object::on_deep_notify(const Glib::RefPtr<Gst::Object>& prop_object, GParamSpec* prop)
{
  const auto 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->deep_notify)
    (*base->deep_notify)(gobj(),Glib::unwrap(prop_object),prop);
}


} // namespace Gst


