DDS-XTypes 1.0 FTF Avatar
  1. OMG Issue

DDSXTY_ — No way to get or set length of collection-typed DynamicData objects

  • Key: DDSXTY_-5
  • Legacy Issue Number: 16237
  • Status: closed  
  • Source: Brookhaven National Laboratory ( Nikolay Malitsky)
  • Summary:

    A DynamicData object may encapsulate the state of an object of a collection type—a sequence, array, string, or map. In such a case, it is necessary to be able to get and set the length of the collection.

    Discussion:

    We need to add an accessor for the current length. This accessor can also be useful for other object of other types; for example, it can return the number of members in a structure.

    However, it is not appropriate to add a mutator for the length directly:

    · If the length of a collection is increased, that implies the addition of new elements. But the values of these new elements will not be meaningful.

    · If the length of a collection is decreased, that implies the removal of existing elements. But that may not be meaningful (what does it mean to remove a non-optional member of a structure?) of useful (why would you want to clear the fifth element of a bit set just because of what its index is?).

    · The lengths of some types cannot legally be changed at all—for example, array types.

    Therefore, it is better to allow elements to be added and removed, where appropriate, and thereby modify the length implicitly.

    Proposed Resolution:

    Add an operation get_length to the DynamicData class.

    · If the object is of a collection type, return the number of elements currently in the collection. In the case of an array type, this value will always be equal to the bound.

    · If the object is of a bit set type, return the number of named flags that are currently set in the bit set.

    · If the object is of a structure or annotation type, return the number of members in the object. This value may be different than the number of members in the corresponding DynamicType—for example, some optional members may be omitted; see the existing DynamicData documentation.

    · If the object is of a union type, return the number of members in the object. This value will always be two: the discriminator and the current member corresponding to it.

    · If the object is of a primitive or enumeration type, it is atomic: return one.

    · If the object is of an alias type, return the value appropriate for the alias’s base type.

    Expand the contracts of the existing set_<type>_value operations to allow them to append new elements to resizable collections—strings, sequences, and maps. (This behavior is aligned with the existing contract of the clear operations, which states that cleared elements of resizable collections shall be removed.) Obtain the member ID associated with the new value as follows:

    · For a string or sequence type, use get_member_id_at_index to obtain an ID for the index one greater than the current length.

    · For a map type, use get_member_id_by_name to obtain an ID for the new map key.

    Proposed Revised Text:

    TO DO

  • Reported: DDS-XTypes 1.0b2 — Wed, 4 May 2011 04:00 GMT
  • Disposition: Resolved — DDS-XTypes 1.0
  • Disposition Summary:

    Add an operation get_item_count to the DynamicData class.
    • If the object is of a collection type, return the number of elements currently in the collection. In the case of an array type, this value will always be equal to the product of the bounds of all array dimensions.
    • If the object is of a bit set type, return the number of named flags that are currently set in the bit set.
    • If the object is of a structure or annotation type, return the number of members in the object. This value may be different than the number of members in the corresponding DynamicType—for example, some optional members may be omitted; see the existing DynamicData documentation.
    • If the object is of a union type, return the number of members in the object. This value will always be two: the discriminator and the current member corresponding to it.
    • If the object is of a primitive or enumeration type, it is atomic: return one.
    • If the object is of an alias type, return the value appropriate for the alias’s base type.
    Expand the contracts of the existing set_<type>_value operations to allow them to append new elements to resizable collections—strings, sequences, and maps. (This behavior is aligned with the existing contract of the clear operations, which states that cleared elements of resizable collections shall be removed.) Obtain the member ID associated with the new value as follows:
    • For a string or sequence type, use get_member_id_at_index to obtain an ID for the index one greater than the current length.
    • For a map type, use get_member_id_by_name to obtain an ID for the new map key.

  • Updated: Fri, 6 Mar 2015 21:48 GMT