Archived

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

Server compile error!

I have written the slice as shown below:
module GISS
{
struct NetPacket
{
string szAlias;
short uiType;
short uiHWAddr;
short uiAddr;
double fVMin;
double fVMax;
string szVUnit;
double fEMin;
double fEMax;
string szEUnit;
double fFactor;
};
sequence<NetPacket> NetPackets;

sequence<double> DataPackets;

interface DDTProtocol
{
bool init(NetPackets np);
bool config();
bool trigger();
DataPackets getData();

string queryError();
};

};

And the server implemet is:
#include <IceUtil/Thread.h>
#include <IceUtil/Monitor.h>
#include "ddtp.h"
#include "LogI.h"

class DDTProtocolI;
typedef IceUtil::Handle<DDTProtocolI> DDTProtocolIPtr;

class DDTProtocolI : public GISS::DDTProtocol, public IceUtil::Monitor<IceUtil::Mutex>
{
public:
DDTProtocolI(const LogIPtr&, HWManager*);

virtual bool init(const GISS::NetPackets&, const Ice::Context&);
virtual bool config(const Ice::Context&);
virtual bool trigger(const Ice::Context&);
virtual GISS::DataPackets getData(const Ice::Context&);
virtual std::string queryError(const Ice::Context&);

void destroy();

void run();

private:
bool _destroy;

bool ice_invoke(std::string, DWORD);

std::string _error;
GISS::NetPackets _NetPackets;
GISS::DataPackets _DataPackets;

LogIPtr _log;
HWManager* _HWManager;

class DDTProtocolThread : public IceUtil::Thread
{
public:
DDTProtocolThread(const DDTProtocolIPtr& ddtprotocol) :
_DDTProtocol(ddtprotocol)
{
}

virtual void run()
{
_DDTProtocol->run();
}

private:
const DDTProtocolIPtr _DDTProtocol;
};

IceUtil::ThreadPtr _DDTProtocolThread;

};

//
// Create a communicator and object adapter.
//
Ice::CommunicatorPtr communicator;
Ice::ObjectAdapterPtr adapter;
LogIPtr log;
try
{
int argc = 0;
Ice::PropertiesPtr properties = Ice::createProperties();
properties->load("config");
communicator = Ice::initializeWithProperties(argc, 0, properties);
log = new LogI;
communicator->setLogger(log);
adapter = communicator->createObjectAdapter("Hello");
}
catch(const IceUtil::Exception& ex)
{
std::ostringstream ostr;
ostr << ex;
std::string s = ostr.str();
AfxMessageBox(CString(s.c_str()), MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}

......

//
// Instantiate the servant.
//
//Ice::ObjectPtr servant = new DDTProtocolI(log, &m_HWManager);
adapter->add(new DDTProtocolI(log, &m_HWManager), Ice::stringToIdentity("hello"));
adapter->activate();
log->message(0, "Ready to receive requests.");

When compiled,I had got the error message as "Error 25 error C2259: 'DDTProtocolI' : cannot instantiate abstract class".
What is the matter?

Comments

  • matthew
    matthew NL, Canada
    The signature of the methods in the servant implementation are wrong. You have, for example,
    virtual bool init(const GISS::NetPackets&, const Ice::Context&);
    

    This should be:
    virtual bool init(const GISS::NetPackets&, const Ice::Current&);
    

    Please also fill our your signature information as described in the link in my signature.
  • Thnak you for your answer !
  • matthew
    matthew NL, Canada
    You are welcome, however, please note that your signature does not mention your organization or project. If you need further help you should provide that information.