Next: , Previous: , Up: Using Dezyne in your C++ environment   [Contents]


3.2.2 Including and configuring the dzn runtime

Before the generated code can be used in combination with the event loop you just created, you must also download the Dezyne runtime to use in your project. The runtime can be found in Window / Show Views / Runtime. Once there, select the programming language you want to use and right click to download the associated files. (Just like code generation, downloading the runtime can be done by use of the command line client and a makefile; see Breakdown of example makefile automating Dezyne features. This approach can be helpful in an environment that makes use of version control.)

images/explore

The minimum required components of the Dezyne runtime that must be included in your application are the actual runtime and the Dezyne locator. The Dezyne runtime is a library of primitives used by the generated code; the locator is a mechanism to inject dependencies into a Dezyne system and its components. The runtime is an example of such a dependency that can be injected into the locator.

Their respective files that must be included are runtime.hh and locator.hh, found in the dzn subfolder. The inclusion of the runtime files should be done using ‘ <> ’ include tags as opposed to ‘ ”” ’ include tags; this is because of how code is generated from Dezyne models. This has some implications for compilation but those will be covered later in Compiling your application.

When the files are included you can instantiate the Dezyne locator and runtime objects in your created main. The minimal setup that does all of the above will look as follows:

#include <dzn/runtime.hh>
#include <dzn/locator.hh>

int main(int argc, char* argv[]) {
  dzn::locator loc;
  dzn::runtime rt;

  loc.set(rt);

  while(true) {
    // Dezyne interaction
  }
}

Near the end of this section, in some extra materials you will find a section dedicated to an in-depth look at the Dezyne runtime with more information on how you can customize some of the components of the runtime to your liking: Using the Dezyne locator to distribute runtime objects.


Next: , Previous: , Up: Using Dezyne in your C++ environment   [Contents]