/*
* $Header: https://svn.mpia.de/gulli/TwiceAsNice/branch/unstable/ln/ltcs/test/LbtoIIFSimulator/LbtoIIFInterfaceFactoryI.h 14502 2017-07-17 08:46:15Z mathar $
*
* @since 2014-08-19
* @author: kittmann
*/

#pragma once

#include <Ice/Ice.h>
#include <LbtoIIFInterface.h>
#include <LbtoIIFInterfaceFactory.h>
#include <list>
#include <LbtoIIFArbitrator.h>

namespace lbto
{
    struct DirtContainer
    {
        std::list<lbto::IIFServerPrx> m_objs;
    };

    class FactoryI : public lbto::Factory
    {
            /** DirtI container.
            */
            static lbto::DirtContainer s_dirts;

            /** Arbitrator object.
            */
            Arbitrator m_ar;

            /** Ice current object.
            */
            Ice::Current m_c;

            /** debug mode flag
            */
            bool m_debug;

            /** instrument ID map
            */
            std::map<std::string, std::string> nameMap;

        public:
            FactoryI();

            ~FactoryI();

            virtual lbto::IIFServerPrx create(const std::string& _proxyName,
                                        const std::string& _focalStation,
                                        const std::string& _instrumentID,
                                        const Ice::Current&);

            virtual void destroyProxy(const std::string& _proxyName,
                                      const Ice::Current&);

            virtual void destroy(const lbto::IIFServerPrx& _prx, const Ice::Current&);

            virtual std::string getProxy(const std::string& _proxyName,
                                    const Ice::Current&);

            virtual std::string getProxyInstrument(const std::string& _proxyName,
                                              const Ice::Current&);

            virtual std::string getProxyFocalStation(const std::string& _proxyName,
                                                const Ice::Current&);

            virtual std::string listConnections(const Ice::Current&);

            virtual void debugMode(bool b, const Ice::Current&);
        private:
            /** Recursive Ice Mutex protection.
            */
            IceUtil::RecMutex __connMutex;
    };

}
