// Generated by gtkmmproc -- DO NOT MODIFY!


#include <gstreamermm/task.h>
#include <gstreamermm/private/task_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>


static void Task_Task_gstreamermm_callback(void* data)
{
  Gst::Task::SlotTask* the_slot = static_cast<Gst::Task::SlotTask*>(data);

  #ifdef GLIBMM_EXCEPTIONS_ENABLED
  try
  {
  #endif //GLIBMM_EXCEPTIONS_ENABLED
    (*the_slot)();
  #ifdef GLIBMM_EXCEPTIONS_ENABLED
  }
  catch(...)
  {
    Glib::exception_handlers_invoke();
  }
  #endif //GLIBMM_EXCEPTIONS_ENABLED
}

namespace Gst
{

Task::Task(const SlotTask& task_slot)
: // Mark this class as non-derived to allow C++ vfuncs to be skipped.
  Glib::ObjectBase(0),
  Object(Glib::ConstructParams(task_class_.init()))
{
  //Create a copy of the slot.  A pointer to this copy will be passed through
  //the call back's data parameter.  It will be destroyed in the Task's
  //destructor
  slot = new SlotTask(task_slot);
  _slot_set(true);

  // These lines are taken verbatim from gst_task_create() after calling
  // g_object_new().
  gobj()->func = &Task_Task_gstreamermm_callback;
  gobj()->data = &slot;
}

bool Task::_slot_set(bool mark_set) const
{
  static bool slot_set = false;

  if (mark_set)
    slot_set = true;

  return slot_set;
}

Task::~Task()
{
  // Delete task's slot upon destruction
  if (_slot_set())
    delete slot;
}

} //namespace Gst

namespace
{
} // anonymous namespace

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


namespace Glib
{

Glib::RefPtr<Gst::Task> wrap(GstTask* object, bool take_copy)
{
  return Glib::RefPtr<Gst::Task>( dynamic_cast<Gst::Task*> (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& Task_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_ = &Task_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_task_get_type());

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

  }

  return *this;
}

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

#ifdef GLIBMM_VFUNCS_ENABLED
#endif //GLIBMM_VFUNCS_ENABLED

#ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
#endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
}

#ifdef GLIBMM_VFUNCS_ENABLED
#endif //GLIBMM_VFUNCS_ENABLED

#ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
#endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED


Glib::ObjectBase* Task_Class::wrap_new(GObject* object)
{
  return new Task((GstTask*)object);
}


/* The implementation: */

GstTask* Task::gobj_copy()
{
  reference();
  return gobj();
}

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

}

Task::Task(GstTask* castitem)
:
  Object((GstObject*)(castitem))
{}


Task::CppClassType Task::task_class_; // initialize static member

GType Task::get_type()
{
  return task_class_.init().get_type();
}

GType Task::get_base_type()
{
  return gst_task_get_type();
}


Glib::RefPtr<Task> Task::create(const SlotTask& task_slot)
{
  return Glib::RefPtr<Task>( new Task(task_slot) );
}
void Task::cleanup_all()
{
gst_task_cleanup_all();
}


TaskState Task::get_state() const
{
  return ((TaskState)(gst_task_get_state(const_cast<GstTask*>(gobj()))));
}

bool Task::join()
{
  return gst_task_join(gobj());
}

bool Task::pause()
{
  return gst_task_pause(gobj());
}

void Task::set_lock(Glib::StaticRecMutex& mutex)
{
gst_task_set_lock(gobj(), (mutex).gobj()); 
}

bool Task::start()
{
  return gst_task_start(gobj());
}

bool Task::stop()
{
  return gst_task_stop(gobj());
}


#ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
#endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED

#ifdef GLIBMM_VFUNCS_ENABLED
#endif //GLIBMM_VFUNCS_ENABLED


} // namespace Gst


