.. include:: vars.rst .. _section-working-with-types: Working with Types ------------------ To introduce new types in your project, right-click on the **Types** node in the Tree View and add one of the top-level types: .. figure:: static/top_level_types.png :alt: Selecting a top-level type :name: Figure_top_level_types :align: center :figwidth: 90% :width: 398px :height: 431px For more information on data types, see :link_um_intro_type_system:`Introduction to the Type System, in the RTI Connext DDS Core Libraries User's Manual <>`. In this example, we are adding two structures, NewStruct1 and NewStruct2: .. figure:: static/struct_declaration.png :alt: Adding a structure :name: Figure_struct_declaration :align: center :figwidth: 90% The pop-up shown above will guide you in creating a new type. You can choose the Name and, optionally, the Base Type. You can also select one of the annotations presented on the screen. By default, the new object will be added to the last XML file used, but you can use the drop-down menu to select any XML file or use the **New...** button to add new XML files to your |SD| project. Once you have added the top level, go to the Structured view and populate the new type using the |plus_icon| button: .. figure:: static/populate_new_type.png :alt: Populating a new structure :name: Figure_populate_new_type :align: center :figwidth: 100% A pop-up will help you select the types and the right values. In this example, we are adding: - A uint8 named 'member1' and a bounded (255) keyed string named 'member2' to the NewStruct1 structure. - An octet named 'member1' and a char8 named 'member2' to the NewStruct2 structure. .. figure:: static/member_declaration.png :alt: Declaring members in a structure :name: Figure_member_declaration :align: center :figwidth: 90% The **Types** tab allows you to explore the types in three ways: - Structured view - XML view - IDL view .. Tip:: The :link_xtypes_guide_intro:`RTI Connext DDS Core Libraries Extensible Types Guide <>` has a mapping of type names in IDL 4.2. (For example, you may want to know that a ``long`` is called ``int32`` in IDL 4.2). The Structured view is the simplest way to explore and modify the types in your system. The |expand_icon| button allows you to go as deep as needed when exploring types. - In the **Item** column, you will see the name and type of a specific element of your type. - In the **Annotations** column, you can see things like the ID of a member; you can see if the member is a key, or if it is an optional or extensible member. - The **Location** column will indicate in which file the member is defined, in case you have a project with multiple XML files. - The **Edit** column contains buttons to alter the selected item. Container objects such as structs, unions, and modules have a |plus_icon| button to add a child to them. You can use |move_up_down_icon| to rearrange all the objects. Currently you cannot move elements in or out of a container (e.g., moving a struct out of a module is not currently supported). To do that, you can always switch to the XML view and modify the XML manually. .. figure:: static/new_string_member.png :alt: Adding a string to a structure :name: Figure_new_string_member :align: center :figwidth: 90% The XML view shows the types in XML format. You can highlight a specific member by selecting it in the tree on the left panel: .. figure:: static/new_struct_xml_tab.png :alt: Seeing the new structure in the XML tab :name: Figure_new_struct_xml_tab :align: center You can also click on |edit_xml_icon| to edit your XML file manually. All the changes will be reflected in the Structured view. Finally, the IDL tab shows you the IDL definition of the type: .. figure:: static/idl_tab.png :alt: Seeing the IDL definition :name: Figure_idl_tab :align: center You can download the IDL type using the |download_idl_icon| button. (After you click this button, a dialog box opens; click the "Download" link at the bottom.)