summaryrefslogtreecommitdiffstats
path: root/tags/cpp-1.0-incubating-M2-final/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfWrapperHeader.xsl
blob: c8157fe2f6c5c728ff0541d0db92980313447f61 (plain)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at
   
     http://www.apache.org/licenses/LICENSE-2.0
     
   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!-- Part of the org.apache.tuscany.sca.cpp.tools.services packages
  - 
  -  This stylesheet creates the CPP implementation of the 
  -  wrapper header for a given SCA service
  -->
    <xsl:output method="text" />

    <!-- Delete cppScopes -->
    <xsl:template match="cppScope"></xsl:template>

    <!-- Delete private methods cppScopes -->
    <xsl:template match="scaOperation[@cppScope='private']">
    </xsl:template>

    <!-- Delete private methods cppScopes -->
    <xsl:template match="scaOperationReturnType"></xsl:template>


    <!-- -->
    <!-- CPP Header/Root -->
    <!-- -->
    <xsl:template match="cppHeader">
        <xsl:variable name="class">
               <xsl:value-of select="concat(@implClass, '_', @serviceName, '_Wrapper')"/>    
        </xsl:variable>
<xsl:text>/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 *   
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

</xsl:text>
        <xsl:call-template name="ifndef_start">
            <xsl:with-param name="class" 
                            select="$class"/>
        </xsl:call-template>


        <xsl:call-template name="include_headers">
            <xsl:with-param name="header" 
                            select="@compositeXmlFileHeader"/>
        </xsl:call-template>

        <xsl:apply-templates select="scaService" mode="class_body"/>

        <xsl:call-template name="ifndef_end">
            <xsl:with-param name="class" 
                            select="$class"/>
        </xsl:call-template>
<!-- Always make sure we have a (visible) final return -->
<xsl:text>

</xsl:text>
</xsl:template>


<!-- Here are the subroutine templates in order -->

    <xsl:template name="ifndef_start">
        <!--For example,  
            #ifndef CustomerInfoImpl_CustomerInfoService_Wrapper_h
            #define CustomerInfoImpl_CustomerInfoService_Wrapper_h
        -->
        <xsl:param name="class"/>
        <xsl:text>#ifndef </xsl:text><xsl:value-of select="$class"/><xsl:text>_h</xsl:text>
<!-- newline -->
<xsl:text>
</xsl:text>
        <xsl:text>#define </xsl:text><xsl:value-of select="$class"/><xsl:text>_h</xsl:text>
<!-- newline -->
<xsl:text>

</xsl:text>
		<xsl:text>#if defined(WIN32) || defined (_WINDOWS)
#pragma warning(disable: 4786)
#endif </xsl:text>
<!-- newline -->
<xsl:text>

</xsl:text>
    </xsl:template>

    <xsl:template name="include_headers">
        <!--For example,  
            #include "CustomerInfoImpl.h"
            #include "tuscany/sca/cpp/CPPServiceWrapper.h"
        -->
        <xsl:param name="header"/>
        <xsl:text>#include "</xsl:text><xsl:value-of select="translate($header,'\','/')"/><xsl:text>"</xsl:text>
<!-- newline -->
<xsl:text>
</xsl:text>
        <xsl:text>#include "tuscany/sca/cpp/CPPServiceWrapper.h"</xsl:text>
    </xsl:template>

    <xsl:template match="scaService" mode="class_body">
        <!--For example
            class wrapperclassname : public tuscany::sca::cpp::CPPServiceWrapper
            {
             constructor
             destructor
                 then apply operation templates for operations
            };

            E.g. Specifically

        class CustomerInfoImpl_CustomerInfoService_Wrapper : public tuscany::sca::cpp::CPPServiceWrapper
        {
        public:
            CustomerInfoImpl_CustomerInfoService_Wrapper(tuscany::sca::model::Component*);
            virtual ~CustomerInfoImpl_CustomerInfoService_Wrapper();
            virtual void invoke(tuscany::sca::Operation& operation);
    
        private:
            CustomerInfoImpl* impl;
        };
        -->
        <!-- TODO second definition, remove? -->
        <xsl:variable name="class">
               <xsl:value-of select="concat(../@implClass, '_', ../@serviceName, '_Wrapper')"/>    
        </xsl:variable>
<xsl:text>

class </xsl:text>
<xsl:value-of select="$class"/>
<xsl:text> : public tuscany::sca::cpp::CPPServiceWrapper
{
public:
    </xsl:text><xsl:value-of select="$class"/><xsl:text>(tuscany::sca::model::Service* target);</xsl:text>
    <xsl:text>
    virtual ~</xsl:text><xsl:value-of select="$class"/><xsl:text>();
    virtual void invokeService(tuscany::sca::Operation&amp; operation);
    virtual void* newImplementation();
    virtual void deleteImplementation();
</xsl:text>
<xsl:text>private:
    </xsl:text>
    <xsl:value-of select="../@implNamespace"/><xsl:value-of select="../@implClass"/><xsl:text>* impl;
};
</xsl:text>
    </xsl:template>

    <xsl:template name="ifndef_end">
        <!--For example,  
            #endif // CustomerInfoImpl_CustomerInfoService_Wrapper_h          
        -->
        <xsl:param name="class"/>
        <xsl:text>
#endif // </xsl:text><xsl:value-of select="$class"/><xsl:text>_h</xsl:text>
    </xsl:template>

<xsl:template match="scaOperation">
</xsl:template>

</xsl:stylesheet>