ActorSimulation.CAFGenerator (GenServerVirtualTime v0.6.0)

Copy Markdown View Source

Generates C++ Actor Framework (CAF) code from ActorSimulation DSL.

This module translates ActorSimulation definitions into production-ready CAF C++ projects with:

  • Typed actor implementations
  • Callback interfaces for custom behavior
  • CMake build configuration with Conan
  • CI pipeline for automated testing
  • Complete documentation

Key Features

  • Callback Modules: Generate callback interfaces so users can add custom behavior WITHOUT touching generated code
  • Type-Safe: Uses CAF's typed actors for compile-time message checking
  • Modern C++17: Clean, idiomatic C++ code
  • Production Ready: Includes CI/CD pipeline and build system

Example

simulation = ActorSimulation.new()
  |> ActorSimulation.add_actor(:sender,
      send_pattern: {:periodic, 100, :msg},
      targets: [:receiver])
  |> ActorSimulation.add_actor(:receiver)

{:ok, files} = CAFGenerator.generate(simulation,
  project_name: "MyActors",
  enable_callbacks: true)

CAFGenerator.write_to_directory(files, "caf_output/")

Summary

Functions

Generates complete CAF project files from an ActorSimulation.

Writes generated files to a directory.

Functions

generate(simulation, opts \\ [])

Generates complete CAF project files from an ActorSimulation.

Options

  • :project_name (required) - Name of the C++ project
  • :enable_callbacks (default: true) - Generate callback interfaces
  • :caf_version (default: "1.0.2") - CAF version for Conan

Returns

{:ok, files} where files is a list of {filename, content} tuples

write_to_directory(files, output_dir)

Writes generated files to a directory.

Creates the directory and all subdirectories as needed.