Home Help Center

["preserve-slice"] and Ice.Default.SlicedFormat=1

MirkoWaechterMirkoWaechter Member Mirko WaechterOrganization: University of KarlsruheProject: ArmarX Robot Framework
Hello,

for slice preserving it is stated in the documentation (see link) that each operation needs to have the metadirective format:sliced attached to it.
Is this also the case if the property
Ice.Default.SlicedFormat=1 is used?

thanks
Mirko

Comments

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    As stated in the documentation of the format metadata, the value of Ice.Default.SlicedFormat is used if no format metadata is specified. So you don't need to set format:sliced if you set Ice.Default.SlicedFormat=1.

    You are still required to set the preserve-slice metadata on a base class if you want to be able to preserve the slices. If you don't specify this metadata and you receive an object that needs to be sliced, the slices won't be preserved. This is fine if you don't need to forward the object to another peer but if you want to forward it as-is, you'll want to preserve its slices.

    Cheers,
    Benoit.
  • MirkoWaechterMirkoWaechter Member Mirko WaechterOrganization: University of KarlsruheProject: ArmarX Robot Framework
    Thanks for the quick reply.
    Do I need to specify the preserve-slice in a class that has no classes it inherits from or can it be some class in the middle of the inheritance?

    An example to clarify:
    class A{};
    
    ["preserve-slice"]
    class B extends A {};
    
    class C extends B {};
    

    It don't need the preserving for all classes that inherit from A, only all classes that inherit from B.
    Does this work or does class A need to have the tag ["preserve-slice"]?
  • MirkoWaechterMirkoWaechter Member Mirko WaechterOrganization: University of KarlsruheProject: ArmarX Robot Framework
    Also, does the preserving work with nested types (where the outer class possibly is not tagged with ["preserve-slice"])?
    ["preserve-slice"]
    Class B{};
    
    Class D
    {
    Class B;
    };
    
    ["format:slice"]
    interface MyInterface
    {
          D getData();
    }
    
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Yes, you can set the preserve-slice metadata on any class of the class hierarchy so you're example is fine.

    It also works for objects which are nested within another data type, the object of type B will be sliced and its slice will be preserved when it's forwarded to another peer even if the object B is nested in the class D.

    Cheers,
    Benoit.
  • MirkoWaechterMirkoWaechter Member Mirko WaechterOrganization: University of KarlsruheProject: ArmarX Robot Framework
    OK, thanks. So I need to debug deeper to find why it is not working for me.
  • MirkoWaechterMirkoWaechter Member Mirko WaechterOrganization: University of KarlsruheProject: ArmarX Robot Framework
    The problem was that my class with the tag preserve-slice was abstract, so no factory for that type either, which led to my error that the slice-preserving did not work.
Sign In or Register to comment.