Results 1 to 4 of 4

Thread: member ambiguity error when creating a smart pointer

  1. #1
    heathbar is offline Registered User
    Join Date
    Apr 2006
    Posts
    2

    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:
    #ifndef CAMSERVERI_H
    #define CAMSERVERI_H

    #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 {
    public:
    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&);

    protected:

    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;

    }

    #endif
    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...

  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
    Welcome to our forums! Please see this post regarding our support policy here on these forums.

  3. #3
    heathbar is offline Registered User
    Join Date
    Apr 2006
    Posts
    2

    updated sig

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

    -Kyle
    Kyle Heath
    MS EE, Stanford University
    Project: SenseNet - experiment in sensor networks

  4. #4
    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
    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.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. smart pointer down cast
    By peterlspot in forum Help Center
    Replies: 3
    Last Post: 05-24-2008, 09:37 AM
  2. Smart Pointer for Sequences
    By kalaxy in forum Help Center
    Replies: 3
    Last Post: 02-14-2008, 07:42 PM
  3. Can I use Ice's smart pointer with my own type?
    By timeguest in forum Help Center
    Replies: 1
    Last Post: 06-27-2005, 04:17 AM
  4. About the smart pointer.
    By level in forum Help Center
    Replies: 11
    Last Post: 08-04-2004, 08:16 PM
  5. Puzzle on smart pointer
    By soloman817 in forum Help Center
    Replies: 1
    Last Post: 07-13-2004, 05:29 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
  •