summaryrefslogtreecommitdiffstats
path: root/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator
diff options
context:
space:
mode:
Diffstat (limited to 'sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator')
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/Makefile.am21
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/README4
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/README.html176
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator.app.composite29
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator.client/CalculatorClient.cpp150
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator.client/Makefile.am40
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator.client/runclient.bat42
-rwxr-xr-xsca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator.client/runclient.sh39
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/Calculator.h34
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/CalculatorImpl.componentType31
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/CalculatorImpl.cpp90
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/CalculatorImpl.h41
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/Divide.h34
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/DivideImpl.componentType27
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/DivideImpl.cpp48
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/DivideImpl.h39
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/Makefile.am53
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/sample.calculator.composite33
18 files changed, 931 insertions, 0 deletions
diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/Makefile.am b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/Makefile.am
new file mode 100644
index 0000000000..d9d4b499b7
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/Makefile.am
@@ -0,0 +1,21 @@
+# 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.
+
+deploydir=$(prefix)/CppCalculator/deploy
+SUBDIRS = sample.calculator sample.calculator.client
+EXTRA_DIST = *.composite README.html
+deploy_DATA = *.composite
diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/README b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/README
new file mode 100644
index 0000000000..b9dedd2da3
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/README
@@ -0,0 +1,4 @@
+Tuscany SCA for C++ Samples - C++ Calculator Sample
+===================================================
+
+See the README.html file for instructions to build and run this sample
diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/README.html b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/README.html
new file mode 100644
index 0000000000..264ba3d881
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/README.html
@@ -0,0 +1,176 @@
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!--
+ 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.
+-->
+
+<HTML>
+<HEAD>
+ <META CONTENT="text/html; charset=iso-8859-1" HTTP-EQUIV="Content-Type">
+ <META CONTENT="text/css" HTTP-EQUIV="Content-Style-Type">
+ <STYLE MEDIA="all" TYPE="text/css">
+@import url("../../doc/css/maven-base.css");
+@import url("../../doc/css/maven-theme.css");
+ </STYLE>
+
+ <LINK HREF="../doc/css/maven-theme.css" MEDIA="print" REL="stylesheet"
+ TYPE="text/css">
+ <TITLE>Tuscany SCA Native Samples - C++ Calculator Sample</TITLE>
+</HEAD>
+
+<BODY>
+<DIV ID="bodyColumn">
+ <DIV ID="contentBox">
+ <DIV CLASS="section">
+ <H1>Tuscany SCA Native Samples - C++ Calculator Sample</H1>
+
+ <P>This is a very simple sample to show how an SCA composite can wire
+ together two C++ components to implement a Calculator service and invoke
+ the service via a local client.
+ </P>
+ <P>There are two sub projects in this workspace:</P>
+ <UL>
+ <LI>sample.calculator<BR/>
+ This contains the source code and SCDL artifacts for the SCA Calculator
+ composite implementing the sample Calculator.
+ </LI>
+ <LI>sample.calculator.client<BR/>
+ A sample client which does a local call to the Calculator service.
+ </LI>
+ </UL>
+ <P>Additionally, there is the sample.calculator.app.composite file. This
+ describes the configuration of the SCA Calculator composite deployed to the SCA
+ runtime.
+ </P>
+ </DIV>
+
+ <DIV CLASS="section">
+ <H2>Contents</H2>
+ <OL>
+ <LI><A HREF="#linuxbld">Building the C++ samples on Linux and Mac OS X</A></LI>
+ <LI><A HREF="#linuxrun">Running the C++ Calculator sample on Linux and Mac OS X</A></LI>
+ <LI><A HREF="#winbld">Building the C++ Calculator sample on Windows</A></LI>
+ <LI><A HREF="#winrun">Running the C++ Calculator sample on Windows</A></LI>
+ <LI><A HREF="#help">Getting help</A></LI>
+ </OL>
+ </DIV>
+
+
+ <DIV CLASS="section">
+ <A NAME="linuxbld"><H2>Building the C++ samples on Linux and Mac OS X</H2></A>
+ <P>If using the binary distribution the samples are built and installed in
+ &lt;tuscany_sca_install_dir&gt;/samples - go directly to <A HREF="#linuxrun">Running the samples on Linux and Mac OS X</A>.</P>
+ <OL>
+ <LI>The following environment variables are required:
+ <UL>
+ <LI>TUSCANY_SCACPP=&lt;path to installed Tuscany SCA&gt;
+ <LI>TUSCANY_SDOCPP=&lt;path to installed Tuscany SDO&gt;
+ </UL></LI>
+ </LI>
+ <LI>Build the C++ samples with the following command sequence:
+ <UL>
+ <LI>cd &lt;tuscany_sca_install_dir&gt;/samples</LI>
+ <LI>./configure --prefix=$TUSCANY_SCACPP/samples --enable-static=no</LI>
+ <LI>make</LI>
+ <LI>make install</LI>
+ </UL>
+ NOTE: If you don't provide the --prefix configure option, it will by default install into
+ /usr/local/tuscany/sca/samples/CppCalculator</LI>
+ </OL>
+ </DIV>
+
+ <DIV CLASS="section">
+ <A NAME="linuxrun"><H2>Running the C++ Calculator sample on Linux and Mac OS X</H2></A>
+ <OL>
+ <LI>The following environment variables are required:
+ <UL>
+ <LI>TUSCANY_SCACPP=&lt;path to installed Tuscany SCA&gt;</LI>
+ <LI>TUSCANY_SDOCPP=&lt;path to installed Tuscany SDO&gt;</LI>
+ </UL>
+ </LI>
+ <LI>Run the sample with the following commands:
+ <UL>
+ <LI>cd &lt;tuscany_sca_install_dir&gt;/samples/CppCalculator/deploy/sample.calculator.client</LI>
+ <LI>./runclient.sh</LI>
+ </UL>
+ </LI>
+ </OL>
+ </DIV>
+
+ <DIV CLASS="section">
+ <A NAME="winbld"><H2>Building the C++ Calculator sample on Windows</H2></A>
+ <P>If using the binary distribution the samples are built and installed in
+ &lt;tuscany_sca_install_dir&gt;\samples - go directly to <A HREF="#winrun">Running the samples on Windows</A>.</P>
+ <OL>
+ <LI>The following environment variables are required:
+ <UL>
+ <LI>TUSCANY_SCACPP=&lt;path to installed Tuscany SCA&gt;
+ <LI>TUSCANY_SDOCPP=&lt;path to installed Tuscany SDO&gt;
+ </UL></LI>
+ </LI>
+ <LI>You must have set up the environment for Microsoft Visual C++ tools.
+ The build command will call vcvars32 to set the environment. Ensure the
+ directory containing this is on your path. This will be where you
+ installed the compiler.
+ </LI>
+ <LI>Build the source, either via the Visual Studio Express projects under
+ &lt;tuscany_sca_install_dir&gt;\samples\CppCalculator\VSExpress\CppCalculator.sln or via the command-line build file
+ found at &lt;tuscany_sca_install_dir&gt;\samples\CppCalculator\VSExpress\CppCalculator\build.bat
+ which will build and deploy the samples.
+ </LI>
+ </OL>
+ </DIV>
+
+ <DIV CLASS="section">
+ <A NAME="winrun"><H2>Running the C++ Calculator sample on Windows</H2></A>
+ <OL>
+ <LI>The following environment variables are required:
+ <UL>
+ <LI>TUSCANY_SCACPP=&lt;path to installed Tuscany SCA&gt;</LI>
+ <LI>TUSCANY_SDOCPP=&lt;path to installed Tuscany SDO&gt;</LI>
+ </UL>
+ </LI>
+ <LI>Run the sample with the following commands:
+ <UL>
+ <LI>cd &lt;tuscany_sca_install_dir&gt;\samples\CppCalculator\deploy\sample.calculator.client</LI>
+ <LI>runclient.bat</LI>
+ </UL>
+ </LI>
+ </DIV>
+
+
+
+ <DIV CLASS="section">
+ <A NAME="help"><H2>Getting Help</H2></A>
+
+ <P>The first place to look is at the Tuscany SCA FAQ at
+ <A HREF="http://cwiki.apache.org/confluence/display/TUSCANY/Tuscany+SCA+-+FAQ"
+ TARGET="_blank">http://cwiki.apache.org/confluence/display/TUSCANY/Tuscany+SCA+-+FAQ</A> </P>
+
+ <P>Any problem with this release can be reported to the Tuscany
+ <A HREF="http://cwiki.apache.org/TUSCANY/mailing-lists.html"
+ TARGET="_blank">mailing lists</A> or create a JIRA issue at&nbsp;<A HREF="http://issues.apache.org/jira/browse/Tuscany"
+ TARGET="_blank">http://issues.apache.org/jira/browse/Tuscany</A>.</P>
+
+ </DIV>
+ </DIV>
+</DIV>
+</BODY>
+
+</HTML>
+
diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator.app.composite b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator.app.composite
new file mode 100644
index 0000000000..5753b3c593
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator.app.composite
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ name="sample.calculator.app">
+
+ <component name="sample.calculator.CalculatorComponent">
+ <implementation.composite name="sample.calculator" />
+ </component>
+
+</composite>
+
diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator.client/CalculatorClient.cpp b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator.client/CalculatorClient.cpp
new file mode 100644
index 0000000000..37e9d40f66
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator.client/CalculatorClient.cpp
@@ -0,0 +1,150 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include <iostream>
+#include <stdlib.h>
+
+#include "osoa/sca/sca.h"
+
+#include "Calculator.h"
+
+using namespace std;
+using namespace osoa::sca;
+
+
+void usage();
+bool IsNumber(const char *p);
+
+int main(int argc, char* argv[])
+{
+ const char *operation;
+ float arg1 = 0;
+ float arg2 = 0;
+
+ if (argc == 4)
+ {
+ operation = argv[1];
+
+ if (!IsNumber(argv[2]))
+ {
+ cout << "calculator_client: Argument 1 is not a number" << endl;
+ usage();
+ }
+ else
+ {
+ arg1 = atof(argv[2]);
+ }
+
+ if (!IsNumber(argv[3]))
+ {
+ cout << "calculator_client: Argument 2 is not a number" << endl;
+ usage();
+ }
+ else
+ {
+ arg2 = atof(argv[3]);
+ }
+ }
+ else
+ {
+ usage();
+ }
+
+ try
+ {
+ // Locate a service
+ CompositeContext myContext = CompositeContext::getCurrent();
+ Calculator *calcService = (Calculator*) myContext.locateService("CalculatorComponent/CalculatorService");
+ if (calcService == 0)
+ {
+ cout << "calculator_client: Unable to find Calculator service" << endl;
+ }
+ else
+ {
+ float result = 0;
+ if (strcmp(operation, "add") == 0)
+ {
+ result = calcService->add(arg1, arg2);
+ cout << "calculator_client: add(" << arg1 << "," << arg2 << ") = " << result << endl;
+ }
+ else
+ if (strcmp(operation, "sub") == 0)
+ {
+ result = calcService->sub(arg1, arg2);
+ cout << "calculator_client: sub(" << arg1 << "," << arg2 << ") = " << result << endl;
+ }
+ else
+ if (strcmp(operation, "mul") == 0)
+ {
+ result = calcService->mul(arg1, arg2);
+ cout << "calculator_client: mul(" << arg1 << "," << arg2 << ") = " << result << endl;
+ }
+ else
+ if (strcmp(operation, "div") == 0)
+ {
+ result = calcService->div(arg1, arg2);
+ cout << "calculator_client: div(" << arg1 << "," << arg2 << ") = " << result << endl;
+ }
+ else
+ {
+ cout << "calculator_client: Unrecognized operation: " << operation << endl;
+ }
+ }
+ }
+ catch (ServiceRuntimeException& ex)
+ {
+ cout << "calculator_client: exception caught: " << ex << endl;
+ }
+ return 0;
+}
+
+void usage()
+{
+ cout << "Usage: calculator_client add|sub|mul|div arg1 arg2" << endl;
+ exit(1);
+}
+
+bool IsNumber (const char *p)
+{
+ int len = strlen(p);
+ int pointcount = 0;
+
+ if (!isdigit (p[0]) && p[0] != '-' && p[0] != '+')
+ {
+ return false;
+ }
+ for (int i = 1; i < len; i++)
+ {
+ if (!isdigit (p[i]))
+ {
+ if (p[i] == '.')
+ {
+ if (pointcount > 0) return false;
+ pointcount++;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+}
diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator.client/Makefile.am b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator.client/Makefile.am
new file mode 100644
index 0000000000..9782bf5041
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator.client/Makefile.am
@@ -0,0 +1,40 @@
+# 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.
+
+deploydir=$(prefix)/CppCalculator/deploy
+clientdir=$(deploydir)/sample.calculator.client
+
+client_PROGRAMS = calculator_client
+client_SCRIPTS = runclient.sh
+EXTRA_DIST = runclient.sh
+
+calculator_client_SOURCES = \
+CalculatorClient.cpp
+
+calculator_client_LDADD = \
+-L${TUSCANY_SCACPP}/lib \
+ -ltuscany_sca \
+-L${TUSCANY_SCACPP}/extensions/cpp/lib \
+ -ltuscany_sca_cpp \
+-L${TUSCANY_SDOCPP}/lib \
+ -ltuscany_sdo
+
+INCLUDES = \
+-I$(TUSCANY_SCACPP)/extensions/cpp/include \
+-I${TUSCANY_SCACPP}/include \
+-I${TUSCANY_SDOCPP}/include \
+-I../sample.calculator
diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator.client/runclient.bat b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator.client/runclient.bat
new file mode 100644
index 0000000000..795325ab52
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator.client/runclient.bat
@@ -0,0 +1,42 @@
+@echo off
+
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements. See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership. The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License. You may obtain a copy of the License at
+@REM
+@REM http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing,
+@REM software distributed under the License is distributed on an
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@REM KIND, either express or implied. See the License for the
+@REM specific language governing permissions and limitations
+@REM under the License.
+
+setlocal
+
+if "%TUSCANY_SCACPP%" == "" (
+echo "TUSCANY_SCACPP not set"
+goto end
+)
+echo using SCA installed at %TUSCANY_SCACPP%
+
+if "%TUSCANY_SDOCPP%" == "" (
+echo "TUSCANY_SDOCPP not set"
+goto end
+)
+echo using SDO installed at %TUSCANY_SDOCPP%
+
+set PATH=%TUSCANY_SCACPP%\bin;%TUSCANY_SCACPP%\extensions\cpp\bin;%TUSCANY_SDOCPP%\bin;%PATH%
+
+set TUSCANY_SCACPP_ROOT=%~d0%~p0\..\
+set TUSCANY_SCACPP_COMPONENT=sample.calculator.CalculatorComponent
+
+.\calculator_client.exe div 5 2
+
+:end
+endlocal
diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator.client/runclient.sh b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator.client/runclient.sh
new file mode 100755
index 0000000000..feae29d557
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator.client/runclient.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# 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.
+
+APFULLDIR=`pwd`
+
+if [ x$TUSCANY_SCACPP = x ]; then
+echo "TUSCANY_SCACPP not set"
+exit;
+fi
+echo "Using SCA installed at $TUSCANY_SCACPP"
+
+if [ x$TUSCANY_SDOCPP = x ]; then
+echo "TUSCANY_SDOCPP not set"
+exit;
+fi
+echo "Using SDO installed at $TUSCANY_SDOCPP"
+
+export LD_LIBRARY_PATH=$TUSCANY_SCACPP/extensions/cpp/lib:$TUSCANY_SCACPP/lib:$TUSCANY_SDOCPP/lib:$LD_LIBRARY_PATH
+
+export TUSCANY_SCACPP_ROOT=$APFULLDIR/../
+export TUSCANY_SCACPP_COMPONENT=sample.calculator.CalculatorComponent
+
+./calculator_client div 5 2
diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/Calculator.h b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/Calculator.h
new file mode 100644
index 0000000000..90e97b5319
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/Calculator.h
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef sample_calculator_h
+#define sample_calculator_h
+
+class Calculator
+{
+public:
+ virtual float add(float arg1, float arg2) = 0;
+ virtual float sub(float arg1, float arg2) = 0;
+ virtual float mul(float arg1, float arg2) = 0;
+ virtual float div(float arg1, float arg2) = 0;
+};
+
+#endif // sample_calculator_h
diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/CalculatorImpl.componentType b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/CalculatorImpl.componentType
new file mode 100644
index 0000000000..72fe9842e8
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/CalculatorImpl.componentType
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0">
+
+ <service name="CalculatorService">
+ <interface.cpp header="Calculator.h"/>
+ </service>
+
+ <reference name="divideService">
+ <interface.cpp header="Divide.h"/>
+ </reference>
+
+</componentType> \ No newline at end of file
diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/CalculatorImpl.cpp b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/CalculatorImpl.cpp
new file mode 100644
index 0000000000..01dac77c92
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/CalculatorImpl.cpp
@@ -0,0 +1,90 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include <stdio.h>
+
+#include "osoa/sca/ComponentContext.h"
+#include "osoa/sca/ServiceRuntimeException.h"
+
+#include "CalculatorImpl.h"
+#include "Divide.h"
+
+CalculatorImpl::CalculatorImpl()
+{
+}
+
+CalculatorImpl::~CalculatorImpl()
+{
+}
+
+// Calculator interface
+float CalculatorImpl::add(float arg1, float arg2)
+{
+ float result = arg1 + arg2;
+
+ printf("CalculatorImpl::add %f + %f = %f\n", arg1, arg2, result);
+ return result;
+}
+
+float CalculatorImpl::sub(float arg1, float arg2)
+{
+ float result = arg1 - arg2;
+ printf("CalculatorImpl::sub %f - %f = %f\n", arg1, arg2, result);
+ return result;
+}
+
+float CalculatorImpl::mul(float arg1, float arg2)
+{
+ float result = arg1 * arg2;
+ printf("CalculatorImpl::mul %f * %f = %f\n", arg1, arg2, result);
+ return result;
+}
+
+float CalculatorImpl::div(float arg1, float arg2)
+{
+ float result = 0;
+
+ // This method shows how to invoke a service on a different component from within a component
+
+ // First, get the current ComponentContext
+ osoa::sca::ComponentContext myContext = osoa::sca::ComponentContext::getCurrent();
+
+ try
+ {
+ // Find the required service, as referenced in CalculatorImpl.componentType
+ Divide* divideService = (Divide*)myContext.getService("divideService");
+
+ // Finally, invoke the service
+ result = divideService->divide(arg1, arg2);
+
+ printf("CalculatorImpl::div Divide returned result: %f\n", result);
+
+ }
+ catch (osoa::sca::ServiceRuntimeException& e)
+ {
+ // Print out error message and carry on
+ printf("CalculatorImpl::div Error whilst invoking Divide: %s", e.getMessageText());
+ }
+
+ return result;
+}
+
+
diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/CalculatorImpl.h b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/CalculatorImpl.h
new file mode 100644
index 0000000000..af8a5eeab1
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/CalculatorImpl.h
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef sample_calculatorimpl_h
+#define sample_calculatorimpl_h
+
+#include "Calculator.h"
+
+class CalculatorImpl : public Calculator
+{
+public:
+ CalculatorImpl();
+ virtual ~CalculatorImpl();
+
+ // Calculator interface
+ virtual float add(float arg1, float arg2);
+ virtual float sub(float arg1, float arg2);
+ virtual float mul(float arg1, float arg2);
+ virtual float div(float arg1, float arg2);
+};
+
+#endif // sample_calculatorimpl_h
+
diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/Divide.h b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/Divide.h
new file mode 100644
index 0000000000..6e171ed733
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/Divide.h
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#ifndef sample_divide_h
+#define sample_divide_h
+
+class Divide
+{
+public:
+ virtual float divide(float arg1, float arg2) = 0;
+};
+
+#endif // sample_divide_h
+
+
diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/DivideImpl.componentType b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/DivideImpl.componentType
new file mode 100644
index 0000000000..d7369e3ff0
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/DivideImpl.componentType
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0">
+
+ <service name="DivideService">
+ <interface.cpp header="Divide.h"/>
+ </service>
+
+</componentType>
diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/DivideImpl.cpp b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/DivideImpl.cpp
new file mode 100644
index 0000000000..f1a927cf4c
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/DivideImpl.cpp
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include <stdio.h>
+
+#include "DivideImpl.h"
+
+DivideImpl::DivideImpl()
+{
+}
+
+DivideImpl::~DivideImpl()
+{
+}
+
+// Divide interface
+float DivideImpl::divide(float arg1, float arg2)
+{
+ if(arg2 == 0.0)
+ {
+ printf("DivideImpl::div %f / %f !! Cannot divide by zero, so returning 0\n", arg1, arg2);
+ return 0;
+ }
+
+ float result = arg1 / arg2;
+ printf("DivideImpl::div %f / %f = %f\n", arg1, arg2, result);
+ return result;
+}
+
+
diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/DivideImpl.h b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/DivideImpl.h
new file mode 100644
index 0000000000..64045f1899
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/DivideImpl.h
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#ifndef sample_divideimpl_h
+#define sample_divideimpl_h
+
+#include "Divide.h"
+
+class DivideImpl : public Divide
+{
+public:
+ DivideImpl();
+ virtual ~DivideImpl();
+
+ // Divide interface
+ virtual float divide(float arg1, float arg2);
+};
+
+#endif // sample_divideimpl_h
+
diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/Makefile.am b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/Makefile.am
new file mode 100644
index 0000000000..de6dad787d
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/Makefile.am
@@ -0,0 +1,53 @@
+# 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.
+
+deploydir=$(prefix)/CppCalculator/deploy
+compositedir=$(deploydir)/sample.calculator
+
+BUILT_SOURCES = scagen
+
+noinst_HEADERS = *.h
+
+scagen:
+ java -jar $(TUSCANY_SCACPP)/bin/scagen.jar -dir . -output .
+
+composite_LTLIBRARIES = libCalculator.la
+composite_DATA = *.composite *.componentType
+EXTRA_DIST = *.composite *.componentType
+
+dist_libCalculator_la_SOURCES = \
+CalculatorImpl.cpp \
+DivideImpl.cpp
+
+nodist_libCalculator_la_SOURCES = \
+CalculatorImpl_CalculatorService_Proxy.cpp \
+CalculatorImpl_CalculatorService_Wrapper.cpp \
+CalculatorImpl_divideService_Proxy.cpp \
+DivideImpl_DivideService_Proxy.cpp \
+DivideImpl_DivideService_Wrapper.cpp
+
+libCalculator_la_LIBADD = \
+-L${TUSCANY_SCACPP}/lib \
+ -ltuscany_sca \
+-L${TUSCANY_SCACPP}/extensions/cpp/lib \
+ -ltuscany_sca_cpp
+
+INCLUDES = \
+-I$(TUSCANY_SCACPP)/extensions/cpp/include \
+-I$(TUSCANY_SCACPP)/include \
+-I${TUSCANY_SDOCPP}/include
+
diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/sample.calculator.composite b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/sample.calculator.composite
new file mode 100644
index 0000000000..6903cf21d8
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/samples/CppCalculator/sample.calculator/sample.calculator.composite
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ name="sample.calculator">
+
+ <component name="CalculatorComponent">
+ <implementation.cpp library="Calculator" header="CalculatorImpl.h"/>
+ <reference name="divideService">DivideComponent/DivideService</reference>
+ </component>
+
+ <component name="DivideComponent">
+ <implementation.cpp library="Calculator" header="DivideImpl.h"/>
+ </component>
+
+</composite> \ No newline at end of file