Home Help Center

Dynamic dispatch demo


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][email protected]:~/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,
DynamicClient.cpp:51: error: `ice_writeStructureSeq' undeclared in namespace `
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


  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff

    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
  • dwaynedwayne St. John's, NewfoundlandMember Dwayne BooneOrganization: ZeroC, Inc.Project: Internet Communications Engine

    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?

  • orpheanorphean Member

    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!
Sign In or Register to comment.