No I am afraid this is not currently possible. However the just approved IDL 4.0 specification added an annotation @default intended to be used for this purpose. So if there is enough interest from the users we could pick this up and offer that feature. As of now this is not planned.
ah thanks bobg - I had seen this feature, I think in my head I was expecting there to also be constructors that have default parameters as well so if you add a new parameter to a topic you don't need to update all the code that constructs that topic data... I Assume this is not available?
I don't think that's available. It's a feature implemented within IDL which, of course, isn't really realized until you update/generate new support functions with rtiddsgen.
Hmm, not sure what is meant by "adding a new parameter to a topic". If you mean you modify the data type definition (used by a Topic) by adding/removing a member of the data type (which is usually done by modifying the IDL file containing your type definition), then as Bob wrote, you have to update the type support/plugin code that is generated using rtiddsgen on your idl file.
That's an independent concept than using @default annotations to provide default values for members of a datatype.
Using "@default" annotations, you can now define what the default values of members of a datatype are initialized to via the IDL definition file...and since adding/changing annotations in an IDl file is fundamentally changing a datatype definition, you have to regenerate the type source files using rtiddsgen as previously stated.
But, by doing so, depending on the programming language used, and if you use the "-constructor" argument for "-language C++", then the constructor for the datatype class...or using the <foo>TypeSupport::create_data() function, the object constructed/returned should have the members initialized with their specified default values.
Hello,
No I am afraid this is not currently possible. However the just approved IDL 4.0 specification added an annotation
@default
intended to be used for this purpose. So if there is enough interest from the users we could pick this up and offer that feature. As of now this is not planned.Regards,
Gerardo
Since this was posted > 5 years ago - is there any update on this? - can we do default parameters in 2021? (Using RTI DDS 6.1.0)
This is supported in Connext 6. I don't know, however, exactly when it was introduced.
https://community.rti.com/static/documentation/connext-dds/6.1.0/doc/manuals/connext_dds_professional/extensible_types_guide/index.htm#extensible_types/DefaultValue.htm#3.3.1_@default_annotation%3FTocPath%3D3.%2520Type%2520System%2520Enhancements%7C3.3%2520Default%2520Value%7C3.3.1%2520%2540default%2520annotation%7C_____0
Regards,
Bob
ah thanks bobg - I had seen this feature, I think in my head I was expecting there to also be constructors that have default parameters as well so if you add a new parameter to a topic you don't need to update all the code that constructs that topic data... I Assume this is not available?
I don't think that's available. It's a feature implemented within IDL which, of course, isn't really realized until you update/generate new support functions with rtiddsgen.
Hmm, not sure what is meant by "adding a new parameter to a topic". If you mean you modify the data type definition (used by a Topic) by adding/removing a member of the data type (which is usually done by modifying the IDL file containing your type definition), then as Bob wrote, you have to update the type support/plugin code that is generated using rtiddsgen on your idl file.
That's an independent concept than using @default annotations to provide default values for members of a datatype.
Using "@default" annotations, you can now define what the default values of members of a datatype are initialized to via the IDL definition file...and since adding/changing annotations in an IDl file is fundamentally changing a datatype definition, you have to regenerate the type source files using rtiddsgen as previously stated.
But, by doing so, depending on the programming language used, and if you use the "-constructor" argument for "-language C++", then the constructor for the datatype class...or using the <foo>TypeSupport::create_data() function, the object constructed/returned should have the members initialized with their specified default values.