#pragma once

/* $Header: https://svn.mpia.de/gulli/TwiceAsNice/branch/unstable/ln/ltcs/test/LbtoIIFSimulator/LbtoIIFArbitrator.h 14502 2017-07-17 08:46:15Z mathar $
*/

#include <Ice/Ice.h>
#include <IceUtil/IceUtil.h>
#include <LbtoIIFInterfaceI.h>
#include <list>
#include <map>

namespace lbto
{
    /**
    * @class Arbitrator
    * @author Jose Borelli <borelli@mpia.de>
    * @brief The arbitrator class controls the authorized instruments and returns the appropiated pointer to the IIF.
    * @todo This class needs also a logger object.
    */
    class Arbitrator
    {
        public:
            /** list of instruments vs IIF objects.
	    */
            std::map<std::string, lbto::IIFServerPtr> m_map;

            Arbitrator();

            ~Arbitrator();

            bool DeRegister(const std::string _proxyName);

            IIFServerPtr getIIFServer(const std::string _proxyName,
                                      Ice::CommunicatorPtr _comm);

            bool ProxyExist(const std::string _proxyName);

        private:
            /** Recursive Ice Mutex protection.
	    */
            IceUtil::RecMutex __connMutex;
    };

}
