Archived

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

Dynamic dispatch demo

Hi.

I have a question regarding how to implement dynamic dispatch. I"m following the demo given in $ICE_HOME/demo/Ice/invoke/

I've taken out all the functions except one..

Here is my sample Dynamic.ice file

module Dynamic
{
struct Structure
{
string name;
int value;
};
sequence<Structure> StructureSeq;
interface Printer
{
void printStructSequence(StructureSeq seq);
};
};

I've also taken PrinterI.h and PrinterI.cpp and stripped it out for only my function printStructSequence (implemented ice_invoke())

now, in the demo, i've noticed two methods ice_writeStructureSeq and ice_readStructureSeq

do I have to implement this in Dynamic.cpp, or will slice2cpp do it for me..

I'm using slice2cpp like this

slice2cpp --stream Dynamic.ice

Right now, when compiling, I get the error

[email]pradab@dagger:~/work/dynamic$./dynamic.bash[/email]
PrinterI.cpp: In member function `virtual bool PrinterI::ice_invoke(const
std::vector<Byte, std::allocator<Byte> >&, std::vector<Byte,
std::allocator<Byte> >&, const Ice::Current&)':
PrinterI.cpp:18: error: `ice_readStructureSeq' undeclared in namespace `Dynamic
'
DynamicClient.cpp: In member function `virtual int DynamicClient::run(int,
char**)':
DynamicClient.cpp:51: error: `ice_writeStructureSeq' undeclared in namespace `
Dynamic'
g++: PrinterI.o: No such file or directory
g++: DynamicClient.o: No such file or directory

thats cuz these two methods are not there in Dynamic.cpp (generated by slice2cpp)

Please help

Comments

  • mes
    mes California
    Hi,

    When I copy your Slice definitions into a file and run 'slice2cpp --stream File.ice', the generated file File.cpp does contain the read/write functions. Are you sure that you are running slice2cpp correctly, and that your compiler is finding the correct version of the generated files?

    Take care,
    - Mark
  • dwayne
    dwayne St. John's, Newfoundland
    Hi,

    The ice_write/ice_read functions are generated by slice2cpp when you use the --stream option. Just take a look in your generated files (Dynamic.cpp|h). Regarding your compile error, are you sure that Dynamic.h is being included by your code?

    Regards,
    Dwayne
  • oopsss

    am so sorry..

    I was doing slice2cpp --stream on the command line..

    but had completely forgotten about it on the Makefile!!

    :)
    apoligies and thanks for the prompt help!