Skip to the main content.

Did you know?

 

RTI is the world’s largest DDS supplier and Connext is the most trusted software framework for critical systems.

Tiered-Support-Plan-DatasheetTiered Support Plans

Our Professional Services team brings extensive experience to train, problem-solve, mentor, and accelerate customer success.

Learn more

Developers

From downloads to Hello World, we've got you covered. Find all of the tutorials, documentation, peer conversations and inspiration you need to get started using Connext today.

Try the Connectivity Selection Tool ⇢

Resources

RTI provides a broad range of technical and high-level resources designed to assist in understanding industry applications, the RTI Connext product line and its underlying data-centric technology.

Company

RTI is the largest software framework company for autonomous systems. The company’s RTI Connext product enables intelligent architecture by sharing information in real time, making large applications work together as one.

News & Events
Cooperation

2 min read

Code Generator: Experiment with New Features

Code Generator: Experiment with New Features

In previous posts we explained how RTI’s new code generator saves you time with faster code generation. It’s now the default code generator in RTI Connext DDS 5.2.0, and it includes a number of other new features we think you will like.

Did you know that our new code generator is much better at detecting syntax errors?

For instance, the code generator will tell you if you forgot to define a type, showing better error messages. And this is just one example.

Do you want to generate only the type files and your project files without overwriting your publisher/subscriber files?

Try the autoGenFiles option.

Do you want even more control over which files you generate?

The new create and update <typefiles | examplefiles | makefiles> options are your solution.

Are you compiling dynamically?

Generate your project files using the shareLib option. It will link your application with RTI’s core dynamic libraries.

Do you want to share private IDLs without showing their actual content?

Try the new obfuscate option.

Are you using unbounded sequences?

Try the unboundedSupport option. Read this blog post to learn more about this new feature.

It’s all easier than ever with the Apache Velocity (VLT) templates. You can check the predefined set of variables available in RTI_rtiddsgen_template_variables.xlsx, located in the Code Generator documentation folder.

As a simple example, imagine you want to generate a new method that prints whether each member of a type is an array or a sequence. It could also print the corresponding dimensions or size. For example, consider this type:

module Mymodule{
    struct MyStruct{
        long longMember;
        long arrayMember [2][100];
        sequence sequenceMember;
        sequence arrayOfSequenceMember[28];
    };
};

Our desired print function would be something like this:

void MyModule_MyStruct_specialPrint(){
    printf(" longMember \n");
    printf(" arrayMember is an array [2, 100] \n ");
    printf(" sequenceMember is a sequence <2> \n");
    printf(" arrayOfSequenceMember is an array [28] is a sequence <5> ");
}

Implementing this is straightforward. You would just need to create a few macros in the code generator templates to generate the above code. We start with the main method, which would be something like this:

void ${node.nativeFQName}_specialPrint(){
    #specialPrint ($node)
}

This method calls to specialPrint macro. That macro iterates within the struct members and print whether they are an array or a sequence

#macro (specialPrint $node)
#*--*##foreach($member in $node.memberFieldMapList)
print("$member.name #isAnArray($member) #isASeq($member) \n");
#*--*##end

We just need to define two auxiliary macros to check each case.

#macro (isAnArray $member)
#if($member.dimensionList) is an array $member.dimensionList #end
#end
#macro (isASeq $member)
#if($member.seqSize) is a sequence &lt;$member.seqSize&gt; #end
#end

If you need more information about supported and new features available in Code Generator, check out the Getting Started Guide or the online documentation.