// **********************************************************************
//
// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
//
// Ice version 3.6.0
//
// <auto-generated>
//
// Generated from file `IceLocatorDiscovery.ice'
//
// Warning: do not edit this file.
//
// </auto-generated>
//

#include <IceLocatorDiscovery/IceLocatorDiscovery.h>
#include <IceUtil/PushDisableWarnings.h>
#include <Ice/LocalException.h>
#include <Ice/ObjectFactory.h>
#include <Ice/Outgoing.h>
#include <Ice/OutgoingAsync.h>
#include <Ice/BasicStream.h>
#include <IceUtil/Iterator.h>
#include <IceUtil/PopDisableWarnings.h>

#ifndef ICE_IGNORE_VERSION
#   if ICE_INT_VERSION / 100 != 306
#       error Ice version mismatch!
#   endif
#   if ICE_INT_VERSION % 100 > 50
#       error Beta header file detected
#   endif
#   if ICE_INT_VERSION % 100 < 0
#       error Ice patch level mismatch!
#   endif
#endif

namespace
{

const ::std::string __IceLocatorDiscovery__LookupReply__foundLocator_name = "foundLocator";

const ::std::string __IceLocatorDiscovery__Lookup__findLocator_name = "findLocator";

}
::IceProxy::Ice::Object* ::IceProxy::IceLocatorDiscovery::upCast(::IceProxy::IceLocatorDiscovery::LookupReply* p) { return p; }

void
::IceProxy::IceLocatorDiscovery::__read(::IceInternal::BasicStream* __is, ::IceInternal::ProxyHandle< ::IceProxy::IceLocatorDiscovery::LookupReply>& v)
{
    ::Ice::ObjectPrx proxy;
    __is->read(proxy);
    if(!proxy)
    {
        v = 0;
    }
    else
    {
        v = new ::IceProxy::IceLocatorDiscovery::LookupReply;
        v->__copyFrom(proxy);
    }
}

void
IceProxy::IceLocatorDiscovery::LookupReply::foundLocator(const ::Ice::LocatorPrx& __p_prx, const ::Ice::Context* __ctx)
{
    ::IceInternal::Outgoing __og(this, __IceLocatorDiscovery__LookupReply__foundLocator_name, ::Ice::Normal, __ctx);
    try
    {
        ::IceInternal::BasicStream* __os = __og.startWriteParams(::Ice::DefaultFormat);
        __os->write(__p_prx);
        __og.endWriteParams();
    }
    catch(const ::Ice::LocalException& __ex)
    {
        __og.abort(__ex);
    }
    __invoke(__og);
}

::Ice::AsyncResultPtr
IceProxy::IceLocatorDiscovery::LookupReply::begin_foundLocator(const ::Ice::LocatorPrx& __p_prx, const ::Ice::Context* __ctx, const ::IceInternal::CallbackBasePtr& __del, const ::Ice::LocalObjectPtr& __cookie)
{
    ::IceInternal::OutgoingAsyncPtr __result = new ::IceInternal::OutgoingAsync(this, __IceLocatorDiscovery__LookupReply__foundLocator_name, __del, __cookie);
    try
    {
        __result->prepare(__IceLocatorDiscovery__LookupReply__foundLocator_name, ::Ice::Normal, __ctx);
        ::IceInternal::BasicStream* __os = __result->startWriteParams(::Ice::DefaultFormat);
        __os->write(__p_prx);
        __result->endWriteParams();
        __result->invoke();
    }
    catch(const ::Ice::Exception& __ex)
    {
        __result->abort(__ex);
    }
    return __result;
}

void
IceProxy::IceLocatorDiscovery::LookupReply::end_foundLocator(const ::Ice::AsyncResultPtr& __result)
{
    __end(__result, __IceLocatorDiscovery__LookupReply__foundLocator_name);
}

const ::std::string&
IceProxy::IceLocatorDiscovery::LookupReply::ice_staticId()
{
    return ::IceLocatorDiscovery::LookupReply::ice_staticId();
}

::IceProxy::Ice::Object*
IceProxy::IceLocatorDiscovery::LookupReply::__newInstance() const
{
    return new LookupReply;
}
::IceProxy::Ice::Object* ::IceProxy::IceLocatorDiscovery::upCast(::IceProxy::IceLocatorDiscovery::Lookup* p) { return p; }

void
::IceProxy::IceLocatorDiscovery::__read(::IceInternal::BasicStream* __is, ::IceInternal::ProxyHandle< ::IceProxy::IceLocatorDiscovery::Lookup>& v)
{
    ::Ice::ObjectPrx proxy;
    __is->read(proxy);
    if(!proxy)
    {
        v = 0;
    }
    else
    {
        v = new ::IceProxy::IceLocatorDiscovery::Lookup;
        v->__copyFrom(proxy);
    }
}

void
IceProxy::IceLocatorDiscovery::Lookup::findLocator(const ::std::string& __p_instanceName, const ::IceLocatorDiscovery::LookupReplyPrx& __p_reply, const ::Ice::Context* __ctx)
{
    ::IceInternal::Outgoing __og(this, __IceLocatorDiscovery__Lookup__findLocator_name, ::Ice::Idempotent, __ctx);
    try
    {
        ::IceInternal::BasicStream* __os = __og.startWriteParams(::Ice::DefaultFormat);
        __os->write(__p_instanceName);
        __os->write(__p_reply);
        __og.endWriteParams();
    }
    catch(const ::Ice::LocalException& __ex)
    {
        __og.abort(__ex);
    }
    __invoke(__og);
}

::Ice::AsyncResultPtr
IceProxy::IceLocatorDiscovery::Lookup::begin_findLocator(const ::std::string& __p_instanceName, const ::IceLocatorDiscovery::LookupReplyPrx& __p_reply, const ::Ice::Context* __ctx, const ::IceInternal::CallbackBasePtr& __del, const ::Ice::LocalObjectPtr& __cookie)
{
    ::IceInternal::OutgoingAsyncPtr __result = new ::IceInternal::OutgoingAsync(this, __IceLocatorDiscovery__Lookup__findLocator_name, __del, __cookie);
    try
    {
        __result->prepare(__IceLocatorDiscovery__Lookup__findLocator_name, ::Ice::Idempotent, __ctx);
        ::IceInternal::BasicStream* __os = __result->startWriteParams(::Ice::DefaultFormat);
        __os->write(__p_instanceName);
        __os->write(__p_reply);
        __result->endWriteParams();
        __result->invoke();
    }
    catch(const ::Ice::Exception& __ex)
    {
        __result->abort(__ex);
    }
    return __result;
}

void
IceProxy::IceLocatorDiscovery::Lookup::end_findLocator(const ::Ice::AsyncResultPtr& __result)
{
    __end(__result, __IceLocatorDiscovery__Lookup__findLocator_name);
}

const ::std::string&
IceProxy::IceLocatorDiscovery::Lookup::ice_staticId()
{
    return ::IceLocatorDiscovery::Lookup::ice_staticId();
}

::IceProxy::Ice::Object*
IceProxy::IceLocatorDiscovery::Lookup::__newInstance() const
{
    return new Lookup;
}

::Ice::Object* IceLocatorDiscovery::upCast(::IceLocatorDiscovery::LookupReply* p) { return p; }

namespace
{
const ::std::string __IceLocatorDiscovery__LookupReply_ids[2] =
{
    "::Ice::Object",
    "::IceLocatorDiscovery::LookupReply"
};

}

bool
IceLocatorDiscovery::LookupReply::ice_isA(const ::std::string& _s, const ::Ice::Current&) const
{
    return ::std::binary_search(__IceLocatorDiscovery__LookupReply_ids, __IceLocatorDiscovery__LookupReply_ids + 2, _s);
}

::std::vector< ::std::string>
IceLocatorDiscovery::LookupReply::ice_ids(const ::Ice::Current&) const
{
    return ::std::vector< ::std::string>(&__IceLocatorDiscovery__LookupReply_ids[0], &__IceLocatorDiscovery__LookupReply_ids[2]);
}

const ::std::string&
IceLocatorDiscovery::LookupReply::ice_id(const ::Ice::Current&) const
{
    return __IceLocatorDiscovery__LookupReply_ids[1];
}

const ::std::string&
IceLocatorDiscovery::LookupReply::ice_staticId()
{
#ifdef ICE_HAS_THREAD_SAFE_LOCAL_STATIC
    static const ::std::string typeId = "::IceLocatorDiscovery::LookupReply";
    return typeId;
#else
    return __IceLocatorDiscovery__LookupReply_ids[1];
#endif
}

::Ice::DispatchStatus
IceLocatorDiscovery::LookupReply::___foundLocator(::IceInternal::Incoming& __inS, const ::Ice::Current& __current)
{
    __checkMode(::Ice::Normal, __current.mode);
    ::IceInternal::BasicStream* __is = __inS.startReadParams();
    ::Ice::LocatorPrx __p_prx;
    __is->read(__p_prx);
    __inS.endReadParams();
    foundLocator(__p_prx, __current);
    __inS.__writeEmptyParams();
    return ::Ice::DispatchOK;
}

namespace
{
const ::std::string __IceLocatorDiscovery__LookupReply_all[] =
{
    "foundLocator",
    "ice_id",
    "ice_ids",
    "ice_isA",
    "ice_ping"
};

}

::Ice::DispatchStatus
IceLocatorDiscovery::LookupReply::__dispatch(::IceInternal::Incoming& in, const ::Ice::Current& current)
{
    ::std::pair< const ::std::string*, const ::std::string*> r = ::std::equal_range(__IceLocatorDiscovery__LookupReply_all, __IceLocatorDiscovery__LookupReply_all + 5, current.operation);
    if(r.first == r.second)
    {
        throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
    }

    switch(r.first - __IceLocatorDiscovery__LookupReply_all)
    {
        case 0:
        {
            return ___foundLocator(in, current);
        }
        case 1:
        {
            return ___ice_id(in, current);
        }
        case 2:
        {
            return ___ice_ids(in, current);
        }
        case 3:
        {
            return ___ice_isA(in, current);
        }
        case 4:
        {
            return ___ice_ping(in, current);
        }
    }

    assert(false);
    throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
}

void
IceLocatorDiscovery::LookupReply::__writeImpl(::IceInternal::BasicStream* __os) const
{
    __os->startWriteSlice(ice_staticId(), -1, true);
    __os->endWriteSlice();
}

void
IceLocatorDiscovery::LookupReply::__readImpl(::IceInternal::BasicStream* __is)
{
    __is->startReadSlice();
    __is->endReadSlice();
}

void 
IceLocatorDiscovery::__patch(LookupReplyPtr& handle, const ::Ice::ObjectPtr& v)
{
    handle = ::IceLocatorDiscovery::LookupReplyPtr::dynamicCast(v);
    if(v && !handle)
    {
        IceInternal::Ex::throwUOE(::IceLocatorDiscovery::LookupReply::ice_staticId(), v);
    }
}

::Ice::Object* IceLocatorDiscovery::upCast(::IceLocatorDiscovery::Lookup* p) { return p; }

namespace
{
const ::std::string __IceLocatorDiscovery__Lookup_ids[2] =
{
    "::Ice::Object",
    "::IceLocatorDiscovery::Lookup"
};

}

bool
IceLocatorDiscovery::Lookup::ice_isA(const ::std::string& _s, const ::Ice::Current&) const
{
    return ::std::binary_search(__IceLocatorDiscovery__Lookup_ids, __IceLocatorDiscovery__Lookup_ids + 2, _s);
}

::std::vector< ::std::string>
IceLocatorDiscovery::Lookup::ice_ids(const ::Ice::Current&) const
{
    return ::std::vector< ::std::string>(&__IceLocatorDiscovery__Lookup_ids[0], &__IceLocatorDiscovery__Lookup_ids[2]);
}

const ::std::string&
IceLocatorDiscovery::Lookup::ice_id(const ::Ice::Current&) const
{
    return __IceLocatorDiscovery__Lookup_ids[1];
}

const ::std::string&
IceLocatorDiscovery::Lookup::ice_staticId()
{
#ifdef ICE_HAS_THREAD_SAFE_LOCAL_STATIC
    static const ::std::string typeId = "::IceLocatorDiscovery::Lookup";
    return typeId;
#else
    return __IceLocatorDiscovery__Lookup_ids[1];
#endif
}

::Ice::DispatchStatus
IceLocatorDiscovery::Lookup::___findLocator(::IceInternal::Incoming& __inS, const ::Ice::Current& __current)
{
    __checkMode(::Ice::Idempotent, __current.mode);
    ::IceInternal::BasicStream* __is = __inS.startReadParams();
    ::std::string __p_instanceName;
    ::IceLocatorDiscovery::LookupReplyPrx __p_reply;
    __is->read(__p_instanceName);
    __is->read(__p_reply);
    __inS.endReadParams();
    findLocator(__p_instanceName, __p_reply, __current);
    __inS.__writeEmptyParams();
    return ::Ice::DispatchOK;
}

namespace
{
const ::std::string __IceLocatorDiscovery__Lookup_all[] =
{
    "findLocator",
    "ice_id",
    "ice_ids",
    "ice_isA",
    "ice_ping"
};

}

::Ice::DispatchStatus
IceLocatorDiscovery::Lookup::__dispatch(::IceInternal::Incoming& in, const ::Ice::Current& current)
{
    ::std::pair< const ::std::string*, const ::std::string*> r = ::std::equal_range(__IceLocatorDiscovery__Lookup_all, __IceLocatorDiscovery__Lookup_all + 5, current.operation);
    if(r.first == r.second)
    {
        throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
    }

    switch(r.first - __IceLocatorDiscovery__Lookup_all)
    {
        case 0:
        {
            return ___findLocator(in, current);
        }
        case 1:
        {
            return ___ice_id(in, current);
        }
        case 2:
        {
            return ___ice_ids(in, current);
        }
        case 3:
        {
            return ___ice_isA(in, current);
        }
        case 4:
        {
            return ___ice_ping(in, current);
        }
    }

    assert(false);
    throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
}

void
IceLocatorDiscovery::Lookup::__writeImpl(::IceInternal::BasicStream* __os) const
{
    __os->startWriteSlice(ice_staticId(), -1, true);
    __os->endWriteSlice();
}

void
IceLocatorDiscovery::Lookup::__readImpl(::IceInternal::BasicStream* __is)
{
    __is->startReadSlice();
    __is->endReadSlice();
}

void 
IceLocatorDiscovery::__patch(LookupPtr& handle, const ::Ice::ObjectPtr& v)
{
    handle = ::IceLocatorDiscovery::LookupPtr::dynamicCast(v);
    if(v && !handle)
    {
        IceInternal::Ex::throwUOE(::IceLocatorDiscovery::Lookup::ice_staticId(), v);
    }
}
