Table 9.5. Predefined source element types
Source Type | Description | Icon |
---|---|---|
ps:dir | Maps directly to a directory. |
![]() |
ps:file | Maps directly to a file. |
![]() |
ps:fragment | Represents a file fragment to be appended to another file. |
![]() |
ps:pvsclxml | Maps directly to an XML document containing variation points (conditional parts) using pvSCL expressions. |
![]() |
ps:pvscltext | Maps directly to a text document containing variation points (conditional parts) using pvSCL expressions. |
![]() |
ps:flagfile | Represents a file that can hold flags such as a C/C++ header file containing preprocessor defines. |
![]() |
ps:makefile | Represents a make (build) file such as GNU make files containing make file variables. |
![]() |
ps:classaliasfile | Represents a file containing an alias e.g. for a C++ class that can be concurrently used in the same place in the class hierarchy. |
![]() |
ps:symlink | Maps directly to a symbolic link to a file. |
![]() |
The following sections provide detailed descriptions of the family model source element types that are relevant for the standard transformation (see Section 6.3.2, “ Standard Transformation ” ).
All file-related source element types derived from element type
ps:destfile
specify the location of a file using the two attributes
dir
and
file
. Using the standard transformation the corresponding file is
copied from<ConfigSpaceInputDir>/<dir>/<file>
to
<ConfigSpaceOutputDir>/<dir>/<file>
. Source element
types derived fromps:srcdestfile
optionally can specify a different source
file location using the attributessrcdir
and
srcfile
.
If one or both of these attributes are not used, the values fromdir
and
file
are used instead. The source file location is relative to the
<ConfigSpaceInputDir>
.
dir
[ps:directory]
|
srcdir?
[ps:directory]
|
This source element type is used to copy a directory from the
source location to the
destination location. All included subdirectories will also copied. The
optional attribute
srcdir
ist used for directories that are located in a different place
in the source hierarchy and/or have a different name.
dir
[ps:directory]
|
file
[ps:path]
|
type
[ps:filetype]
|
srcdir?
[ps:directory]
|
srcfile?
[ps:path]
|
srcurl?
[ps:url]
|
This source element type is used for files that are used without
modification. The
source file is copied from the source location to the destination
location. The optional
attributes
srcdir
and
srcfile
are used for files
that are located in a different place in the source hierarchy and/or
have a different
source file name.
The optional attribute srcurl
is used to specify a source directory
with an url. This supports basic authentification. If this srcurl property is
set srcdir is ignored. The standard transformation supports the protocls http
and https.
The value of attribute
type
should be
def
or
impl
when the file contains
definitions (e.g. a C/C++ Header) or implementations. For most other files the
type
misc
is appropriate.
Type | Description |
---|---|
impl
| This type is used for files containing an implementation, e.g. .cc or .cpp files |
def
| This type is used for files containing declarations, e.g. C++ header files. In the context of ps:classalias calculations this information is used to determine the include files required for a given class. |
misc
| This type is used for any file that does not fit into the other categories. |
app
| This type is used for the main application file. |
undefined
| This type is for files for which no special meaning and/or action is defined. |
dir
[ps:directory]
|
file
[ps:path]
|
type
[ps:filetype]
|
srcdir?
[ps:directory]
|
srcfile?
[ps:path]
|
mode
[ps:insertionmode]
|
content?
[ps:string]
|
encoding?
[ps:encoding]
|
This source element type is used to append text or another file to
a file. The content
is taken either from a file if
srcdir
and
srcfile
are given, or from a string if
content
is given. If taken from a string, attribute encoding
can be used to specify the character encoding of the string content. The attribute
mode
is used to specify the point at which this content is appended
to the file, i.e.before
or
after
the child parts of the current node's parent part are visited. The
default value isbefore
.
dir
[ps:directory]
|
file
[ps:path]
|
type
[ps:filetype]
|
srcdir?
[ps:directory]
|
srcfile?
[ps:path]
|
conditionname?
[ps:string]
|
copycondition?
[ps:boolean]
|
valuesubstitution?
[ps:boolean]
|
This source element type is used to copy an XML document and
optionally to save the
copy to a file. Special conditional attributes on the nodes of the XML
document are
dynamically evaluated to decide whether this node (and its subnodes) are
copied into the
result document. The name of the evaluated condition attribute is
specified using the
attribute
conditionname
and defaults to
pv:condition
. If the attribute
copycondition
is
not set tofalse
, the condition attribute is copied into the target
document as well. If the attributevaluesubstitution
is set to
true
, the content of all attribute values of the XML document will
be handled asSection 9.5.5, “
ps:pvscltext
”
.
The condition itself has to be a valid pvSCL expression. For details on writing pvSCL expressions, see Section 9.7, “Expression Language pvSCL” .
In the example document given below after processing with an
ps:pvsclxml
transformation, the resulting XML document only
contains an introductory chapter if the corresponding featureWithIntroduction
is selected.
Example 9.1. A sample conditional document for use with the ps:pvsclxml transformation
<?xml version='1.0'?> <text xmlns:pv="http://www.pure-systems.com/purevariants"> <chapter pv:condition="WithIntroduction"> This is some introductory text. </chapter> <chapter> This text is always in the resulting xml output. </chapter> </text>
A special XML node is supported for calculating and inserting the
value pvSCL
expression. The name of this node is
pv:eval
(namespace
"pv" is defined as "http://www.pure-systems.com/purevariants"). Thepv:eval
node is replaced by the calculated value in the result
document.
Example 9.2. Example use of pv:eval
Source document: <?xml version='1.0'?> <version xmlns:pv="http://www.pure-systems.com/purevariants"> <pv:eval>Version->version</pv:eval> </version> Result document: <?xml version='1.0'?> <version xmlns:pv="http://www.pure-systems.com/purevariants"> 1.0 </version>
dir
[ps:directory]
|
file
[ps:path]
|
type
[ps:filetype]
|
srcdir?
[ps:directory]
|
srcfile?
[ps:path]
|
encoding?
[ps:encoding]
|
This source element type is used to copy a text document and optionally to save the copy to a file. Special statements in the text document are evaluated to decide which parts of the text document are copied into the result document, or to insert additional text. If no text document encoding is given, then UTF-8 encoding is assumed.
The statements (macro-like calls) that can be used in the text document are listed in the following table.
Statement | Description |
---|---|
PVSCL:IFCOND(
condition
)
|
Open a new conditional text block. The text in
the block is included in the resulting text output if the given
condition
evaluates to true. The opened conditional text block has to be closed by
a
PVSCL:ENDCOND
call.
|
|
This macro can be used after a
PVSCL:IFCOND
or
PVSCL:ELSEIFCOND
call. If the condition of the preceding
PVSCL:IFCOND
or
PVSCL:ELSEIFCOND
is failed, the condition of this
PVSCL:ELSEIFCOND
is checked. If it evaluates to true,
the enclosed text is included in the resulting text output. |
PVSCL:ELSECOND
|
This macro can be used after a
PVSCL:IFCOND
or
PVSCL:ELSEIFCOND
call. If the condition of the preceding
PVSCL:IFCOND
or
PVSCL:ELSEIFCOND
is failed, the enclosed text is included in the
resulting text output. |
PVSCL:ENDCOND
|
Close a conditional text block. This macro is
allowed after a
PVSCL:IFCOND
,
PVSCL:ELSEIFCOND
, or
PVSCL:ENDCOND
call.
|
PVSCL:EVAL(
expression
)
| Evaluate the given pvSCL expression and insert the value of the expression into the result document. |
These statements can occur everywhere in the text document and are
directly matched,
i.e. independently of the surrounding text. The conditions of
PVSCL:IFCOND
and
PVSCL:ELSEIFCOND
and the
expression ofPVSCL:EVAL
are the same as the conditions
described for source element typeps:pvsclxml
(see
Section 9.5.4, “
ps:pvsclxml
”
for details), except for a list of comma-separated flags
that can follow the pvSCL code. Following flags are supported.
Flag | Description |
---|---|
LINE
| Clear or remove the line containing the pvSCL
conditional text statement. Example for a multi-line
if-statement utilizing flag LINE :
/* PVSCL:IFCOND(Temperature,LINE) */ initializeSensor("temperature",PVSCL:EVAL(Temperature->max)); /* PVSCL:ELSECOND */ disableSensor("temperature"); /* PVSCL:ENDCOND */Result if feature Temperature is selected: initializeSensor("temperature",60);Example for a single-line if-statement utilizing flag LINE :
//PVSCL:IFCOND(WindSpeed,LINE)updateSensor("wind");PVSCL:ENDCONDResult if feature WindSpeed is selected: updateSensor("wind"); |
BLANKS
| Clear the line containing the pvSCL conditional text
statement. In contrast to the flag LINE
does BLANKS replace each character with a
whitespace. This ensures the location of the parts remaining in
the file is the same as in the input document. Example
for a multi-line if-statement utilizing flag BLANKS :
/* PVSCL:IFCOND(Temperature,BLANKS) */ initializeSensor("temperature",PVSCL:EVAL(Temperature->max)); /* PVSCL:ELSECOND */ disableSensor("temperature"); /* PVSCL:ENDCOND */Result if feature Temperature is selected: /* */ initializeSensor("temperature",60); /* */Example for a single-line if-statement utilizing flag BLANKS :
//PVSCL:IFCOND(WindSpeed,BLANKS)updateSensor("wind");PVSCL:ENDCONDResult if feature WindSpeed is selected: // updateSensor("wind"); |
Conditional text blocks can be nested. That means, that a
PVSCL:IFCOND
block can contain another
PVSCL:IFCOND
block defining a nested conditional text block that is evaluated
only if the surrounding text block is included in the resulting
text output.
In the example document given below after processing with an
ps:pvscltext
transformation, the resulting text document only
contains an introductory chapter if the corresponding featureWithIntroduction
is selected.
Example 9.3. A sample conditional document for use with the ps:pvscltext transformation
PVSCL:IFCOND(WithIntroduction) This text is in the resulting text output if feature WithIntroduction is selected. PVSCL:ELSECOND This text is in the resulting text output if feature WithIntroduction is not selected. PVSCL:ENDCOND This text is always in the resulting text output.
dir
[ps:directory]
|
file
[ps:path]
|
type
[ps:filetype]
|
flag
[ps:string]
|
encoding?
[ps:encoding]
|
This source element type is used to generate C/C++-Header files
containing
#define <flag> <flagValue>
statements. The
<flagValue>
part of these statements is the value of the
attributeValue
of the parent part element. The name of the flag is
specified by the attributeflag
. See
the section called “Providing Values for Part Elements”
for more details. The same file location can be
used in more than oneps:flagfile
definition to include multiple
#define
statements in a single file.
Example 9.4. Generated code for a ps:flagfile for flag "DEFAULT" with value "1"
#ifndef __guard_DEBUG #define __guard_DEBUG #undef DEBUG #define DEBUG 1 #endif
dir
[ps:directory]
|
file
[ps:path]
|
type
[ps:filetype]
|
variable
[ps:string]
|
set?
[ps:boolean]
|
makesystem?
[ps:makesystemtype]
|
encoding?
[ps:encoding]
|
This source element type is used to generate
makefile
variables
using a<variable> += '<varValue>'
statement. The
<varValue>
part of the statement
is the value of the attributeValue
of the parent part element. The
name of the variable is specified by the attributevariable
. See
the section called “Providing Values for Part Elements”
for more details. The attribute
set
defines if the variable is set to the value (true) or if the
variable is extended by the value (false). The generated code is
compatible with the gmake
system. To generate code for a different make system the attributemakesystem
can be used. The same file location can be used for more
than oneps:makefile
element to include multiple makefile variables
in a single file.
Example 9.5. Generated code for a ps:makefile for variable "CXX_OPTFLAGS" with value "-O6"
CXX_OPTFLAGS += "-O6"
dir
[ps:directory]
|
file
[ps:path]
|
type
[ps:filetype]
|
alias
[ps:string]
|
includebasedir?
[ps:directory]
|
encoding?
[ps:encoding]
|
This source element type is used to support different classes with
different names
that are concurrently used in the same place in the class hierarchy.
This transformation
is C/C++ specific and can be used as an efficient replacement for
templates in some cases.
This definition is only used in conjunction with the part type
ps:classalias
. A
typedef className alias;
statement is generated by the standard transformation for this
element type.className
is the name of the class referenced by the parent ps:classalias
part element. Furthermore, in the standard
transformation #include
directives are generated for each of the referenced class'
ps:file
source elements that have a
type
attribute with the value 'def'.
The optional attribute includebasedir
defines how the #include
directives
referencing the class header files will be generated.
If this attribute is missing or it has an empty value,
the generated #include
directives will reference the
class header file by absolute file paths.
Otherwise the value will be used as the base directory path.
In that case the generated #include
directives will reference the class header files
by a file paths relative to that base directory.
If the alias name
contains a namespace prefix, corresponding namespace blocks are generated
around the
typedef
statement.
Example 9.6. Generated code for a ps:classalias for alias "io::net::PCConn" with aliased class "NoConn"
#ifndef __PCConn_include__ #define __PCConn_include__ #include "C:/Weather Station Example/output/usr/wm-src/NoConn.h" namespace io { namespace net { typedef NoConn PCConn; } } #endif __PCConn_include__
Example 9.7. Generated code for a ps:classalias for alias "io::net::PCConn" with aliased class "NoConn" with includebasedir set to "usr/wm-src"
#ifndef __PCConn_include__ #define __PCConn_include__ #include "NoConn.h" namespace io { namespace net { typedef NoConn PCConn; } } #endif __PCConn_include__
dir
[ps:directory]
|
file
[ps:path]
|
type
[ps:filetype]
|
linktarget
[ps:string]
|
This source element type is used to create a symbolic link to a
file or directory
named
<linktarget>
.
Symbolic links are not supported under Microsoft Windows operating systems. Instead files and directories are copied.