// Generated from component.y - manual changes will be lost
ifdef::sidebartoc[]
include::_Sidebar.adoc[]
endif::[]


























Component declaration
---------------------

A component declaration describes a instance of the `genom` component
model. It is defined by a unique name (an identifier) that also defines an
IDL scope for any embedded types.

****
[horizontal]
(5) `*component             ::=*` ::
   `"component"` <<grammar#dotgen-rule-component-name,`component-name`>> <<grammar#dotgen-rule-component-body,`component-body`>> `";"`
(6) `*component-name        ::=*` ::
   <<grammar#dotgen-rule-identifier,`identifier`>>
(7) `*component-body        ::=*` ::
   `[` `"{"` <<grammar#dotgen-rule-exports,`exports`>> `"}"` `]`
****

Components export objects from the `genom` component model, namely:
link:ids{outfilesuffix}[IDS], link:task{outfilesuffix}[tasks],
link:port{outfilesuffix}[ports], link:service{outfilesuffix}[attributes] or
link:service{outfilesuffix}[services].

Components may also define new types via IDL statements. Any such types are
defined within the component scope.

****
[horizontal]
(8) `*exports               ::=*` ::
   `{` <<grammar#dotgen-rule-export,`export`>> `}`
(9) `*export                ::=*` ::
   <<grammar#dotgen-rule-idl-statement,`idl-statement`>> +
                              `|` <<grammar#dotgen-rule-property,`property`>> +
                              `|` <<grammar#dotgen-rule-ids,`ids`>> +
                              `|` <<grammar#dotgen-rule-task,`task`>> +
                              `|` <<grammar#dotgen-rule-port,`port`>> +
                              `|` <<grammar#dotgen-rule-attribute,`attribute`>> +
                              `|` <<grammar#dotgen-rule-service,`service`>>
****















































A number of properties can be attached to a component:

****
[horizontal]
(10) `*component-property    ::=*` ::
   `(` `"doc"` <<grammar#dotgen-rule-string-literals,`string-literals`>> +
                              `|` `"version"` <<grammar#dotgen-rule-string-literals,`string-literals`>> +
                              `|` `"lang"` <<grammar#dotgen-rule-string-literals,`string-literals`>> +
                              `|` `"email"` <<grammar#dotgen-rule-string-literals,`string-literals`>> +
                              `|` `"requires"` <<grammar#dotgen-rule-string-list,`string-list`>> +
                              `|` `"codels-require"` <<grammar#dotgen-rule-opt-private,`opt-private`>> <<grammar#dotgen-rule-string-list,`string-list`>> +
                              `|` `"clock-rate"` <<grammar#dotgen-rule-const-expr,`const-expr`>> <<grammar#dotgen-rule-time-unit,`time-unit`>> +
                              `|` `"provides"` <<grammar#dotgen-rule-interface-list,`interface-list`>> +
                              `|` `"uses"` <<grammar#dotgen-rule-interface-list,`interface-list`>> `)` `";"`
(11) `*opt-private           ::=*` ::
   `[` `"private"` `]`
****

+doc+::
A string that describes the functionality of the component.

+version+::
The component version number, as a string.

+lang+::
The programming language of the codels interface. At the moment, only "c" is
supported.

+email+::
A string containing the contact e-mail address to reach support for the
component.

+requires+::
A list of dependencies of the component (see
link:pragma{outfilesuffix}#pragma_requires[#pragma requires]). Each
string should contain a package name in `pkg-config` format.

+codels-requires+::
A list of dependencies of the codels. Each string should contain a package
name in `pkg-config` format. The `private` keyword mark the following
dependencies as not being inherited when defined in an an interface. For a
component, this has no effect.

+clock-rate+::
The period of the internal component clock. It is usually not necessary to
define it explicitly. If the component defines periodic task, the component
clock period will be automatically computed as the greatest common divisor
of the period of all periodic tasks.

+provides+::
A list of interfaces (see link:interface{outfilesuffix}[Interface
declaration]) that the component implements. All objects from the interface
are imported as-is into the component description. Ports and services may be
further refined once imported, typically by defining codels (see
link:codel{outfilesuffix}[Codel declaration]) that implement the services.

+uses+::
A list of interfaces (see link:interface{outfilesuffix}[Interface
declaration]) that the component uses. Ports are imported in the opposite
direction (e.g. a `port out` is imported as a `port in`). Services are
imported as `remote` objects that can be accessed via codel parameters
(see link:codel{outfilesuffix}[Codel declaration]). Other objects are
imported as-is.

=== Example

This would define an empty component with no service and no functionality:

[source,C]
----
component foo {
  version     "1.0";
  email       "me@example.com";
  lang        "c";
  require     "genom3 >= 2.99.20";
};
----





































































































// eof
