Home
Categories
Dictionary
Glossary
Download
Project Details
Changes Log
What Links Here
FAQ
License

Switch type


A switch type allows to define a type as one of a list of specified types. For example:
      <types>
         <simpleType name="int" baseType="int" />
         <simpleType name="bool" baseType="boolean" />
         <switchType name="theSwitch" types="int bool" />
      </types>
Each of the possible types is specified by its associated index. For example in the case above, int would have the index 0, and bool the index 1.

Setting values for switch datas

To set the value you can used the index of the type in the types declaration, of the type name, or the type:
      Data.Switch data = (Data.Switch) service.getData(<the data name>);
      data.setValue(<the type name>, value);      
      // or
      data.setValue(<the type index>, value);   
      // or
      data.setValue(<the type>, value);         
For example, for this types declaration:
      <types>
         <simpleType name="int" baseType="int" />
         <simpleType name="bool" baseType="boolean" />
         <switchType name="theSwitch" types="int bool" />
      </types>
If you want to set a boolean value for the switch type, you can do:
      Type boolType = module.getType("bool");
      Data.Switch data = (Data.Switch) service.getData(<the data name>);
      data.setValue("bool", true);      
      // or
      data.setValue(1, true);   
      // or
      data.setValue(boolType, true);         

See also


Categories: concepts

Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence