This forum has been archived. Please start a new discussion on GitHub.

member ambiguity error when creating a smart pointer

I have a class that inherits from both IceUtil::Thread and a skeleton class and get an error when trying to create an instance and assign it to a smart pointer.

The error (from gcc version 4.0.2) is:
/usr/include/IceUtil/Handle.h: In constructor ‘IceUtil::Handle<T>::Handle(T*) [with T = SenseNet::CamServerI]’:
camserver_main.cpp:28: instantiated from here
/usr/include/IceUtil/Handle.h:124: error: request for member ‘__incRef’ is ambiguous
/usr/include/IceUtil/Shared.h:200: error: candidates are: void IceUtil::Shared::__incRef()
/usr/include/Ice/GCShared.h:41: error: virtual void IceInternal::GCShared::__incRef()

Here's the class decleration:

#include <IceUtil/Thread.h>
#include "camserver.h"
#include "cameraservleti.h"
#include "sensenetserveri.h"
#include "camerasensor.h"

namespace SenseNet {

@author heathkh
class CamServerI : virtual public SenseNetServerI, virtual public CamServer, public IceUtil::Thread {
CamServerI(Ice::ObjectAdapterPtr objectAdapter);
virtual ~CamServerI();

void run();

void stop();

void loadConfiguration(std::string filename);
void saveConfiguration(std::string filename);

//Operations that implement the CamServerInterface
virtual CameraServletPrx getCameraServlet(const ::Ice::Current&);


IceUtil:: Mutex mutex;
bool stopThread;

std::string cameraSensorTypeName;
CameraSensor* cam;

CameraServletIPtr cameraServlet;
CameraServletPrx cameraServletPrx;


//define a smart pointer for this type
typedef IceUtil::Handle<CamServerI> CamServerIPtr;



And here's the line that causes the error:
CamServerIPtr camServer = new CamServerI(objectAdapter);

I am creating a server object that both needs to respond to incoming requests and also needs it's own thread to periodically broadcast messages. Is there a better way to do this?

Thanks for your help...


  • marc
    marc Florida
    Welcome to our forums! Please see this post regarding our support policy here on these forums.
  • updated sig

    Thanks for letting me know... I just updated my signature as requested.

  • marc
    marc Florida
    Skeleton classes and the Thread class derive from different base classes. The skeleton classes derive from IceInternal::GCShared, which provides for garbage collection. IceUtil::Thread derives from IceUtil::Shared, which does not (and can not) provide garbage collection. Since the two base classes differ, you cannot derive your servant implementation class from IceUtil::Thread. A simple solution to work around this problem is to use an IceUtil::Thread member in your servant class, which has a run() method that simply calls a run() method in your servant class. For an example, have a look at the class CallbackI in the demo demo/Ice/bidir.