Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: abccef12b4489bd8090ce532259756c1a68d23a1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
[module Marshalling('http://www.eclipse.org/uml2/4.0.0/UML')/]

[import org::eclipse::papyrus::qompass::designer::core::acceleo::UMLTool /]
[import org::eclipse::papyrus::qompass::designer::core::acceleo::utils_cpp /]

[comment
  All marshalling mechanisms produce an Event, since we need a common data type.
  An advantage of the Event data type is that ID and kind can be used to
  identify data without having to unmarshall.
  (what about target instance?) [=> as long as an event is within the pool of an object, this information is
  not required on each event. But it needs to be added in the moment, an event is transferred.

Also: two different tasks: Call => CallEvent
	CallEvent => buffer
	Call => buffer

	CallEvent => Call
	buffer => CallEvent
	operations marshall all,
   
  An alternative option would be to produce a buffer only
  In case of OO marshalling, there is no need to produce an event via
  an out port, but to pass the buffer in the call

  Better(?): Marshalling returns CallEvent or buffer
 marshall
/]
[template public marshallStruct(operation : Operation)]
struct ParamData {
[for (parameter : Parameter | parametersInInout(operation))]
	[cppType(type) /] [name/];
[/for]
};
Event event;
event.ID = [operation.name/];
event.kind = CallEvent;
ParamData * data = &event.params; 
[for (parameter : Parameter | parametersInInout(operation))]
	data->[parameter.name/] = [parameter.name/];
[/for]
out->dispatch(event);
[/template]

[template public marshallASN(operation : Operation)]
Event event;
event.ID = [operation.name/];
event.kind = CallEvent;
// create buffer for ASN.1 data types
char * pBuffer = &event.params + sizeof(event.params);		// grows backwards
int encodedSize = 0;     // total size of encoded buffer
AsnLen itemSize;         // size of an encoded item
int operationID = ID_[operation.name/];
	
// now marshall in and inout parameters via ASN.1
[for (parameter : Parameter | operation.parametersInInout())]
{
	[parameter.type.cppType()/] varName_ASN = [parameter.name/];
	itemSize  = BEncAsnContent (&pBuffer, &varName_ASN);
	encodedSize += itemSize;
}
[/for]

itemSize  = BEncAsnContent (&pBuffer, &operationID);
itemSize += BEncAsnContent (&pBuffer, &m_serverID);
encodedSize += itemSize;

encodedSize += BEncDefLen (&pBuffer, encodedSize);

out->dispatch(event);
[/template]

Back to the top