Using Generated Code

Once a model has been transformed into C++ libraries,
applications can then link these libraries. The generated C++ code is intended to be
used along with an OpenDDS C++ support library to reduce the amount of
code being generated and to simplify application development.

The snippet of code shown below illustrates how application code can use the
C++ support library and generated code to construct a DataWriter in just a few
lines of code.

intmain(intargc,char*argv[]){try{// Using support library
OpenDDS::Model::Applicationapplication(argc,argv);// Using generated code
MessengerLib::DefaultMessengerTypemodel(application,argc,argv);usingOpenDDS::Model::MessengerLib::Elements;DDS::DataWriter_varwriter=model.writer(Elements::DataWriters::writer);...}...}

Included in the files generated are MPC files
that specify how to build a C++ library representing the model from the generated source. Using
MPC, files such as makefiles or Visual Studio project files can be generated, making it easy to
build the C++ library.

The generated model library could depend on other generated model libraries.
For example, there could be an external data type library which is generated
to a different directory. This could cause a great deal of maintenance of project files, as
models change their dependencies over time. To help overcome this,
the generated model library records the paths to all of its externally referenced
model libraries in a separate MPC file. Inheriting from this paths base project
will inherit the needed settings to include the dependent model as well.