Home Help Center

How to use user defined C++ types in Slice

rmerriamrmerriam Member Rud MerriamOrganization: mystic lake softwareProject: Entry in NASA 2013 Sample Return Robot Centennial
 
#ifndef HELLO_ICE
#define HELLO_ICE

[["cpp:include:../inc/GridData.h"]]

// in GridData.h
//    struct GridDatum { ... };
//    typedef std::deque<GridDatum> GridData;

module SRR
{

    interface SRRData
    {       
        idempotent void sendGridData(GridData data);
        idempotent void sendGridPoint(float east, float south, int id);
        void shutdown();
        };
    
};

#endif

I am trying to use my own defined types. The above Slice snippet illustrates what I am trying to do. The few comment lines indicate what is in GridData.h where my types are defined. I tried the a lot of variations on the "cpp:type] metadata without success.

How do I use my own data types?

Rud

Comments

  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi Rud,

    C++ does not have serializable types like Java and C#, so you need to tell Ice how to serialize the C++ objects you want to transmit as sequence<byte> (or sequence of some other type).

    This is done through StreamHelper templates, as described in C++ Mapping for Sequences - Ice 3.5 - ZeroC.

    For a complete working example, I recommend the Protocol Buffers lab release: ZeroC Labs: Protocol Buffers. And then replace the PB by your own type or type-family.

    Cheers,
    Bernard
Sign In or Register to comment.