Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Object and derived classes use SharedPtr with the Original mapping #1668

Merged
merged 11 commits into from
Jan 15, 2024
66 changes: 4 additions & 62 deletions cpp/include/Ice/FacetMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,79 +2,21 @@
// Copyright (c) ZeroC, Inc. All rights reserved.
//
//
// Ice version 3.7.10
//
// <auto-generated>
//
// Generated from file `FacetMap.ice'
//
// Warning: do not edit this file.
//
// </auto-generated>
//

#ifndef __Ice_FacetMap_h__
#define __Ice_FacetMap_h__

#include <IceUtil/PushDisableWarnings.h>
#include <Ice/ProxyF.h>
#include <Ice/ObjectF.h>
#include <Ice/ValueF.h>
#include <Ice/Exception.h>
#include <Ice/LocalObject.h>
#include <Ice/StreamHelpers.h>
#include <Ice/Comparable.h>
#include <IceUtil/ScopedArray.h>
#include <Ice/Optional.h>
#include <IceUtil/UndefSysMacros.h>

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

#ifndef ICE_API
# if defined(ICE_STATIC_LIBS)
# define ICE_API /**/
# elif defined(ICE_API_EXPORTS)
# define ICE_API ICE_DECLSPEC_EXPORT
# else
# define ICE_API ICE_DECLSPEC_IMPORT
# endif
#endif

#ifdef ICE_CPP11_MAPPING // C++11 mapping
#include <map>

namespace Ice
{

/**
* A mapping from facet name to servant.
*/
using FacetMap = ::std::map<::std::string, ::std::shared_ptr<Object>>;

}

#else // C++98 mapping
#ifndef ICE_FACET_MAP_H
#define ICE_FACET_MAP_H

namespace Ice
{

/**
* A mapping from facet name to servant.
*/
typedef ::std::map< ::std::string, ObjectPtr> FacetMap;
using FacetMap = ::std::map<::std::string, ObjectPtr>;

}

#endif

#include <IceUtil/PopDisableWarnings.h>
#endif
2 changes: 1 addition & 1 deletion cpp/include/Ice/MetricsAdminI.h
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ class ICE_API MetricsAdminI : public IceMX::MetricsAdmin,
const Ice::LoggerPtr _logger;
Ice::PropertiesPtr _properties;
};
ICE_DEFINE_PTR(MetricsAdminIPtr, MetricsAdminI);
ICE_DEFINE_SHARED_PTR(MetricsAdminIPtr, MetricsAdminI);

};

Expand Down
9 changes: 3 additions & 6 deletions cpp/include/Ice/NativePropertiesAdmin.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace Ice
* Ice ignores any exceptions raised by the callback.
* \headerfile Ice/Ice.h
*/
class ICE_API PropertiesAdminUpdateCallback : public virtual Ice::LocalObject
class ICE_API PropertiesAdminUpdateCallback
{
public:

Expand All @@ -44,17 +44,14 @@ class ICE_API PropertiesAdminUpdateCallback : public virtual Ice::LocalObject
*/
virtual void updated(const PropertyDict& d) = 0;
};
typedef IceUtil::Handle<PropertiesAdminUpdateCallback> PropertiesAdminUpdateCallbackPtr;
using PropertiesAdminUpdateCallbackPtr = SharedPtr<PropertiesAdminUpdateCallback>;
#endif

/**
* Base class for the Properties admin facet.
* \headerfile Ice/Ice.h
*/
class ICE_API NativePropertiesAdmin
#ifndef ICE_CPP11_MAPPING
: public virtual IceUtil::Shared
#endif
{
public:

Expand All @@ -79,7 +76,7 @@ class ICE_API NativePropertiesAdmin
virtual void removeUpdateCallback(const PropertiesAdminUpdateCallbackPtr& cb) = 0;
#endif
};
ICE_DEFINE_PTR(NativePropertiesAdminPtr, NativePropertiesAdmin);
ICE_DEFINE_SHARED_PTR(NativePropertiesAdminPtr, NativePropertiesAdmin);

}

Expand Down
5 changes: 2 additions & 3 deletions cpp/include/Ice/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,11 @@ class ICE_API Object
* The base class for servants.
* \headerfile Ice/Ice.h
*/
class ICE_API Object : public virtual IceUtil::Shared
class ICE_API Object
{
public:

virtual bool operator==(const Object&) const;
virtual bool operator<(const Object&) const;
virtual ~Object() = default;

/**
* Tests whether this object supports a specific Slice interface.
Expand Down
8 changes: 4 additions & 4 deletions cpp/include/Ice/ObjectF.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
#ifndef ICE_OBJECT_F_H
#define ICE_OBJECT_F_H

#include <IceUtil/Shared.h>
#include <Ice/Handle.h>
#include <Ice/Config.h>
#include <Ice/SharedPtr.h>

namespace Ice
{

class Object;

#ifdef ICE_CPP11_MAPPING
/// \cond INTERNAL
using ObjectPtr = ::std::shared_ptr<Object>;
/// \endcond
#else
ICE_API Object* upCast(Object*);
typedef IceInternal::Handle<Object> ObjectPtr;
using ObjectPtr = SharedPtr<Object>;
#endif

}
Expand Down
37 changes: 33 additions & 4 deletions cpp/include/Ice/OutgoingAsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -670,13 +670,12 @@ extern ICE_API CallbackBasePtr dummyCallback;
// Generic callback template that requires the caller to down-cast the
// proxy and the cookie that are obtained from the AsyncResult.
//
template<class T>
template<class T, class TPtr>
class AsyncCallback : public GenericCallbackBase
{
public:

typedef T callback_type;
typedef IceUtil::Handle<T> TPtr;

typedef void (T::*Callback)(const ::Ice::AsyncResultPtr&);

Expand Down Expand Up @@ -812,7 +811,7 @@ newCallback(const IceUtil::Handle<T>& instance,
void (T::*cb)(const AsyncResultPtr&),
void (T::*sentcb)(const AsyncResultPtr&) = 0)
{
return new ::IceInternal::AsyncCallback<T>(instance, cb, sentcb);
return new ::IceInternal::AsyncCallback<T, IceUtil::Handle<T>>(instance, cb, sentcb);
}

/**
Expand All @@ -827,7 +826,37 @@ newCallback(T* instance,
void (T::*cb)(const AsyncResultPtr&),
void (T::*sentcb)(const AsyncResultPtr&) = 0)
{
return new ::IceInternal::AsyncCallback<T>(instance, cb, sentcb);
return new ::IceInternal::AsyncCallback<T, IceUtil::Handle<T>>(instance, cb, sentcb);
}

/**
* Creates a callback wrapper instance that delegates to your object.
* @param instance The callback object.
* @param cb The completion callback.
* @param sentcb The sent callback.
* @return A callback object that can be passed to an asynchronous invocation.
*/
template<class T> CallbackPtr
newCallback(const Ice::SharedPtr<T>& instance,
void (T::*cb)(const AsyncResultPtr&),
void (T::*sentcb)(const AsyncResultPtr&) = 0)
{
return new ::IceInternal::AsyncCallback<T, Ice::SharedPtr<T>>(instance, cb, sentcb);
}

/**
* Creates a callback wrapper instance that delegates to your object.
* @param instance The callback object.
* @param cb The completion callback.
* @param sentcb The sent callback.
* @return A callback object that can be passed to an asynchronous invocation.
*/
template<class T> CallbackPtr
newCallback(const std::shared_ptr<T>& instance,
void (T::*cb)(const AsyncResultPtr&),
void (T::*sentcb)(const AsyncResultPtr&) = 0)
{
return new ::IceInternal::AsyncCallback<T, std::shared_ptr<T>>(instance, cb, sentcb);
}

}
Expand Down
34 changes: 0 additions & 34 deletions cpp/include/Ice/PropertiesF.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,30 +75,11 @@ namespace Ice

using PropertiesPtr = ::std::shared_ptr<Properties>;

using PropertiesAdminPtr = ::std::shared_ptr<PropertiesAdmin>;
using PropertiesAdminPrxPtr = ::std::shared_ptr<PropertiesAdminPrx>;

}
/// \endcond

#else // C++98 mapping

namespace IceProxy
{

namespace Ice
{

class PropertiesAdmin;
/// \cond INTERNAL
ICE_API void _readProxy(::Ice::InputStream*, ::IceInternal::ProxyHandle< PropertiesAdmin>&);
ICE_API ::IceProxy::Ice::Object* upCast(PropertiesAdmin*);
/// \endcond

}

}

namespace Ice
{

Expand All @@ -108,22 +89,7 @@ ICE_API LocalObject* upCast(Properties*);
/// \endcond
typedef ::IceInternal::Handle< Properties> PropertiesPtr;

class PropertiesAdmin;
/// \cond INTERNAL
ICE_API Object* upCast(PropertiesAdmin*);
/// \endcond
typedef ::IceInternal::Handle< PropertiesAdmin> PropertiesAdminPtr;
typedef ::IceInternal::ProxyHandle< ::IceProxy::Ice::PropertiesAdmin> PropertiesAdminPrx;
typedef PropertiesAdminPrx PropertiesAdminPrxPtr;

}

/// \cond STREAM
namespace Ice
{

}
/// \endcond

#endif

Expand Down
49 changes: 0 additions & 49 deletions cpp/src/Ice/FacetMap.cpp

This file was deleted.

4 changes: 3 additions & 1 deletion cpp/src/Ice/Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1383,7 +1383,9 @@ IceInternal::Instance::finishSetup(int& argc, const char* argv[], const Ice::Com
const string processFacetName = "Process";
if(_adminFacetFilter.empty() || _adminFacetFilter.find(processFacetName) != _adminFacetFilter.end())
{
_adminFacets.insert(make_pair(processFacetName, ICE_MAKE_SHARED(ProcessI, communicator)));
ProcessPtr processFacet(make_shared<ProcessI>(communicator));

_adminFacets.insert(make_pair(processFacetName, processFacet));
}

//
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/Ice/Instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Timer;
typedef IceUtil::Handle<Timer> TimerPtr;

class MetricsAdminI;
ICE_DEFINE_PTR(MetricsAdminIPtr, MetricsAdminI);
ICE_DEFINE_SHARED_PTR(MetricsAdminIPtr, MetricsAdminI);

class RequestHandlerFactory;
typedef IceUtil::Handle<RequestHandlerFactory> RequestHandlerFactoryPtr;
Expand Down
10 changes: 4 additions & 6 deletions cpp/src/Ice/LoggerAdminI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ namespace

const char* traceCategory = "Admin.Logger";

class LoggerAdminI : public Ice::LoggerAdmin
#ifdef ICE_CPP11_MAPPING
, public std::enable_shared_from_this<LoggerAdminI>
#endif
class LoggerAdminI : public Ice::LoggerAdmin,
public std::enable_shared_from_this<LoggerAdminI>
{
public:

Expand Down Expand Up @@ -117,7 +115,7 @@ class LoggerAdminI : public Ice::LoggerAdmin
CommunicatorPtr _sendLogCommunicator;
bool _destroyed;
};
ICE_DEFINE_PTR(LoggerAdminIPtr, LoggerAdminI);
ICE_DEFINE_SHARED_PTR(LoggerAdminIPtr, LoggerAdminI);

class Job : public IceUtil::Shared
{
Expand Down Expand Up @@ -435,7 +433,7 @@ LoggerAdminI::attachRemoteLogger(const RemoteLoggerPrx& prx,
throw;
}
#else
CallbackPtr initCompletedCb = newCallback(this, &LoggerAdminI::initCompleted);
CallbackPtr initCompletedCb = newCallback(LoggerAdminIPtr(shared_from_this()), &LoggerAdminI::initCompleted);
try
{
remoteLogger->begin_init(logger->getPrefix(), initLogMessages, initCompletedCb, logger);
Expand Down
Loading