/* $Header: https://svn.mpia.de/gulli/TwiceAsNice/branch/unstable/ln/laos-drot/test/LaosDrotServiceFactoryMock.cc 14115 2016-12-07 17:38:28Z mathar $
*/

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

#include "SharknirDrotServiceWorkerMock.h"

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::DrotServiceWorkerMock(_config, device);

        Basda::Basdard::addWorker(serviceName, worker);
    //       Nice::Application::distribute(_config);
    }
    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);
    }
}


