-
Notifications
You must be signed in to change notification settings - Fork 0
/
consumer-person.puml
78 lines (62 loc) · 2.58 KB
/
consumer-person.puml
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
71
72
73
74
75
76
77
78
' Begin duplicate inclusion protection header.
!if %true() != $CLASSY_C4_CONSUMER_PERSON_PUML
!$CLASSY_C4_CONSUMER_PERSON_PUML = %true()
' End duplicate inclusion protection header.
' Defines a class that decorates the C4 Person class so that it adds the concept
' that a Person consumes provided interfaces (ie: user interfaces).
!include <C4/C4_Context>
!include <classy/types/interface-consumer>
!include <classy/types/port>
!include <classy-c4/person>
$class(ConsumerPerson)
$classImplements(Person)
$classImplements(InterfaceConsumer, 'consumer')
$classVar(port, Port)
' Constructor that first calls our parent constructor then sets an Element
' Content Renderer callback and an Outside Renderer callback.
!function ConsumerPerson($this)
!$parent = $getInstanceVar($this, 'parent')
Person($parent)
!$port = $new('Port')
$call($port, 'setName', 'use')
$setInstanceVar($this, 'port', $port)
!$cbElementContent = $new('Callback')
!$cbOutside = $new('Callback')
$call($cbElementContent, 'setContext', $this)
$call($cbOutside, 'setContext', $this)
$call($cbElementContent, 'setMethod', 'ConsumerPerson__renderElementContent')
$call($cbOutside, 'setMethod', 'ConsumerPerson__renderOutsideContent')
$call($this, 'setElementContentRendererCallback', $cbElementContent)
$call($this, 'setOutsideRendererCallback', $cbOutside)
!return $this
!endfunction
' This method is an Element Content Renderer callback. This is where we render
' the port for our Person.
!procedure ConsumerPerson__renderElementContent($this, $alias)
!$port = $getInstanceVar($this, 'port')
$call($port, 'render', $void=%true())
!endprocedure
' This method is an Outside Renderer callback. This is where we render the
' interfaces that we consume and our connection to those interfaces.
!procedure ConsumerPerson__renderOutsideContent($this, $alias)
!$interfaces = $call($this, 'getConsumedInterfaces')
!if '' != $interfaces
!$interface = $call($interfaces, 'each')
!$port = $getInstanceVar($this, 'port')
!$portAlias = $call($port, 'render')
!while %false() != $interface
!$current = $call($interface, 'render')
$current )-- $portAlias
!$interface = $call($interfaces, 'each')
!endwhile
!endif
!endprocedure
' Retrieves the sole Port used by a Person.
$classMethod(getPort)
!function ConsumerPerson__getPort($this, $args='')
!return $getInstanceVar($this, 'port')
!endfunction
$endclassMethod(getPort)
$endclass(ConsumerPerson)
' Terminate duplicate inclusion enclosure.
!endif