Results 1 to 4 of 4

Thread: How to define a pointer type in slice?

  1. #1
    acku711 is offline Registered User
    Name: Zhang Pp
    Organization: Neusoft
    Project: R&D
    Join Date
    Dec 2008
    Location
    Beijing,China
    Posts
    4

    How to define a pointer type in slice?

    Hi,

    I have two questions.
    1) I need to define an interface including an operation that accepts two arguments, one is int type, the other is char** type. How to define it?
    2) If the argument is ostream*, How to define it?

    Thanks for any help in advance.

  2. #2
    michi's Avatar
    michi is offline Registered User
    Name: Michi Henning
    Organization: Triodia Technologies
    Project: I have a passing interest in Ice :-)
    Join Date
    Feb 2003
    Location
    Brisbane, Australia
    Posts
    1,055
    Quote Originally Posted by acku711 View Post
    Hi,
    1) I need to define an interface including an operation that accepts two arguments, one is int type, the other is char** type. How to define it?
    What are you trying to model here. That the operation returns a string? If so, you can use
    Code:
    void op(out string s);
    Code:
    2) If the argument is ostream*, How to define it?
    You cannot pass a C++ stream across a Slice interface. Doing so makes no sense. For example, if the receiver is written in Java, what could it possibly do with the stream?

    Even if the receiver were written in C++ too, what should happen if the receiver were to use the stream sent by the sender? If there receiver were to write some bytes to the stream, where would you expect them to appear? The couldn't appear on the sender's screen because a C++ stream is not capable of perform remote communication.

    I suggest you read the introductory chapter and the Slice chapter of the documentation to get an idea of what Ice can do for you, and how the basic architecture works.

    Cheers,

    Michi.

    Thanks for any help in advance.[/QUOTE]

  3. #3
    acku711 is offline Registered User
    Name: Zhang Pp
    Organization: Neusoft
    Project: R&D
    Join Date
    Dec 2008
    Location
    Beijing,China
    Posts
    4
    Thanks,Michi
    Sorry, maybe I have not described clearly.

    For the first question, I need to define an interface like that:

    int getOpt (int argc, char **argv)

    How to define argv in slice? I try to define this like that:

    sequence<byte> ByteSeq;
    sequence<ByteSeq> ByteseqSeq;
    int getOpt (int argc, ByteseqSeq argv);

    I don't feel it is better. In fact, I accept "(int argc, char **argv)" from command lines in client and pass to server through getOpt(). If the interface is defined like above, I have to rebuilt "ByteseqSeq" from char **argv. Is there another way?

    --------------------------------------------------------------------------
    For the other question,

    I want to carry out a task that the client can get the output from server at real time. For example:

    supposing I can pass ostream& object int a function func(),

    interface demo
    {
    void func(out ostream& os); //I kown it is error here
    };

    ...
    void demo::func(ostream& os, const Ice::Current &)
    {
    int result = 0;
    while (1)
    {
    /* do something and come out result */

    os << result; /* then it will be printed in client */
    }
    }

  4. #4
    matthew's Avatar
    matthew is offline ZeroC Staff
    Name: Matthew Newhook
    Organization: ZeroC, Inc.
    Project: Internet Communications Engine
    Join Date
    Feb 2003
    Location
    NL, Canada
    Posts
    1,458
    For the first case you would be better off passing a sequence of string.

    Code:
    sequence<string> StringSeq;
    You can find some predefined sequence types in slice/Ice/BuiltinSequences.ice.

    For the second case you'd have to define some interface through which the server streams the data. Something like:

    Code:
    // Slice
    sequence<byte> ByteSeq;
    interface Stream
    {
        void send(ByteSeq data);
    };
    
    interface Server
    {
       void startStreaming(Stream* s);
    };
    In your client you would supply a proxy to a stream object to the server, and the server would call on the stream object passing the data as a series of byte sequences to the client.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to define uncertain variable type
    By hisensewxz in forum Help Center
    Replies: 5
    Last Post: 08-21-2009, 09:14 PM
  2. How to define a variant type?
    By fengxb in forum Help Center
    Replies: 2
    Last Post: 07-31-2005, 10:45 AM
  3. How to define this in slice?
    By zhangzq71 in forum Help Center
    Replies: 4
    Last Post: 07-17-2005, 06:18 PM
  4. Can I use Ice's smart pointer with my own type?
    By timeguest in forum Help Center
    Replies: 1
    Last Post: 06-27-2005, 04:17 AM
  5. Replies: 1
    Last Post: 06-14-2005, 12:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •