FW Profile - C1 Implementation
|
Declaration of the static creation interface for a FW Procedure. More...
Go to the source code of this file.
Macros | |
#define | FW_PR_INST(PR_DESC, N, NDEC, NFLOWS, NA, NG) |
Instantiate a procedure descriptor and its internal data structure. More... | |
#define | FW_PR_INST_NODEC(PR_DESC, N, NFLOWS, NA, NG) |
Instantiate a procedure descriptor and its internal data structure. More... | |
#define | FW_PR_INST_DER(PR_DESC, NA, NG) |
Instantiate a descriptor for a derived procedure. More... | |
Functions | |
void | FwPrInit (FwPrDesc_t prDesc) |
Initialize a procedure descriptor to represent an unconfigured procedure with no control flows, no actions, and no guards. More... | |
void | FwPrInitDer (FwPrDesc_t prDesc, FwPrDesc_t prDescBase) |
Initialize a procedure descriptor to extend another procedure (the base procedure). More... | |
Declaration of the static creation interface for a FW Procedure.
A FW Procedure is described by a procedure descriptor. This interface allows a procedure descriptor to be created statically (i.e. without using dynamic memory allocation). In this sense, this interface is alternative to the dynamic creation interface defined in FwPrDCreate.h
.
A procedure can be created in two ways:
In both cases, creation of a procedure descriptor is done in two steps:
Instantiation is done by means of the following macros.
FW_PR_INST
should be used to instantiate from scratch a descriptor for a procedure with one or more choice pseudo-states.FW_PR_INST_NODEC
should be used to instantiate from scratch a descriptor for a procedure with no choice pseudo-states.FW_PR_INST_DER
should be used to instantiate a descriptor for a procedure which is derived by extending another procedure.Initialization is done by means of the following functions:
FwPrInit
should be used to initialize a descriptor which has been created from scratch with either FW_PR_INST
or FW_PR_INST_NODEC
.FwPrInitDer
should be used to initialize a descriptor of a procedure which is derived by extending another procedureAfter a procedure descriptor has been instantiated and initialized, it will normally need to be configured. Configuration of a procedure descriptor can be done using the functions described in the FwPrConfig.h
file.
This file is part of the FW Profile.
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
For information on alternative licensing, please contact P&P Software GmbH.
Definition in file FwPrSCreate.h.
#define FW_PR_INST | ( | PR_DESC, | |
N, | |||
NDEC, | |||
NFLOWS, | |||
NA, | |||
NG | |||
) |
Instantiate a procedure descriptor and its internal data structure.
This macro compiles correctly only if the number of action nodes N, the number of decision NDEC and the number of control flows NFLOWS is positive. If there is a need to define a procedure with zero decision nodes, the FW_PR_INST_NODEC
macro should be used.
The macro generates code that does the following:
PrANode_t
to represent the array holding the procedure action nodes.PrDNodes_t
to represent the array holding the procedure decision nodes.PrFlow_t
to represent the array holding the procedure control flows.PrAction_t
to represent the array holding the procedure actions.PrGuard_t
to represent the array holding the procedure guards (the extra guard is the "dummy guard" PrDummyGuard"
to be attached to control flows which have no guard).FwPrDescBase_t
to represent the base part of the procedure descriptor.struct FwPrDesc
to represent the procedure descriptor.All variables defined by this macro are static
.
The procedure descriptor instantiated by the macro is only partially initialized. Full initialization is performed using function FwPrInit
.
Since the macro includes the declaration of several variables, it should be located in the section of a c-file where variable declaration is legal.
PR_DESC | the variable holding the procedure descriptor |
N | a positive integer representing the number of action nodes |
NDEC | a positive integer the number of decision nodes |
NFLOWS | a positive integer representing the number of control flows |
NA | a positive integer representing the number of actions |
NG | a non-negative integer representing the number of guards (i.e. the number of transition actions which are defined on the procedure) |
Definition at line 102 of file FwPrSCreate.h.
#define FW_PR_INST_DER | ( | PR_DESC, | |
NA, | |||
NG | |||
) |
Instantiate a descriptor for a derived procedure.
A derived procedure is a procedure which is created by extending another procedure. The procedure which is thus extended is called base procedure.
A procedure descriptor consists of two parts: the base descriptor and the extension descriptor (see FwPrPrivate.h
). A derived procedure and its base procedure share the same base descriptor (which defines the topology of the procedure) but have different extension descriptors. This macro accordingly only instantiates a new extension descriptor. More precisely, this macro generates code that does the following:
PrAction_t
to represent the array holding the procedure actions.PrGuard_t
to represent the array holding the procedure guards (the extra guard is the "dummy guard" PrDummyGuard"
to be attached to control flows which have no guard).struct FwPrDesc
to represent the procedure descriptor.All variables defined by this macro are static
.
The procedure descriptor instantiated by the macro is only partially initialized. Full initialization is performed using function FwPrInitDer
.
Since the macro includes the declaration of several variables, it should be located in the section of a c-file where variable declaration is legal.
PR_DESC | the variable holding the procedure descriptor |
NA | a non-negative integer representing the number of actions |
NG | a non-negative integer representing the number of guards |
Definition at line 197 of file FwPrSCreate.h.
#define FW_PR_INST_NODEC | ( | PR_DESC, | |
N, | |||
NFLOWS, | |||
NA, | |||
NG | |||
) |
Instantiate a procedure descriptor and its internal data structure.
This macro compiles correctly only if the number of action nodes N and the number of control flows is positive. This macro instantiates a descriptor for a procedure without decision nodes. If there is a need to define a procedure with one or more decision nodes, the FW_PR_INST
macro should be used.
The macro generates code that does the following:
PrANode_t
to represent the array holding the procedure action nodes.PrFlow_t
to represent the array holding the procedure control flows.PrAction_t
to represent the array holding the procedure actions.PrGuard_t
to represent the array holding the procedure guards (the extra guard is the "dummy guard" PrDummyGuard"
to be attached to control flows which have no guard).FwPrDescBase_t
to represent the base part of the procedure descriptor.struct FwPrDesc
to represent the procedure descriptor.All variables defined by this macro are static
.
The procedure descriptor instantiated by the macro is only partially initialized. Full initialization is performed using function FwPrInit
.
Since the macro includes the declaration of several variables, it should be located in the section of a c-file where variable declaration is legal.
PR_DESC | the variable holding the procedure descriptor |
N | a positive integer representing the number of action nodes |
NFLOWS | a positive integer representing the number of control flows |
NA | a positive integer representing the number of actions |
NG | a non-negative integer representing the number of guards (i.e. the number of transition actions which are defined on the procedure) |
Definition at line 153 of file FwPrSCreate.h.
void FwPrInit | ( | FwPrDesc_t | prDesc | ) |
Initialize a procedure descriptor to represent an unconfigured procedure with no control flows, no actions, and no guards.
After this function has been executed, the argument procedure descriptor has the same content as a procedure descriptor which has been created by calling FwPrCreate
.
This function is primarily intended to be used to initialize a procedure descriptor which has been statically instantiated with macro FW_PR_INST
or FW_PR_INST_NODEC
.
If the function is called upon a procedure descriptor that had already been initialized, the previous initialization values are lost. In such a case, a memory leak is possible due to the potential loss of the pointers to the arrays where the procedures nodes and control flows are stored.
prDesc | the procedure descriptor to be initialized. |
Definition at line 23 of file FwPrSCreate.c.
void FwPrInitDer | ( | FwPrDesc_t | prDesc, |
FwPrDesc_t | prDescBase | ||
) |
Initialize a procedure descriptor to extend another procedure (the base procedure).
This function checks that the descriptor to be initialized satisfies the following constraints:
If either constraint is not satisfied, the function reports an error by setting the error code of the descriptor to be initialized and then returns. If the first constraint is not satisfied, the function sets the error code to prWrongNOfActions
. If the second constraint is not satisfied, the function sets the error code to prWrongNOfGuards
.
If both constraints are satisfied, this function initializes a descriptor as follows:
flowCnt
field to zero.Thus, the descriptor initialized by this function represents exactly the same procedure as the descriptor created by calling function FwPrCreateDer
.
This function is primarily intended to be used to initialize a procedure descriptor which has been statically instantiated with macro FW_PR_INST_DER
. If the function is called upon a procedure descriptor that had already been initialized, the previous initialization values are lost. In such a case, a memory leak is possible due to the potential loss of the pointers to the arrays where the procedures states, choice pseudo-states, transitions and embedded procedures are stored.
prDesc | the procedure descriptor to be initialized. |
prDescBase | the procedure descriptor of the base procedure. |
Definition at line 51 of file FwPrSCreate.c.