Results 1 to 3 of 3

Thread: macro to resolve ambiguous-base Ice::Object methods

  1. #1
    shaver is offline Registered User
    Join Date
    May 2003
    Posts
    35

    Lightbulb macro to resolve ambiguous-base Ice::Object methods

    If I want to implement two distinct Ice interfaces in one class, I have to manually forward the Ice::Object internal methods to ::Ice::Object, or else suffer g++'s "no unique final overrider" wrath. Rather than duplicate the (considerable) typing every time I hit one of those, or write one-off slice interfaces to have slice2cpp generate the forwarding for me -- at some code size cost as well -- I use the following macro:

    Code:
    #define ICE_FORWARD_ICE_OBJECT_METHODS                                                               \
        virtual bool ice_isA(const std::string& i, const ::Ice::Current& c) const { return ::Ice::Object::ice_isA(i, c); } \
        virtual ::std::vector< ::std::string> ice_ids(const ::Ice::Current& c = ::Ice::Current()) const { return ::Ice::Object::ice_ids(c); } \
        virtual const ::std::string& ice_id(const ::Ice::Current& c= ::Ice::Current()) const { return ::Ice::Object::ice_id(c); } \
        virtual ::IceInternal::DispatchStatus __dispatch(::IceInternal::Incoming& i, const ::Ice::Current& c) { return ::Ice::Object::__dispatch(i, c); } \
        virtual void __write(::IceInternal::BasicStream* s, bool b) const { ::Ice::Object::__write(s, b); } \
        virtual void __read(::IceInternal::BasicStream* s, bool b = true) { ::Ice::Object::__read(s, b); } \
        virtual void __gcReachable(::IceUtil::GCObjectMultiSet& ms) const { ::Ice::Object::__gcReachable(ms); } \
        virtual void __gcClear() { ::Ice::Object::__gcClear(); }
    I think it would look quite spiffy in Ice/Object.h, myself!

    Mike

  2. #2
    marc's Avatar
    marc is offline ZeroC Staff
    Name: Marc Laukien
    Organization: ZeroC, Inc.
    Project: The Internet Communications Engine
    Join Date
    Feb 2003
    Location
    Florida
    Posts
    1,860
    Hmm... I'm surprised that this works. For example, you overload ice_isA() to use the version of the base class, so all checked casts to a derived interface fail, don't they? And how are calls dispatched, since you forward __dispatch() to the base class as well?

    In general, I recommend to not to use such code that relies on Ice internals. Such code could break when we make changes to internals.

  3. #3
    shaver is offline Registered User
    Join Date
    May 2003
    Posts
    35
    Originally posted by marc
    Hmm... I'm surprised that this works. For example, you overload ice_isA() to use the version of the base class, so all checked casts to a derived interface fail, don't they? And how are calls dispatched, since you forward __dispatch() to the base class as well?
    Honestly, now that you ask, I don't really know. It seems to work, but I agree that it sure shouldn't.

    What I'm trying to achieve is having checkedCast act like QueryInterface, I suppose, but maybe I want facets or some other mechanism for this purpose. Am I "not supposed" to have my servant inherit from multiple disjoint interfaces? I guess I need some more sophisticated dispatching mechanism, based on the incoming identity or something.

    Hrm. How embarrassing.

    Mike

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 11
    Last Post: 06-24-2010, 03:12 PM
  2. Replies: 7
    Last Post: 03-11-2009, 11:50 AM
  3. Replies: 1
    Last Post: 09-18-2008, 08:44 PM
  4. Base Class For Ref-Counted Classes?
    By acbell in forum Help Center
    Replies: 2
    Last Post: 03-06-2006, 05:32 PM
  5. Replies: 6
    Last Post: 01-26-2004, 06:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •