Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

GObj

Gobjs are modular components that form the building blocks of Yuneta applications. The creation and configuration of gobjs are flexible, allowing developers to instantiate individual gobjs or entire hierarchies using structured APIs and configurations.


GObj Creation APIs

1. Creating Individual Gobjs

The primary APIs for creating gobjs include:

APIDescription
gobj_createCreates a GObj with the specified name, GClass, and attributes.
gobj_create2Similar to gobj_create, but allows specifying flags to control the GObj’s behavior.
gobj_create_yunoCreates the root GObj of a Yuno, typically used to initialize the application.
gobj_create_serviceCreates a service GObj that exposes commands and events for interaction with other components.
gobj_create_default_serviceCreates a default service GObj with autostart enabled and autoplay disabled.
gobj_create_volatilCreates a volatile GObj, which is not persisted.
gobj_create_pure_childCreates a pure child GObj that directly sends events to its parent.

2. Creating GObj Trees

Entire hierarchies of gobjs can be created using structured configurations:


GObj Flags (gobj_flag_t)

Flags control the behavior and characteristics of gobjs during their creation. They can be combined to define multiple properties.

FlagValueDescription
gobj_flag_yuno0x0001Marks the GObj as a Yuno root.
gobj_flag_default_service0x0002Sets the GObj as the default service for the Yuno, with autostart enabled.
gobj_flag_service0x0004Indicates that the GObj is a service, exposing public commands and events.
gobj_flag_volatil0x0008Marks the GObj as volatile, meaning it is not persistent.
gobj_flag_pure_child0x0010Sets the GObj as a pure child, sending events directly to its parent.
gobj_flag_autostart0x0020Automatically starts the GObj after creation.
gobj_flag_autoplay0x0040Automatically plays the GObj after creation.
gobj_flag_top_service0x0080Interface (events, attrs, commands, stats) available to external access.

JSON Tree Configuration for GObj Creation

GObj hierarchies can be defined using JSON structures, making it easy to specify attributes, children, and behavioral flags. A typical JSON tree structure includes:

KeyDescription
gclassThe name of the GClass for the GObj.
nameThe name of the GObj.
default_serviceBoolean indicating if the GObj is the default service.
as_serviceBoolean indicating if the GObj should act as a service.
autostartBoolean indicating if the GObj should start automatically.
autoplayBoolean indicating if the GObj should play automatically.
disableBoolean indicating if the GObj should be disabled.
pure_childBoolean indicating if the GObj is a pure child.
kwA dictionary of attributes to configure the GObj.
childrenA list of child GObjs with their respective configurations.

Hierarchy Rules:

  1. If a subscriber is not specified, it defaults to the parent GObj.

  2. If there is only one child in children, it is automatically set as the “bottom” GObj.


Rules for Proper GObj Usage


Benefits of GObj Creation APIs