Skip to content

Commit

Permalink
Ice::Object cleanup (#1954)
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier authored Mar 16, 2024
1 parent 7ebe256 commit 7c6f754
Show file tree
Hide file tree
Showing 57 changed files with 233 additions and 317 deletions.
6 changes: 3 additions & 3 deletions cpp/include/Ice/Communicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,22 +315,22 @@ namespace Ice
* @param servant The servant that implements the new Admin facet.
* @param facet The name of the new Admin facet.
*/
void addAdminFacet(const std::shared_ptr<Object>& servant, const std::string& facet);
void addAdminFacet(const ObjectPtr& servant, const std::string& facet);

/**
* Remove the following facet to the Admin object. Removing a facet that was not previously registered throws
* NotRegisteredException.
* @param facet The name of the Admin facet.
* @return The servant associated with this Admin facet.
*/
std::shared_ptr<Object> removeAdminFacet(const std::string& facet);
ObjectPtr removeAdminFacet(const std::string& facet);

/**
* Returns a facet of the Admin object.
* @param facet The name of the Admin facet.
* @return The servant associated with this Admin facet, or null if no facet is registered with the given name.
*/
std::shared_ptr<Object> findAdminFacet(const std::string& facet);
ObjectPtr findAdminFacet(const std::string& facet);

/**
* Returns a map of all facets of the Admin object.
Expand Down
1 change: 0 additions & 1 deletion cpp/include/Ice/Connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include <IceUtil/PushDisableWarnings.h>
#include <Ice/ProxyF.h>
#include <Ice/ObjectF.h>
#include <Ice/ValueF.h>
#include <Ice/Exception.h>
#include <Ice/StreamHelpers.h>
Expand Down
91 changes: 27 additions & 64 deletions cpp/include/Ice/Current.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,110 +2,73 @@
// Copyright (c) ZeroC, Inc. All rights reserved.
//

#ifndef __Ice_Current_h__
#define __Ice_Current_h__
#ifndef ICE_CURRENT_H
#define ICE_CURRENT_H

#include <IceUtil/PushDisableWarnings.h>
#include <Ice/ProxyF.h>
#include <Ice/ObjectF.h>
#include <Ice/ValueF.h>
#include <Ice/Exception.h>
#include <Ice/StreamHelpers.h>
#include <Ice/Comparable.h>
#include <optional>
#include <Ice/ObjectAdapterF.h>
#include <Ice/ConnectionF.h>
#include <Ice/Context.h>
#include <Ice/Identity.h>
#include <Ice/OperationMode.h>
#include <Ice/Version.h>
#include <IceUtil/UndefSysMacros.h>

#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
#include "ConnectionF.h"
#include "Ice/Context.h"
#include "Ice/Identity.h"
#include "ObjectAdapterF.h"
#include "Ice/OperationMode.h"
#include "Ice/Version.h"

namespace Ice
{
/**
* Information about the current method invocation for servers. Each operation on the server has a
* <code>Current</code> as its implicit final parameter. <code>Current</code> is mostly used for Ice services. Most
* applications ignore this parameter.
* Information about an incoming request being dispatched.
* \headerfile Ice/Ice.h
*/
struct Current
{
/**
* The object adapter.
*/
::std::shared_ptr<::Ice::ObjectAdapter> adapter;
ObjectAdapterPtr adapter;

/**
* Information about the connection over which the current method invocation was received. If the invocation is
* direct due to collocation optimization, this value is set to null.
*/
::std::shared_ptr<::Ice::Connection> con;
ConnectionPtr con;

/**
* The Ice object identity.
*/
::Ice::Identity id;
Identity id;

/**
* The facet.
*/
::std::string facet;
std::string facet;

/**
* The operation name.
*/
::std::string operation;
std::string operation;

/**
* The mode of the operation.
*/
::Ice::OperationMode mode;
OperationMode mode;

/**
* The request context, as received from the client.
*/
::Ice::Context ctx;
Context ctx;

/**
* The request id unless oneway (0).
*/
int requestId;
/**
* The encoding version used to encode the input and output parameters.
*/
::Ice::EncodingVersion encoding;

/**
* Obtains a tuple containing all of the struct's data members.
* @return The data members in a tuple.
* The encoding version used to encode the input and output parameters.
*/
std::tuple<
const ::std::shared_ptr<::Ice::ObjectAdapter>&,
const ::std::shared_ptr<::Ice::Connection>&,
const ::Ice::Identity&,
const ::std::string&,
const ::std::string&,
const ::Ice::OperationMode&,
const ::Ice::Context&,
const int&,
const ::Ice::EncodingVersion&>
ice_tuple() const
{
return std::tie(adapter, con, id, facet, operation, mode, ctx, requestId, encoding);
}
EncodingVersion encoding;
};

using Ice::operator<;
using Ice::operator<=;
using Ice::operator>;
using Ice::operator>=;
using Ice::operator==;
using Ice::operator!=;
/** A default-initialized Current instance. */
ICE_API extern const Current emptyCurrent;
}

#include <IceUtil/PopDisableWarnings.h>
#endif
1 change: 0 additions & 1 deletion cpp/include/Ice/Endpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include <IceUtil/PushDisableWarnings.h>
#include <Ice/ProxyF.h>
#include <Ice/ObjectF.h>
#include <Ice/ValueF.h>
#include <Ice/Exception.h>
#include <Ice/StreamHelpers.h>
Expand Down
1 change: 0 additions & 1 deletion cpp/include/Ice/EndpointSelectionType.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#define __Ice_EndpointSelectionType_h__

#include <Ice/ProxyF.h>
#include <Ice/ObjectF.h>
#include <Ice/ValueF.h>
#include <Ice/Exception.h>
#include <Ice/StreamHelpers.h>
Expand Down
11 changes: 5 additions & 6 deletions cpp/include/Ice/FacetMap.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//
//

#include <Ice/ObjectF.h>
#include <map>

#ifndef ICE_FACET_MAP_H
# define ICE_FACET_MAP_H
#define ICE_FACET_MAP_H

#include "ObjectF.h"
#include <map>

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

#endif
1 change: 0 additions & 1 deletion cpp/include/Ice/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#define __Ice_Logger_h__

#include <Ice/ProxyF.h>
#include <Ice/ObjectF.h>
#include <Ice/ValueF.h>
#include <Ice/Exception.h>
#include <Ice/StreamHelpers.h>
Expand Down
9 changes: 2 additions & 7 deletions cpp/include/Ice/MarshaledResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
#include "Current.h"
#include "OutputStream.h"

namespace IceInternal
{
class Incoming;
}

namespace Ice
{
/**
Expand All @@ -25,12 +20,12 @@ namespace Ice
public:
MarshaledResult() = delete;
MarshaledResult(const MarshaledResult&) = delete;
MarshaledResult(MarshaledResult&&);
MarshaledResult(MarshaledResult&&) = default;

virtual ~MarshaledResult() = default;

MarshaledResult& operator=(const MarshaledResult&) = delete;
MarshaledResult& operator=(MarshaledResult&&);
MarshaledResult& operator=(MarshaledResult&&) = default;

/// \cond INTERNAL

Expand Down
32 changes: 14 additions & 18 deletions cpp/include/Ice/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,32 @@
#ifndef ICE_OBJECT_H
#define ICE_OBJECT_H

#include <Ice/ObjectF.h>
#include <Ice/ProxyF.h>
#include <Ice/SlicedDataF.h>
#include <Ice/Current.h>
#include <Ice/Format.h>
#include "ObjectF.h"
#include "IncomingRequest.h"
#include "OutgoingResponse.h"

namespace IceInternal
{
class Incoming;
class Direct;
}

namespace Ice
{
/** A default-initialized Current instance. */
ICE_API extern const Current emptyCurrent;

/**
* The base class for servants.
* @remarks Object is a stateless polymorphic base class. Its copy constructor, move constructor, copy assignment
* operator and move assignment operator are all deleted to prevent accidental slicing. Derived classes can
* define these constructors and assignment operators to reenable copying, moving and slicing.
* \headerfile Ice/Ice.h
*/
class ICE_API Object
{
public:
Object() = default;
virtual ~Object() = default;

Object(const Object&) = delete;
Object& operator=(const Object&) = delete;
Object(Object&&) = delete;
Object& operator=(Object&&) = delete;

/**
* Dispatch an incoming request and return the corresponding outgoing response.
* Dispatches an incoming request and return the corresponding outgoing response.
* @param request The incoming request.
* @param sendResponse A callback that the implementation calls to return the response. sendResponse does not
* throw any exception and any sendResponse wrapper must not throw any exception. sendResponse can be called by
Expand Down Expand Up @@ -74,7 +70,7 @@ namespace Ice
/// \endcond

/**
* Returns the Slice type IDs of the interfaces supported by this object.
* Gets the Slice type IDs of the interfaces supported by this object.
* @param current The Current object for the invocation.
* @return The Slice type IDs of the interfaces supported by this object, in alphabetical order.
*/
Expand All @@ -84,7 +80,7 @@ namespace Ice
/// \endcond

/**
* Returns the Slice type ID of the most-derived interface supported by this object.
* Gets the Slice type ID of the most-derived interface supported by this object.
* @param current The Current object for the invocation.
* @return The Slice type ID of the most-derived interface.
*/
Expand All @@ -94,7 +90,7 @@ namespace Ice
/// \endcond

/**
* Obtains the Slice type ID of this type.
* Gets the Slice type ID of this type.
* @return The return value is always "::Ice::Object".
*/
static std::string_view ice_staticId() noexcept;
Expand Down
Loading

0 comments on commit 7c6f754

Please sign in to comment.