Code Generator

5.Code Generator

The major part of the development of Uli SDK is to use Code Generators to generate C++ codes for data records, messages, services, and comp apps. This process significantly reduces development time and cost. Here are the brief descriptions of the process:

  1. Generate Data Records, the data structures of the messages.
  2. Generate Messages, messages used in communications between clients and services.
  3. Generate Services, services include a state machine, a set of input and output messages, internal event, and configurable parameters.
  4. Generate comp apps, applications includes one or more comps that host services to perform related functionalities.

The code generators are written in Java classes located in the uli_sdk/codegen directory. Before using the code generators, you need to run make to build the Java classes. Three make targets:

  1. make: make the code generator java classes.
  2. make clean: clean up the java classes.
  3. make clean_clean: clean up the java and output directories of the generated codes: records, messages, services, and apps.

For ease of use, there are shell scripts created for each of the generator process:

  1. gen_record.sh generate data records, output codes are placed in codegen/records.
  2. gen_message.sh generate messages, output codes are placed in codegen/messages.
  3. gen_service.sh generate services, output codes are placed in codegen/services.
  4. gen_app.sh generate comp apps, output codes are places in codegen/apps.

Here are the commands for generating codes:

% ./gen_record.sh <path-to-record-gen-json-file>
% ./gen_message.sh <path-to-message-gen-json-file>
% ./gen_servivce.sh <path-to-service-gen-json-file>
% ./gen_app.sh <path-to-app-gen-json-file>

The JSON file is used to specify how to generate codes. Sections below describe in details of the JSON file. You can find them in the json directories of the apps, services, and messages.