lingua-franca 0.10.1
Lingua Franca code generator
Loading...
Searching...
No Matches
org.lflang.federated.generator.FederateTargetConfig Class Reference

Subclass of TargetConfig with a specialized constructor for creating configurations for federates. More...

Inherits org.lflang.target.TargetConfig.

Public Member Functions

TargetDecl extractTargetDecl ()
 Construct a TargetDecl by extracting the fields of the given TargetConfig.
 FederateTargetConfig (LFGeneratorContext context, Resource federateResource)
 Create a configuration for a federate given a main context and the resource in which the class of the federate is specified.
Optional< TargetProperty<?, ?> > forName (String name)
 Return the target property in this target config that matches the given string.
List< TargetProperty<?, ?> > getAssignedProperties ()
 Return the target properties that have been assigned a value.
Resource getMainResource ()
 Get the main resource that is under compilation.
List< TargetProperty<?, ?> > getRegisteredProperties ()
 Return the target properties that are currently registered.
boolean isFederated ()
 Return whether this configuration is used in the context of a federated program.
boolean isSet (TargetProperty<?, ?> property)
 Return true if this target property has been set (past initialization), false otherwise.
boolean isSupported (TargetProperty p)
 Return true if the given target property is supported, false otherwise.
String listOfRegisteredProperties ()
 Return the target properties that are currently registered.
void load (GeneratorArguments args, MessageReporter err)
 Load overrides passed in as CLI arguments.
List< TargetProperty<?, ?> > loaded ()
 Return all the target properties that have been set.
void mergeImportedConfig (Resource importedResource, Resource mainResource, Predicate< TargetProperty > loadOrNot, MessageReporter messageReporter)
 If the federate that the target configuration applies to is imported, merge target properties declared in the file that it was imported from.
void register (TargetProperty<?, ?>... properties)
 Register target properties and assign them their initial value.
void reportUnsupportedTargetProperty (String name, MessageReporter.Stage2 stage2)
 Report that a target property is not supported by the current target.
void reset (TargetProperty<?, ?> property)
 Reset this target property to its initial value (and mark it as unset).
String settings ()
 Return a description of the current settings.
void update (TargetConfig config, List< KeyValuePair > pairs, Path relativePath, Predicate< TargetProperty > loadOrNot, MessageReporter err)
 Update the given configuration using the given target properties.
void validate (MessageReporter reporter)
 Validate all set properties and report issues via the given reporter.

Static Public Member Functions

static List< KeyValuePair > extractProperties (TargetConfig config)
 Extract all properties as a list of key-value pairs from a TargetConfig.
static TargetConfig getMockInstance (Target target)
 Return mock instance to use for testing, which is not tied to a generator context or a resource.

Public Attributes

final List< String > compileAdditionalSources = new ArrayList<>()
 Additional sources to add to the compile command if appropriate.
final Target target
 The target of this configuration (e.g., C, TypeScript, Python).

Static Public Attributes

static final String NOT_IN_LF_SYNTAX_MESSAGE
 Error message to use when a target property does not exist in LF syntax.

Protected Member Functions

void load (JsonObject jsonObject, MessageReporter messageReporter)
 Update this configuration based on the given JSON object.
void load (Resource resource, MessageReporter reporter)
 Load configuration from the given resource.

Protected Attributes

final Map< TargetProperty<?, ?>, KeyValuePair > keyValuePairs = new HashMap<>()
 Map from.
Resource mainResource
 The main resource that is under compilation.
final Map< TargetProperty<?, ?>, Object > properties = new HashMap<>()
 Map of target properties.

Package Functions

public< T, S extends TargetPropertyType > T get (TargetProperty< T, S > property) throws IllegalArgumentException
 Return the value currently assigned to the given target property.
public< T, S extends TargetPropertyType > T getOrDefault (TargetProperty< T, S > property)
 Return the value currently assigned to the given target property, or its default value if none been set.
public< T, S extends TargetPropertyType > KeyValuePair lookup (TargetProperty< T, S > targetProperty)
 Return the AST node that was used to assign a value for the given target property.
public< T, S extends TargetPropertyType > void set (TargetProperty< T, S > property, T value)
 Assign the given value to the given target property.

Detailed Description

Subclass of TargetConfig with a specialized constructor for creating configurations for federates.

Author
Marten Lohstroh

Constructor & Destructor Documentation

◆ FederateTargetConfig()

org.lflang.federated.generator.FederateTargetConfig.FederateTargetConfig ( LFGeneratorContext context,
Resource federateResource )

Create a configuration for a federate given a main context and the resource in which the class of the federate is specified.

Parameters
contextThe generator context.
federateResourceThe resource in which to find the reactor class of the federate.

Member Function Documentation

◆ extractProperties()

List< KeyValuePair > org.lflang.target.TargetConfig.extractProperties ( TargetConfig config)
staticinherited

Extract all properties as a list of key-value pairs from a TargetConfig.

The returned list only includes properties that were explicitly set.

Parameters
configThe TargetConfig to extract from.
Returns
The extracted properties.

◆ extractTargetDecl()

TargetDecl org.lflang.target.TargetConfig.extractTargetDecl ( )
inherited

Construct a TargetDecl by extracting the fields of the given TargetConfig.

Returns
A generated TargetDecl.

◆ forName()

Optional< TargetProperty<?, ?> > org.lflang.target.TargetConfig.forName ( String name)
inherited

Return the target property in this target config that matches the given string.

Parameters
nameThe string to match against.

◆ get()

public< T, S extends TargetPropertyType > T org.lflang.target.TargetConfig.get ( TargetProperty< T, S > property) throws IllegalArgumentException
packageinherited

Return the value currently assigned to the given target property.

◆ getAssignedProperties()

List< TargetProperty<?, ?> > org.lflang.target.TargetConfig.getAssignedProperties ( )
inherited

Return the target properties that have been assigned a value.

◆ getMainResource()

Resource org.lflang.target.TargetConfig.getMainResource ( )
inherited

Get the main resource that is under compilation.

◆ getMockInstance()

TargetConfig org.lflang.target.TargetConfig.getMockInstance ( Target target)
staticinherited

Return mock instance to use for testing, which is not tied to a generator context or a resource.

◆ getOrDefault()

public< T, S extends TargetPropertyType > T org.lflang.target.TargetConfig.getOrDefault ( TargetProperty< T, S > property)
packageinherited

Return the value currently assigned to the given target property, or its default value if none been set.

Parameters
propertyThe property to get the value of
Returns
The current value, or the initial value of none was assigned.
Parameters
<T>The Java type of the returned value.
<S>The LF type of the returned value.

◆ getRegisteredProperties()

List< TargetProperty<?, ?> > org.lflang.target.TargetConfig.getRegisteredProperties ( )
inherited

Return the target properties that are currently registered.

◆ isFederated()

boolean org.lflang.target.TargetConfig.isFederated ( )
inherited

Return whether this configuration is used in the context of a federated program.

◆ isSet()

boolean org.lflang.target.TargetConfig.isSet ( TargetProperty<?, ?> property)
inherited

Return true if this target property has been set (past initialization), false otherwise.

◆ isSupported()

boolean org.lflang.target.TargetConfig.isSupported ( TargetProperty p)
inherited

Return true if the given target property is supported, false otherwise.

◆ listOfRegisteredProperties()

String org.lflang.target.TargetConfig.listOfRegisteredProperties ( )
inherited

Return the target properties that are currently registered.

◆ load() [1/3]

void org.lflang.target.TargetConfig.load ( GeneratorArguments args,
MessageReporter err )
inherited

Load overrides passed in as CLI arguments.

Parameters
argsList of overrides that may or may not be set
errMessage reporter to report attempts to set unsupported target properties.

◆ load() [2/3]

void org.lflang.target.TargetConfig.load ( JsonObject jsonObject,
MessageReporter messageReporter )
protectedinherited

Update this configuration based on the given JSON object.

Parameters
jsonObjectThe JSON object to read updates from.
messageReporterA message reporter to report issues.

◆ load() [3/3]

void org.lflang.target.TargetConfig.load ( Resource resource,
MessageReporter reporter )
protectedinherited

Load configuration from the given resource.

Parameters
resourceA resource to load from.
reporterA message reporter for reporting errors and warnings.

◆ loaded()

List< TargetProperty<?, ?> > org.lflang.target.TargetConfig.loaded ( )
inherited

Return all the target properties that have been set.

◆ lookup()

public< T, S extends TargetPropertyType > KeyValuePair org.lflang.target.TargetConfig.lookup ( TargetProperty< T, S > targetProperty)
packageinherited

Return the AST node that was used to assign a value for the given target property.

Parameters
targetPropertyThe target property to find a matching AST node for.
<T>The Java type of values assigned to the given target property.
<S>The LF type of values assigned to the given target property.

◆ mergeImportedConfig()

void org.lflang.target.TargetConfig.mergeImportedConfig ( Resource importedResource,
Resource mainResource,
Predicate< TargetProperty > loadOrNot,
MessageReporter messageReporter )
inherited

If the federate that the target configuration applies to is imported, merge target properties declared in the file that it was imported from.

Parameters
importedResourceThe resource in which the target configuration is to be loaded from.
mainResourceThe resource in which the main reactor is specified.
loadOrNotPredicate to determine for each target property whether it should be loaded.
messageReporterAn error reporter to use when problems are encountered.

◆ register()

void org.lflang.target.TargetConfig.register ( TargetProperty<?, ?>... properties)
inherited

Register target properties and assign them their initial value.

Parameters
propertiesThe target properties to register.

◆ reportUnsupportedTargetProperty()

void org.lflang.target.TargetConfig.reportUnsupportedTargetProperty ( String name,
MessageReporter.Stage2 stage2 )
inherited

Report that a target property is not supported by the current target.

Parameters
nameThe name of the unsupported target property.
stage2The second stage an the error reporter through which to report the warning.

◆ reset()

void org.lflang.target.TargetConfig.reset ( TargetProperty<?, ?> property)
inherited

Reset this target property to its initial value (and mark it as unset).

◆ set()

public< T, S extends TargetPropertyType > void org.lflang.target.TargetConfig.set ( TargetProperty< T, S > property,
T value )
packageinherited

Assign the given value to the given target property.

Parameters
propertyThe target property to assign the value to.
valueThe value to assign to the target property.
<T>The Java type of the value.
<S>The LF type of the value.

◆ settings()

String org.lflang.target.TargetConfig.settings ( )
inherited

Return a description of the current settings.

◆ update()

void org.lflang.target.TargetConfig.update ( TargetConfig config,
List< KeyValuePair > pairs,
Path relativePath,
Predicate< TargetProperty > loadOrNot,
MessageReporter err )
inherited

Update the given configuration using the given target properties.

Parameters
configThe configuration object to update.
pairsAST node that holds all the target properties.
relativePathThe path from the main resource to the resource from which the new properties originate.
loadOrNotPredicate to determine whether a property should be loaded.
errMessage reporter for errors.

◆ validate()

void org.lflang.target.TargetConfig.validate ( MessageReporter reporter)
inherited

Validate all set properties and report issues via the given reporter.

Parameters
reporterA reporter to report errors and warnings through.

Member Data Documentation

◆ compileAdditionalSources

final List<String> org.lflang.target.TargetConfig.compileAdditionalSources = new ArrayList<>()
inherited

Additional sources to add to the compile command if appropriate.

◆ keyValuePairs

final Map<TargetProperty<?, ?>, KeyValuePair> org.lflang.target.TargetConfig.keyValuePairs = new HashMap<>()
protectedinherited

Map from.

◆ mainResource

Resource org.lflang.target.TargetConfig.mainResource
protectedinherited

The main resource that is under compilation.

◆ NOT_IN_LF_SYNTAX_MESSAGE

final String org.lflang.target.TargetConfig.NOT_IN_LF_SYNTAX_MESSAGE
staticinherited
Initial value:
=
"There is no representation of this property in the LF target property syntax"

Error message to use when a target property does not exist in LF syntax.

◆ properties

final Map<TargetProperty<?, ?>, Object> org.lflang.target.TargetConfig.properties = new HashMap<>()
protectedinherited

Map of target properties.

◆ target

final Target org.lflang.target.TargetConfig.target
inherited

The target of this configuration (e.g., C, TypeScript, Python).


The documentation for this class was generated from the following file:
  • /Users/runner/work/lingua-franca/lingua-franca/core/src/main/java/org/lflang/federated/generator/FederateTargetConfig.java