From 1c2df9a2458897ff6c2393913b2723457e42a0da Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Mon, 23 Nov 2009 05:48:11 +0000 Subject: Simplified the automake build using configure options instead of environment variables and cleaned up some of the makefile.am files. Adjusted build instructions. Moved directories that don't yet build or work out of the main build dir and obsolete docs to a contrib dir. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@883254 13f79535-47bb-0310-9956-ffa450edef68 --- .../CppCalculator/sample.calculator/Calculator.h | 34 ++++++++ .../sample.calculator/CalculatorImpl.componentType | 31 ++++++++ .../sample.calculator/CalculatorImpl.cpp | 90 ++++++++++++++++++++++ .../sample.calculator/CalculatorImpl.h | 41 ++++++++++ .../CppCalculator/sample.calculator/Divide.h | 34 ++++++++ .../sample.calculator/DivideImpl.componentType | 27 +++++++ .../CppCalculator/sample.calculator/DivideImpl.cpp | 48 ++++++++++++ .../CppCalculator/sample.calculator/DivideImpl.h | 39 ++++++++++ .../CppCalculator/sample.calculator/Makefile.am | 53 +++++++++++++ .../sample.calculator/sample.calculator.composite | 33 ++++++++ 10 files changed, 430 insertions(+) create mode 100644 sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator/Calculator.h create mode 100644 sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator/CalculatorImpl.componentType create mode 100644 sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator/CalculatorImpl.cpp create mode 100644 sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator/CalculatorImpl.h create mode 100644 sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator/Divide.h create mode 100644 sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator/DivideImpl.componentType create mode 100644 sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator/DivideImpl.cpp create mode 100644 sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator/DivideImpl.h create mode 100644 sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator/Makefile.am create mode 100644 sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator/sample.calculator.composite (limited to 'sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator') diff --git a/sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator/Calculator.h b/sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator/Calculator.h new file mode 100644 index 0000000000..90e97b5319 --- /dev/null +++ b/sca-cpp/trunk/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/trunk/contrib/samples/CppCalculator/sample.calculator/CalculatorImpl.componentType b/sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator/CalculatorImpl.componentType new file mode 100644 index 0000000000..72fe9842e8 --- /dev/null +++ b/sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator/CalculatorImpl.componentType @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator/CalculatorImpl.cpp b/sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator/CalculatorImpl.cpp new file mode 100644 index 0000000000..01dac77c92 --- /dev/null +++ b/sca-cpp/trunk/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 + +#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/trunk/contrib/samples/CppCalculator/sample.calculator/CalculatorImpl.h b/sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator/CalculatorImpl.h new file mode 100644 index 0000000000..af8a5eeab1 --- /dev/null +++ b/sca-cpp/trunk/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/trunk/contrib/samples/CppCalculator/sample.calculator/Divide.h b/sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator/Divide.h new file mode 100644 index 0000000000..6e171ed733 --- /dev/null +++ b/sca-cpp/trunk/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/trunk/contrib/samples/CppCalculator/sample.calculator/DivideImpl.componentType b/sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator/DivideImpl.componentType new file mode 100644 index 0000000000..d7369e3ff0 --- /dev/null +++ b/sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator/DivideImpl.componentType @@ -0,0 +1,27 @@ + + + + + + + + + + diff --git a/sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator/DivideImpl.cpp b/sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator/DivideImpl.cpp new file mode 100644 index 0000000000..f1a927cf4c --- /dev/null +++ b/sca-cpp/trunk/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 + +#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/trunk/contrib/samples/CppCalculator/sample.calculator/DivideImpl.h b/sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator/DivideImpl.h new file mode 100644 index 0000000000..64045f1899 --- /dev/null +++ b/sca-cpp/trunk/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/trunk/contrib/samples/CppCalculator/sample.calculator/Makefile.am b/sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator/Makefile.am new file mode 100644 index 0000000000..de6dad787d --- /dev/null +++ b/sca-cpp/trunk/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/trunk/contrib/samples/CppCalculator/sample.calculator/sample.calculator.composite b/sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator/sample.calculator.composite new file mode 100644 index 0000000000..6903cf21d8 --- /dev/null +++ b/sca-cpp/trunk/contrib/samples/CppCalculator/sample.calculator/sample.calculator.composite @@ -0,0 +1,33 @@ + + + + + + + + DivideComponent/DivideService + + + + + + + \ No newline at end of file -- cgit v1.2.3