-
Notifications
You must be signed in to change notification settings - Fork 0
/
component.puml
53 lines (43 loc) · 1.67 KB
/
component.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
' Begin duplicate inclusion protection header.
!if %true() != $CLASSY_C4_COMPONENT_PUML
!$CLASSY_C4_COMPONENT_PUML = %true()
' End duplicate inclusion protection header.
' Defines a class that wraps the C4 Component function.
!include <C4/C4_Component>
!include <classy/types/element-renderer>
!include <classy/types/technical-descriptor>
!include <classy-c4/externalizable-element>
$class(Component)
$classImplements(ElementRenderer)
$classImplements(ExternalizableElement, 'externalizer')
$classImplements(TechnicalDescriptor, 'tech')
' Constructor that first calls our parent Element Renderer constructor then
' sets an Element Renderer callback.
!function Component($this)
!$parent = $getInstanceVar($this, 'parent')
ElementRenderer($parent)
!$cbElement = $new('Callback')
$call($cbElement, 'setContext', $this)
$call($cbElement, 'setMethod', 'Component__renderElement')
$call($this, 'setElementRendererCallback', $cbElement)
!return $this
!endfunction
' This method is an Element Renderer callback. We determine the relevant name,
' technology, and description values to submit to the C4 Component function as
' well as if we should render it standard or as an external Component.
!procedure Component__renderElement($this, $alias)
!$name = $call($this, 'getName')
!$desc = $call($this, 'getDescription')
!$tech = $call($this, 'getTechnology')
!if '' == $tech
!$tech = 'N/A'
!endif
!if $call($this, 'isExternal')
Component_Ext($alias, $name, $tech, $desc)
!else
Component($alias, $name, $tech, $desc)
!endif
!endprocedure
$endclass(Component)
' Terminate duplicate inclusion enclosure.
!endif