// $Header$

/*
*  https://svn.mpia.de/gulli/TwiceAsNice/branch/unstable/ln/laos-drot/src/Service/LaosDrotServiceFactory.cc 14102 2016-11-27 18:44:03Z mathar $
*/

#include <Basda/Basdard.h>
#include "SharknirDrotServiceWorker.h"
#include <Basda/ServiceState.h>

/*
* @since 2011-08-30
* @author kittmann
*/
extern "C" void instantService(const Nice::JointPtr & _config)
{
        std::string serviceName = _config->getAtNode<std::map<std::string, std::string> >(
                "LOAD")["NAME"];

        std::string deviceName = _config
                    ->Nice::Joint::getWithDefault<std::string>("DEVICE", "undefined");
        D_LOG( "Loading device: " << deviceName);

        Basda::MoccaNDevicePtr device = Basda::Basdard::device<Basda::MoccaNDevice>(deviceName);

        if (device)
        {
            Basda::ServiceWorkerPtr worker = new Sharknir::DrotServiceWorker(_config, device);

            Basda::Basdard::addWorker(serviceName, worker);
        }
        else
        {
            F_LOG("Trying to initialize an invalid or non existing device: "
                                  << deviceName);
            F_LOG("Check the configuration file for wrong parameters. "
                                  "Service will shutdown now.");
            exit(1);
        }
}


