// -*- C++ -*-
/*!
 * @file  SoundPlayer.cpp
 * @brief reproduce a wav file 
 * @date $Date$
 *
 * $Id$
 */

#include "SoundPlayer.h"

// Module specification
// <rtc-template block="module_spec">
static const char* soundplayer_spec[] =
  {
    "implementation_id", "SoundPlayer",
    "type_name",         "SoundPlayer",
    "description",       "reproduce a wav file ",
    "version",           "1.0.0",
    "vendor",            "RTC-Center",
    "category",          "communication",
    "activity_type",     "PERIODIC",
    "kind",              "DataFlowComponent",
    "max_instance",      "1",
    "language",          "C++",
    "lang_type",         "compile",
    // Configuration variables
    "conf.default.sound_fname", "sound.wav",
    // Widget
    "conf.__widget__.sound_fname", "text",
    // Constraints
    ""
  };
// </rtc-template>

/*!
 * @brief constructor
 * @param manager Maneger Object
 */
SoundPlayer::SoundPlayer(RTC::Manager* manager)
    // <rtc-template block="initializer">
  : RTC::DataFlowComponentBase(manager),
    m_PlaySoundProvPort("PlaySoundProv")

    // </rtc-template>
{
}

/*!
 * @brief destructor
 */
SoundPlayer::~SoundPlayer()
{
}



RTC::ReturnCode_t SoundPlayer::onInitialize()
{
  // Registration: InPort/OutPort/Service
  // <rtc-template block="registration">
  // Set InPort buffers
  
  // Set OutPort buffer
  
  // Set service provider to Ports
  m_PlaySoundProvPort.registerProvider("PlaySound", "PlaySound", m_PlaySound);
  
  // Set service consumers to Ports
  
  // Set CORBA Service Ports
  addPort(m_PlaySoundProvPort);
  
  // </rtc-template>

  // <rtc-template block="bind_config">
  // Bind variables and configuration variable
  bindParameter("sound_fname", m_sound_fname, "sound.wav");
  
  // </rtc-template>
  return RTC::RTC_OK;
}

/*
RTC::ReturnCode_t SoundPlayer::onFinalize()
{
  return RTC::RTC_OK;
}
*/

/*
RTC::ReturnCode_t SoundPlayer::onStartup(RTC::UniqueId ec_id)
{
  return RTC::RTC_OK;
}
*/

/*
RTC::ReturnCode_t SoundPlayer::onShutdown(RTC::UniqueId ec_id)
{
  return RTC::RTC_OK;
}
*/

RTC::ReturnCode_t SoundPlayer::onActivated(RTC::UniqueId ec_id)
{
  m_PlaySound.fname = m_sound_fname;
  return RTC::RTC_OK;
}

/*
RTC::ReturnCode_t SoundPlayer::onDeactivated(RTC::UniqueId ec_id)
{
  return RTC::RTC_OK;
}
*/

/*
RTC::ReturnCode_t SoundPlayer::onExecute(RTC::UniqueId ec_id)
{
  return RTC::RTC_OK;
}
*/

/*
RTC::ReturnCode_t SoundPlayer::onAborting(RTC::UniqueId ec_id)
{
  return RTC::RTC_OK;
}
*/

/*
RTC::ReturnCode_t SoundPlayer::onError(RTC::UniqueId ec_id)
{
  return RTC::RTC_OK;
}
*/

/*
RTC::ReturnCode_t SoundPlayer::onReset(RTC::UniqueId ec_id)
{
  return RTC::RTC_OK;
}
*/

/*
RTC::ReturnCode_t SoundPlayer::onStateUpdate(RTC::UniqueId ec_id)
{
  return RTC::RTC_OK;
}
*/

/*
RTC::ReturnCode_t SoundPlayer::onRateChanged(RTC::UniqueId ec_id)
{
  return RTC::RTC_OK;
}
*/



extern "C"
{
 
  void SoundPlayerInit(RTC::Manager* manager)
  {
    coil::Properties profile(soundplayer_spec);
    manager->registerFactory(profile,
                             RTC::Create<SoundPlayer>,
                             RTC::Delete<SoundPlayer>);
  }
  
};


