// **********************************************************************
//
// 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 `PropertiesAdmin.ice'
//
// Warning: do not edit this file.
//
// </auto-generated>
//

#ifndef ICE_API_EXPORTS
#   define ICE_API_EXPORTS
#endif
#include <Ice/PropertiesAdmin.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 __Ice__PropertiesAdmin__getProperty_name = "getProperty";

const ::std::string __Ice__PropertiesAdmin__getPropertiesForPrefix_name = "getPropertiesForPrefix";

const ::std::string __Ice__PropertiesAdmin__setProperties_name = "setProperties";

}

IceAsync::Ice::AMD_PropertiesAdmin_setProperties::AMD_PropertiesAdmin_setProperties(::IceInternal::Incoming& in) :
    ::IceInternal::IncomingAsync(in)
{
}

void
IceAsync::Ice::AMD_PropertiesAdmin_setProperties::ice_response()
{
    if(__validateResponse(true))
    {
        __writeEmptyParams();
        __response();
    }
}
#ifdef __SUNPRO_CC
class ICE_API IceProxy::Ice::PropertiesAdmin;
#endif
ICE_API ::IceProxy::Ice::Object* ::IceProxy::Ice::upCast(::IceProxy::Ice::PropertiesAdmin* p) { return p; }

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

::std::string
IceProxy::Ice::PropertiesAdmin::getProperty(const ::std::string& __p_key, const ::Ice::Context* __ctx)
{
    __checkTwowayOnly(__Ice__PropertiesAdmin__getProperty_name);
    ::IceInternal::Outgoing __og(this, __Ice__PropertiesAdmin__getProperty_name, ::Ice::Normal, __ctx);
    try
    {
        ::IceInternal::BasicStream* __os = __og.startWriteParams(::Ice::DefaultFormat);
        __os->write(__p_key);
        __og.endWriteParams();
    }
    catch(const ::Ice::LocalException& __ex)
    {
        __og.abort(__ex);
    }
    if(!__og.invoke())
    {
        try
        {
            __og.throwUserException();
        }
        catch(const ::Ice::UserException& __ex)
        {
            ::Ice::UnknownUserException __uue(__FILE__, __LINE__, __ex.ice_name());
            throw __uue;
        }
    }
    ::std::string __ret;
    ::IceInternal::BasicStream* __is = __og.startReadParams();
    __is->read(__ret);
    __og.endReadParams();
    return __ret;
}

::Ice::AsyncResultPtr
IceProxy::Ice::PropertiesAdmin::begin_getProperty(const ::std::string& __p_key, const ::Ice::Context* __ctx, const ::IceInternal::CallbackBasePtr& __del, const ::Ice::LocalObjectPtr& __cookie)
{
    __checkAsyncTwowayOnly(__Ice__PropertiesAdmin__getProperty_name);
    ::IceInternal::OutgoingAsyncPtr __result = new ::IceInternal::OutgoingAsync(this, __Ice__PropertiesAdmin__getProperty_name, __del, __cookie);
    try
    {
        __result->prepare(__Ice__PropertiesAdmin__getProperty_name, ::Ice::Normal, __ctx);
        ::IceInternal::BasicStream* __os = __result->startWriteParams(::Ice::DefaultFormat);
        __os->write(__p_key);
        __result->endWriteParams();
        __result->invoke();
    }
    catch(const ::Ice::Exception& __ex)
    {
        __result->abort(__ex);
    }
    return __result;
}

#ifdef ICE_CPP11

::Ice::AsyncResultPtr
IceProxy::Ice::PropertiesAdmin::__begin_getProperty(const ::std::string& __p_key, const ::Ice::Context* __ctx, const ::IceInternal::Function<void (const ::std::string&)>& __response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& __exception, const ::IceInternal::Function<void (bool)>& __sent)
{
    class Cpp11CB : public ::IceInternal::Cpp11FnCallbackNC
    {
    public:

        Cpp11CB(const ::std::function<void (const ::std::string&)>& responseFunc, const ::std::function<void (const ::Ice::Exception&)>& exceptionFunc, const ::std::function<void (bool)>& sentFunc) :
            ::IceInternal::Cpp11FnCallbackNC(exceptionFunc, sentFunc),
            _response(responseFunc)
        {
            CallbackBase::checkCallback(true, responseFunc || exceptionFunc != nullptr);
        }

        virtual void completed(const ::Ice::AsyncResultPtr& __result) const
        {
            ::Ice::PropertiesAdminPrx __proxy = ::Ice::PropertiesAdminPrx::uncheckedCast(__result->getProxy());
            ::std::string __ret;
            try
            {
                __ret = __proxy->end_getProperty(__result);
            }
            catch(const ::Ice::Exception& ex)
            {
                Cpp11FnCallbackNC::exception(__result, ex);
                return;
            }
            if(_response != nullptr)
            {
                _response(__ret);
            }
        }
    
    private:
        
        ::std::function<void (const ::std::string&)> _response;
    };
    return begin_getProperty(__p_key, __ctx, new Cpp11CB(__response, __exception, __sent));
}
#endif

::std::string
IceProxy::Ice::PropertiesAdmin::end_getProperty(const ::Ice::AsyncResultPtr& __result)
{
    ::Ice::AsyncResult::__check(__result, this, __Ice__PropertiesAdmin__getProperty_name);
    ::std::string __ret;
    if(!__result->__wait())
    {
        try
        {
            __result->__throwUserException();
        }
        catch(const ::Ice::UserException& __ex)
        {
            throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());
        }
    }
    ::IceInternal::BasicStream* __is = __result->__startReadParams();
    __is->read(__ret);
    __result->__endReadParams();
    return __ret;
}

::Ice::PropertyDict
IceProxy::Ice::PropertiesAdmin::getPropertiesForPrefix(const ::std::string& __p_prefix, const ::Ice::Context* __ctx)
{
    __checkTwowayOnly(__Ice__PropertiesAdmin__getPropertiesForPrefix_name);
    ::IceInternal::Outgoing __og(this, __Ice__PropertiesAdmin__getPropertiesForPrefix_name, ::Ice::Normal, __ctx);
    try
    {
        ::IceInternal::BasicStream* __os = __og.startWriteParams(::Ice::DefaultFormat);
        __os->write(__p_prefix);
        __og.endWriteParams();
    }
    catch(const ::Ice::LocalException& __ex)
    {
        __og.abort(__ex);
    }
    if(!__og.invoke())
    {
        try
        {
            __og.throwUserException();
        }
        catch(const ::Ice::UserException& __ex)
        {
            ::Ice::UnknownUserException __uue(__FILE__, __LINE__, __ex.ice_name());
            throw __uue;
        }
    }
    ::Ice::PropertyDict __ret;
    ::IceInternal::BasicStream* __is = __og.startReadParams();
    __is->read(__ret);
    __og.endReadParams();
    return __ret;
}

::Ice::AsyncResultPtr
IceProxy::Ice::PropertiesAdmin::begin_getPropertiesForPrefix(const ::std::string& __p_prefix, const ::Ice::Context* __ctx, const ::IceInternal::CallbackBasePtr& __del, const ::Ice::LocalObjectPtr& __cookie)
{
    __checkAsyncTwowayOnly(__Ice__PropertiesAdmin__getPropertiesForPrefix_name);
    ::IceInternal::OutgoingAsyncPtr __result = new ::IceInternal::OutgoingAsync(this, __Ice__PropertiesAdmin__getPropertiesForPrefix_name, __del, __cookie);
    try
    {
        __result->prepare(__Ice__PropertiesAdmin__getPropertiesForPrefix_name, ::Ice::Normal, __ctx);
        ::IceInternal::BasicStream* __os = __result->startWriteParams(::Ice::DefaultFormat);
        __os->write(__p_prefix);
        __result->endWriteParams();
        __result->invoke();
    }
    catch(const ::Ice::Exception& __ex)
    {
        __result->abort(__ex);
    }
    return __result;
}

#ifdef ICE_CPP11

::Ice::AsyncResultPtr
IceProxy::Ice::PropertiesAdmin::__begin_getPropertiesForPrefix(const ::std::string& __p_prefix, const ::Ice::Context* __ctx, const ::IceInternal::Function<void (const ::Ice::PropertyDict&)>& __response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& __exception, const ::IceInternal::Function<void (bool)>& __sent)
{
    class Cpp11CB : public ::IceInternal::Cpp11FnCallbackNC
    {
    public:

        Cpp11CB(const ::std::function<void (const ::Ice::PropertyDict&)>& responseFunc, const ::std::function<void (const ::Ice::Exception&)>& exceptionFunc, const ::std::function<void (bool)>& sentFunc) :
            ::IceInternal::Cpp11FnCallbackNC(exceptionFunc, sentFunc),
            _response(responseFunc)
        {
            CallbackBase::checkCallback(true, responseFunc || exceptionFunc != nullptr);
        }

        virtual void completed(const ::Ice::AsyncResultPtr& __result) const
        {
            ::Ice::PropertiesAdminPrx __proxy = ::Ice::PropertiesAdminPrx::uncheckedCast(__result->getProxy());
            ::Ice::PropertyDict __ret;
            try
            {
                __ret = __proxy->end_getPropertiesForPrefix(__result);
            }
            catch(const ::Ice::Exception& ex)
            {
                Cpp11FnCallbackNC::exception(__result, ex);
                return;
            }
            if(_response != nullptr)
            {
                _response(__ret);
            }
        }
    
    private:
        
        ::std::function<void (const ::Ice::PropertyDict&)> _response;
    };
    return begin_getPropertiesForPrefix(__p_prefix, __ctx, new Cpp11CB(__response, __exception, __sent));
}
#endif

::Ice::PropertyDict
IceProxy::Ice::PropertiesAdmin::end_getPropertiesForPrefix(const ::Ice::AsyncResultPtr& __result)
{
    ::Ice::AsyncResult::__check(__result, this, __Ice__PropertiesAdmin__getPropertiesForPrefix_name);
    ::Ice::PropertyDict __ret;
    if(!__result->__wait())
    {
        try
        {
            __result->__throwUserException();
        }
        catch(const ::Ice::UserException& __ex)
        {
            throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());
        }
    }
    ::IceInternal::BasicStream* __is = __result->__startReadParams();
    __is->read(__ret);
    __result->__endReadParams();
    return __ret;
}

void
IceProxy::Ice::PropertiesAdmin::setProperties(const ::Ice::PropertyDict& __p_newProperties, const ::Ice::Context* __ctx)
{
    ::IceInternal::Outgoing __og(this, __Ice__PropertiesAdmin__setProperties_name, ::Ice::Normal, __ctx);
    try
    {
        ::IceInternal::BasicStream* __os = __og.startWriteParams(::Ice::DefaultFormat);
        __os->write(__p_newProperties);
        __og.endWriteParams();
    }
    catch(const ::Ice::LocalException& __ex)
    {
        __og.abort(__ex);
    }
    __invoke(__og);
}

::Ice::AsyncResultPtr
IceProxy::Ice::PropertiesAdmin::begin_setProperties(const ::Ice::PropertyDict& __p_newProperties, const ::Ice::Context* __ctx, const ::IceInternal::CallbackBasePtr& __del, const ::Ice::LocalObjectPtr& __cookie)
{
    ::IceInternal::OutgoingAsyncPtr __result = new ::IceInternal::OutgoingAsync(this, __Ice__PropertiesAdmin__setProperties_name, __del, __cookie);
    try
    {
        __result->prepare(__Ice__PropertiesAdmin__setProperties_name, ::Ice::Normal, __ctx);
        ::IceInternal::BasicStream* __os = __result->startWriteParams(::Ice::DefaultFormat);
        __os->write(__p_newProperties);
        __result->endWriteParams();
        __result->invoke();
    }
    catch(const ::Ice::Exception& __ex)
    {
        __result->abort(__ex);
    }
    return __result;
}

void
IceProxy::Ice::PropertiesAdmin::end_setProperties(const ::Ice::AsyncResultPtr& __result)
{
    __end(__result, __Ice__PropertiesAdmin__setProperties_name);
}

const ::std::string&
IceProxy::Ice::PropertiesAdmin::ice_staticId()
{
    return ::Ice::PropertiesAdmin::ice_staticId();
}

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

ICE_API ::Ice::Object* Ice::upCast(::Ice::PropertiesAdmin* p) { return p; }

namespace
{
const ::std::string __Ice__PropertiesAdmin_ids[2] =
{
    "::Ice::Object",
    "::Ice::PropertiesAdmin"
};

}

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

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

const ::std::string&
Ice::PropertiesAdmin::ice_id(const ::Ice::Current&) const
{
    return __Ice__PropertiesAdmin_ids[1];
}

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

::Ice::DispatchStatus
Ice::PropertiesAdmin::___getProperty(::IceInternal::Incoming& __inS, const ::Ice::Current& __current)
{
    __checkMode(::Ice::Normal, __current.mode);
    ::IceInternal::BasicStream* __is = __inS.startReadParams();
    ::std::string __p_key;
    __is->read(__p_key);
    __inS.endReadParams();
    ::std::string __ret = getProperty(__p_key, __current);
    ::IceInternal::BasicStream* __os = __inS.__startWriteParams(::Ice::DefaultFormat);
    __os->write(__ret);
    __inS.__endWriteParams(true);
    return ::Ice::DispatchOK;
}

::Ice::DispatchStatus
Ice::PropertiesAdmin::___getPropertiesForPrefix(::IceInternal::Incoming& __inS, const ::Ice::Current& __current)
{
    __checkMode(::Ice::Normal, __current.mode);
    ::IceInternal::BasicStream* __is = __inS.startReadParams();
    ::std::string __p_prefix;
    __is->read(__p_prefix);
    __inS.endReadParams();
    ::Ice::PropertyDict __ret = getPropertiesForPrefix(__p_prefix, __current);
    ::IceInternal::BasicStream* __os = __inS.__startWriteParams(::Ice::DefaultFormat);
    __os->write(__ret);
    __inS.__endWriteParams(true);
    return ::Ice::DispatchOK;
}

::Ice::DispatchStatus
Ice::PropertiesAdmin::___setProperties(::IceInternal::Incoming& __inS, const ::Ice::Current& __current)
{
    __checkMode(::Ice::Normal, __current.mode);
    ::IceInternal::BasicStream* __is = __inS.startReadParams();
    ::Ice::PropertyDict __p_newProperties;
    __is->read(__p_newProperties);
    __inS.endReadParams();
    ::Ice::AMD_PropertiesAdmin_setPropertiesPtr __cb = new IceAsync::Ice::AMD_PropertiesAdmin_setProperties(__inS);
    try
    {
        setProperties_async(__cb, __p_newProperties, __current);
    }
    catch(const ::std::exception& __ex)
    {
        __cb->ice_exception(__ex);
    }
    catch(...)
    {
        __cb->ice_exception();
    }
    return ::Ice::DispatchAsync;
}

namespace
{
const ::std::string __Ice__PropertiesAdmin_all[] =
{
    "getPropertiesForPrefix",
    "getProperty",
    "ice_id",
    "ice_ids",
    "ice_isA",
    "ice_ping",
    "setProperties"
};

}

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

    switch(r.first - __Ice__PropertiesAdmin_all)
    {
        case 0:
        {
            return ___getPropertiesForPrefix(in, current);
        }
        case 1:
        {
            return ___getProperty(in, current);
        }
        case 2:
        {
            return ___ice_id(in, current);
        }
        case 3:
        {
            return ___ice_ids(in, current);
        }
        case 4:
        {
            return ___ice_isA(in, current);
        }
        case 5:
        {
            return ___ice_ping(in, current);
        }
        case 6:
        {
            return ___setProperties(in, current);
        }
    }

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

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

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

void ICE_API 
Ice::__patch(PropertiesAdminPtr& handle, const ::Ice::ObjectPtr& v)
{
    handle = ::Ice::PropertiesAdminPtr::dynamicCast(v);
    if(v && !handle)
    {
        IceInternal::Ex::throwUOE(::Ice::PropertiesAdmin::ice_staticId(), v);
    }
}
