Ember
Loading...
Searching...
No Matches
System Architecture

Overview

Ember follows a clean architectural separation between core logic and user interface components. This design enables:

  • Testability: Core logic can be unit tested without UI dependencies
  • Portability: EmberCore can be used with different UI frameworks
  • Maintainability: Clear boundaries between components

Component Diagram

┌─────────────────────────────────────────────────────────────────┐
│ EmberForge │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Panels │ │ Tabs │ │ Dialogs │ │
│ │ (MainPanel, │ │(FileExplorer│ │(Preferences,│ │
│ │ SidePanel) │ │ Properties) │ │ParserConfig)│ │
│ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
│ │ │ │ │
│ ┌──────┴────────────────┴────────────────┴──────┐ │
│ │ MainFrame (wxFrame) │ │
│ └───────────────────────┬───────────────────────┘ │
│ │ │
│ ┌───────────────────────┴───────────────────────┐ │
│ │ App (wxApp) │ │
│ └───────────────────────────────────────────────┘ │
└──────────────────────────┬──────────────────────────────────────┘
│ Uses
┌──────────────────────────┴──────────────────────────────────────┐
│ EmberCore │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Core │ │ Parsers │ │ Adapters │ │
│ │ (Node, Tree,│ │(LibXML, XML │ │(DirectTree, │ │
│ │ Blackboard) │ │ Serializer) │ │ NodeAdapter)│ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Interfaces │ │ Types │ │ Utils │ │
│ │(ITreeNode, │ │(Color, Rect,│ │ (Logger, │ │
│ │ITreeFactory)│ │ String) │ │SpdlogManager│ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
└─────────────────────────────────────────────────────────────────┘

EmberCore

EmberCore is the framework-agnostic core library containing all behavior tree logic. It has no dependencies on wxWidgets or any GUI framework.

Core Module

The Core module contains the fundamental data structures:

Class Purpose
Node Represents a single behavior tree node
BehaviorTree Container for a complete behavior tree with metadata
BehaviorTreeValidator Validates tree structure and constraints
BlackboardEntry Key-value storage for tree communication
Blackboard Collection of blackboard entries

Parsers Module

The Parsers module handles XML serialization:

Class Purpose
LibXMLBehaviorTreeParser Parses XML files into behavior trees
LibXMLBehaviorTreeSerializer Serializes trees back to XML
ParserConfig Configuration for parsing behavior
ParserProfile Named configuration presets
ConfigManager Manages parser configurations
BehaviorTreeProject Multi-file project management
ProjectManager Singleton for active project handling

Adapters Module

The Adapters module provides an abstraction layer between core data and visualization:

Class Purpose
ITreeNode Abstract interface for tree nodes
ITreeStructure Abstract interface for tree traversal
ITreeFactory Factory interface for node creation
DirectTreeAdapter Adapts BehaviorTree to ITreeStructure
NodeAdapter Adapts Node to ITreeNode

Interfaces Module

Pure virtual interfaces for extensibility:

Interface Purpose
ITreeNode Node access abstraction
ITreeStructure Tree structure abstraction
ITreeFactory Node creation abstraction
IParseProgressCallback Progress reporting for parsing

Types Module

Framework-agnostic type definitions:

Type Purpose
String std::string alias
Point 2D point (x, y)
Size 2D dimensions (width, height)
Rect Rectangle (position + size)
Color RGBA color representation

Utils Module

Utility classes:

Class Purpose
Logger Logging infrastructure
SpdlogManager spdlog integration (optional)

EmberForge

EmberForge is the wxWidgets-based GUI application that provides the visual interface for Ember.

Application Module

Class Purpose
App wxApp subclass, application entry point
MainFrame Main window, manages layout and menus

Panels Module

Dockable panels for the workspace:

Class Purpose
Panel Base class for all panels
SidePanel Base class for side panels with tabs
MainPanel Central panel containing scenes
LeftSidePanel Left dock (file explorer, hierarchy)
RightSidePanel Right dock (properties)
BottomPanel Bottom dock (logs, output)

Tabs Module

Tab components for panel content:

Class Purpose
ITab Tab interface
FileExplorerTab File browser tab
SceneHierarchyTab Tree hierarchy view
PropertiesTab Node property editor
LogTab Log message viewer
ToolTab Tool palette

Scenes Module

Scene system for tree visualization:

Class Purpose
IScene Scene interface
BehaviorTreeScene Behavior tree visualization scene
SceneContainer Manages multiple scenes
TreeVisualization Canvas for rendering trees

Dialogs Module

Modal dialogs:

Class Purpose
PreferencesDialog Application preferences
ParserConfigDialog Parser configuration
BehaviorTreeProjectDialog Project management
ProjectManagerDialog Project selection
LoadingDialog Progress indicator

Utils Module

UI utilities:

Class Purpose
AppPreferences Persistent application settings
BehaviorTreeConfig Tree visualization settings
WxConverters Type conversion utilities
CustomTabArt Custom tab appearance

Data Flow

Loading a Behavior Tree

1. User selects File > Open
2. MainFrame calls LibXMLBehaviorTreeParser::ParseFile()
3. Parser returns ParseResult with BehaviorTree
4. MainFrame creates DirectTreeAdapter wrapping the tree
5. BehaviorTreeScene receives the adapter
6. TreeVisualization renders via ITreeStructure interface

Editing a Node

1. User selects node in TreeVisualization
2. Selection callback notifies MainFrame
3. MainFrame updates PropertiesTab with node data
4. User edits property in PropertiesTab
5. PropertiesTab updates Node via ITreeNode interface
6. TreeVisualization refreshes display

Saving a Project

1. User selects File > Save Project
2. MainFrame calls ProjectManager::SaveProject()
3. ProjectManager iterates project files
4. LibXMLBehaviorTreeSerializer writes each file
5. Project configuration saved to JSON

Design Patterns

Adapter Pattern

The Adapters module implements the Adapter pattern to decouple EmberCore data structures from visualization code. This allows the same visualization code to work with different tree implementations.

Factory Pattern

ITreeFactory and DefaultTreeFactory implement the Factory pattern for creating tree nodes, enabling customization of node creation.

Singleton Pattern

ConfigManager and ProjectManager use the Singleton pattern for global access to configuration and project state.

Observer Pattern

Event callbacks (NodeSelectionCallback, TreeSelectionCallback) implement a simplified Observer pattern for UI updates.

Template Method Pattern

Panel and SidePanel use the Template Method pattern with virtual hooks (CreateLayout, CreateToolbar) for customization by subclasses.

Thread Safety

EmberCore is designed for single-threaded use. All UI operations in EmberForge occur on the main thread. Background operations (like parsing large files) should use wxWidgets threading primitives and communicate results via events.

See Also