Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 54920cec07c0bc9179c1014c1c9a76ed286e4d4e (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
[module CppClassHeader('http://www.eclipse.org/uml2/4.0.0/UML')/]
[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/]
[import org::eclipse::papyrus::cpp::codegen::utils::ClassUtils/]
[import org::eclipse::papyrus::cpp::codegen::acceleo::Constants/]
[import org::eclipse::papyrus::cpp::codegen::acceleo::IncludeUtils/]
[import org::eclipse::papyrus::cpp::codegen::acceleo::util::clazz::CppClassIncludeClassDeclaration/]
[import org::eclipse::papyrus::cpp::codegen::acceleo::util::clazz::CppClassTypeAndEnum/]
[import org::eclipse::papyrus::cpp::codegen::acceleo::util::clazz::CppClassFriendDeclaration/]
[import org::eclipse::papyrus::cpp::codegen::acceleo::util::clazz::CppClassInheritedDeclarations/]
[import org::eclipse::papyrus::cpp::codegen::acceleo::util::clazz::CppClassAttributesDeclaration/]
[import org::eclipse::papyrus::cpp::codegen::acceleo::util::clazz::CppClassOperationsDeclaration/]
[import org::eclipse::papyrus::cpp::codegen::acceleo::util::clazz::CppClassOperationsImplementation/]
[import org::eclipse::papyrus::cpp::codegen::acceleo::util::CppTemplates/]
[import org::eclipse::papyrus::cpp::codegen::acceleo::util::CppDocumentation/]



[query public classUnionOrStruct(classifier : Classifier) : String =
if (hasStereotype(C_Cpp::Union)) then 'union'
else
	if (oclIsKindOf(DataType)) then 'struct'
	else 'class'
	endif
endif
/]

[comment default initializer for non-static attributes with a default value
TODO: should be disabled by default, since non-static members can be initialized directly
in C++ 011/]
[template public defaultInitializer(classifier : Classifier) post(trim())]
[let attributeList : Set(Property) = attribute->select(	
	(isStatic = false) and
	(defaultValue <> null) and
	(defaultValue.stringValue() <> null))]
[if not attributeList->isEmpty()]
	[classifier.name/]() : [for (a : Property | attributeList) separator(', ')
		][name/]([defaultValue.stringValue()/])[/for] {}
[/if][/let]
[/template]


[template public CppClassHeader(class : Classifier)]
#ifndef [getFullNameUC()/]_H
#define [getFullNameUC()/]_H

/************************************************************
              [class.name/] class header
 ************************************************************/

[_package.CppOwnerPackageIncludeDeclaration()/]

[CppClassAllIncludesDeclaration()/]

[IncludeHeader()/]

[openNS()/] 
[_package.CppClassTypeAndEnumPackage()/]
/************************************************************/
[CppElementDoc()/]
[templateSignature()/][classUnionOrStruct()/] [class.name/][CppClassInheritedDeclarations()/] {
[CppClassIncludeFriendDeclaration()/][CppClassTypeAndEnum()/]

  public:
[defaultInitializer()/][CppClassAttributesDeclaration(VisibilityKind::public)/][CppClassOperationsDeclaration(VisibilityKind::public)/]

  protected:
[CppClassAttributesDeclaration(VisibilityKind::protected)/][CppClassOperationsDeclaration(VisibilityKind::protected)/]

  private:
[CppClassAttributesDeclaration(VisibilityKind::private)/][CppClassOperationsDeclaration(VisibilityKind::private)/]

};
/************************************************************/
/* External declarations (package visibility)               */
[CppClassAttributesDeclaration(VisibilityKind::_package)/]
[CppClassOperationsDeclaration(VisibilityKind::_package)/]
/************************************************************/

[if (isTemplate())]
/************************************************************/
/* Template functions                                       */
[CppClassOperationsImplementation(false)/]
[/if]

/* Inline functions                                         */
[CppClassOperationsImplementation(true)/]
[closeNS()/]

/************************************************************
              End of [class.name/] class header
 ************************************************************/

#endif
[/template]

Back to the top