Hi,
In a UML activity diagram, what is the correct way of modeling passing a function pointer from one action to another "action"? The "destination action" is of course pretty empty, and all it does is to receive the function pointer (from the source action) and run the function.
TIA
Avraham
>> If you want to generate executable and deployable code, that's different than "I want to show my design intent so that someone can implement it in some action language.
i am doing reverse engineering. So this is supposed to be accurate. The system and its documentation gets regularly audited by external parties. And we are supposed to be always proving an upward path in quality of our development processes. My SysML/UML diagrams are intended to be used for safety analysis. So my needs are closer to the designation of "generate executable and deployable code".
Of course, then the simplest thing, supposing that you wanted to install the passed function pointer into a variable f (of type FunctionPtr2InputsOneOutput (which might be defined by a typedef), and then apply it would be even simpler:
It also depends on the level of precision you're trying to capture. If you want to generate executable and deployable code, that's different than "I want to show my design intent so that someone can implement it is some action language." If I was going for the latter I would probably do something iike the following. It could be that you don't need the Install Behavior bit, but you might, if you were doing something like installing an interrupt handler.
i need to get more info on "who" supplies the function pointer to action A, and why does this have to be an indirect function call. I.e., why does the identifying of the address of the function have to be delayed until run-time? Will share it with you when I know more.
>> Here's an approach to address this kind of question. Write out the code you want to replicate and then reverse engineer it into Rhapsody and take a look. Thanks. It would be a good idea. But I have been doing my so called modeling just by drawing SysML/UML diagrams using Visio. That's what I have. No actual MSBE platform (yet). So I am wondering what difference it should make in the SysML/UML diagram: (i) Action A passes control to action B
as opposed to (ii) Action A sends a function pointer to action B, which uses it to invoke some action C. That was me thinking out loud ...
>> First, this is really below the level of UML per se and is in the realm of the underlying "action language".
I am reverse engineering a system and modeling it in SysML/UML.
Background if it is of any significance:
The system is an enormous complex real-time embedded system and mission critical. My area of interest is the System TLD (top-level design) of the operational system. It is the top-most stuff. There is a large number of software engines running on multiple cores on a single board. I call it a SW Engine grid (my made-up term). And some of the engines are defined as being invoked via a function pointers. I don't yet know why they are invoked via function pointers and have not had time to ask.
So ... in my company, function pointers are used to invoke entire modules.
>> First, this is really below the level of UML per se and is in the realm of the underlying "action language".
You mean this (usually) is the low/detail level inside the actions?
A couple of comments:
First, this is really below the level of UML per se and is in the realm of the underlying "action language".
Second, I can see why you might actually want to do this anyway. Here's an approach to address this kind of question. Write out the code you want to replicate and then reverse engineer it into Rhapsody and take a look.
I took the following code:
int foo(int i){ return i + 1;}
typedef int (*g)(int); // Declare typedef
g func = &foo; // Define function-pointer variable, and initialize
int hvar = func(3); // Call function through pointer
and used Tools > Reverse Engineer to bring it into a Rhapsody model. This is what I got. (Figure 1).
g, the typedef, was brought in as a type (kind: Language) using the following definition (Figure 2).
The assignment of the variable func is shown in Figure 3.
Hope this helps.