Go Back   ZeroC Forums > Comments

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 01-24-2004
shaver 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
Reply With Quote
  #2 (permalink)  
Old 01-24-2004
marc's Avatar
marc marc is offline
ZeroC Staff
 
Name: Marc Laukien
Organization: ZeroC, Inc.
Project: The Internet Communications Engine
 
Join Date: Feb 2003
Location: Florida
Posts: 1,780
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.
Reply With Quote
  #3 (permalink)  
Old 01-24-2004
shaver shaver is offline
Registered User
 
 
Join Date: May 2003
Posts: 35
Quote:
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
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Base Class For Ref-Counted Classes? acbell Help Center 2 03-06-2006 05:32 PM
Add methods to a Java sample ???? surfer Help Center 8 01-18-2006 07:23 PM
C# code generated for comparison methods kwaclaw Comments 3 10-11-2005 01:54 PM
Local or server private methods dashie Help Center 6 12-22-2004 02:31 AM
request: macro declaring slice interface's methods shaver Comments 6 01-26-2004 06:45 PM


All times are GMT -4. The time now is 01:16 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.