Results 1 to 6 of 6

Thread: slice definition for type ID?

  1. #1
    peterlspot is offline Registered User
    Name: Peter Lau
    Organization: Self
    Project: Study
    Join Date
    Nov 2007
    Posts
    13

    Accessing type ID from slice?

    Just wonder if one can access the type Id of a class or struct right in slice? The reason is to use type id as indexes in Freeze store. With this index, one can easily enumerate all instances of a given slice type in the store.

    Take an example "food.ice":

    module FoodStore
    {
    class Food
    {
    string name;
    }

    class BakedFood extends Food
    {
    int temperature;
    int mintues;
    }
    class MyFaviouriteBread extends Food
    {
    }
    }
    Suppose there is a Freeze map created by:

    slice2freeze --dict FoodStoreMap,string,FoodStore::Food FoodStoreMap food.ice
    How can one add a Freeze Index to this map so that one can easily find all the instances of "BakedFood"? Seems there is no "ice_id" or "type_id" fields defined in Ice::Object ...

    Thanks,
    Peter
    Last edited by peterlspot; 11-27-2007 at 05:13 AM.
    Peter Lau
    No pains, no gains.
    Lifelong programming ...

  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
    Ice::Object has an ice_id method that returns the Slice type ID. Does this help with your problem?

    Cheers,

    Michi.
    Last edited by michi; 11-27-2007 at 06:55 PM.

  3. #3
    peterlspot is offline Registered User
    Name: Peter Lau
    Organization: Self
    Project: Study
    Join Date
    Nov 2007
    Posts
    13
    Hi michi, thanks very much for the prompt follow up.

    Yes I knew that Ice::Object has a method "ice_id()", but that method is only available to C++/C#/Java programs, not available to the slice2freeze tool. In fact, the "--dict-index" option of the slice2freeze tool requires the index key to be a data member of a slice class or struct, how can one create an index using the Ice::Object::ice_id() in Freeze?

    Suppose there is a "ice_id" member available for Ice::Object in slice, one can easily use
    slice2freeze --dict foodStoreMap,string,FoodStore::Food --dict-index foodStoreMap,ice_id food.ice
    to create an index to the Freeze map.

    Do u know if there is already a similar thing in ICE or Freeze now? Is there any other alternatives?
    Peter Lau
    No pains, no gains.
    Lifelong programming ...

  4. #4
    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
    Sorry, but there is currently now way to do what you want because the index key has to be a member of the Slice class.

    We'll consider adding this feature to a future release.

    Cheers,

    Michi.

  5. #5
    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
    Note that you can achieve what you need by adding a typeID member to your FoodStore class:
    Code:
    module FoodStore
    {
        class Food
        {
            string typeID;
            string name;
        };
    };
    This will allow you to use the typeID member as the key of the index.

    Cheers,

    Michi.

  6. #6
    peterlspot is offline Registered User
    Name: Peter Lau
    Organization: Self
    Project: Study
    Join Date
    Nov 2007
    Posts
    13
    Yea, that is the workaround for now, though it is not natural since the information in the "ice_id()" method must be manually populated to that member field before an instance is writing to Freeze.

    Just for ur information, maybe the slice2freeze tool can be added a new option like
    "--dict-index-by-type xxxMap"
    so that a typeId index is added to a map. This way, the change is limited to the "slice2freeze" tool only and no need to change the current SLICE spec.

    Anyway, hope ICE can get even more popular this way, and best wishes...
    Peter Lau
    No pains, no gains.
    Lifelong programming ...

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Using IceUtil::Time in a Slice definition
    By sidney in forum Help Center
    Replies: 2
    Last Post: 03-19-2010, 04:33 AM
  2. ice.slice definition problem
    By Marek Nos in forum Help Center
    Replies: 0
    Last Post: 05-27-2009, 07:51 AM
  3. slice definition if dfstream file
    By moshehak in forum Help Center
    Replies: 1
    Last Post: 02-21-2008, 07:47 AM
  4. How to use Slice defined Types in another definition
    By Venkat Seeth in forum Help Center
    Replies: 4
    Last Post: 02-22-2005, 12:24 PM
  5. Type id
    By ganzuoni in forum Comments
    Replies: 5
    Last Post: 07-02-2003, 03:09 AM

Posting Permissions

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