From 36adc76235fb0a38e7042bc751f988b71627e2a0 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Tue, 11 Dec 2012 06:13:02 +0000 Subject: Changes to get successful C++11 based build. Code cleanup, dependency upgrades, and const + inline optimizations in components, samples, and app hosting server. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1420007 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/samples/store-cpp/fruits-catalog.cpp | 22 +++++++--------------- sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp | 14 +++++++------- 2 files changed, 14 insertions(+), 22 deletions(-) (limited to 'sca-cpp/trunk/samples/store-cpp') diff --git a/sca-cpp/trunk/samples/store-cpp/fruits-catalog.cpp b/sca-cpp/trunk/samples/store-cpp/fruits-catalog.cpp index 9907650316..16f01cd85c 100644 --- a/sca-cpp/trunk/samples/store-cpp/fruits-catalog.cpp +++ b/sca-cpp/trunk/samples/store-cpp/fruits-catalog.cpp @@ -35,27 +35,19 @@ namespace store { /** * Returns the catalog. */ -struct convert { - const lambda&)> converter; - const string currency; - convert(const lambda&)>& converter, const string& currency) : converter(converter), currency(currency) { - } - const value operator()(const value& price) const { - return converter(mklist("convert", string("USD"), currency, price)); - } -}; - const list mkfruit(const string& name, const string& code, const string& symbol, const double price) { - return list() + + return nilListValue + mklist("name", name) + mklist("currencyCode", code) + mklist("currencySymbol", symbol) + mklist("price", price); } -const failable items(const lambda&)>& converter, const lambda&)>& currencyCode) { - const string currency(currencyCode(list())); +const failable items(const lvvlambda& converter, const lvvlambda& currencyCode) { + const string currency(currencyCode(nilListValue)); const string symbol(converter(mklist("symbol", currency))); - const lambda conv(convert(converter, currency)); + const vvlambda conv = [converter, currency](const value& price) -> const value { + return converter(mklist("convert", string("USD"), currency, price)); + }; - return value(list() + + return value(nilListValue + mkfruit("Apple", currency, symbol, conv(2.99)) + mkfruit("Orange", currency, symbol, conv(3.55)) + mkfruit("Pear", currency, symbol, conv(1.55))); diff --git a/sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp b/sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp index 2771d7cd9c..e65aa0d392 100644 --- a/sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp +++ b/sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp @@ -38,7 +38,7 @@ const string cartId("1234"); * Get the shopping cart from the cache. Return an empty * cart if not found. */ -const list getcart(const value& id, const lambda&)>& cache) { +const list getcart(const value& id, const lvvlambda& cache) { const value cart = cache(mklist("get", mklist(id))); cerr << "cart value: " << cart << "\n"; const failable fcart = cart; @@ -46,14 +46,14 @@ const list getcart(const value& id, const lambda& cerr << "cart content: " << content(fcart) << "\n"; cerr << "cart reason: " << reason(fcart) << "\n"; if (isNil(cart)) - return value(list()); + return value(nilListValue); return (list)cart; } /** * Post a new item to the cart. Create a new cart if necessary. */ -const failable post(unused const list& collection, const value& item, const lambda&)>& cache) { +const failable post(unused const list& collection, const value& item, const lvvlambda& cache) { const value id(mkuuid()); const list newItem(mklist("entry", cadr(car(item)), mklist("id", id), cadddr(car(item)))); const list cart(cons(newItem, getcart(cartId, cache))); @@ -75,7 +75,7 @@ const value find(const value& id, const list& cart) { /** * Return items from the cart. */ -const failable get(const list& id, const lambda&)>& cache) { +const failable get(const list& id, const lvvlambda& cache) { if (isNil(id)) return value(mklist(append(mklist("feed", mklist("title", string("Your Cart")), mklist("id", cartId)), getcart(cartId, cache)))); return find(car(id), getcart(cartId, cache)); @@ -84,10 +84,10 @@ const failable get(const list& id, const lambda del(const list& id, unused const lambda&)>& cache) { +const failable del(const list& id, unused const lvvlambda& cache) { if (isNil(id)) return cache(mklist("delete", mklist(cartId))); - return value(true); + return trueValue; } /** @@ -109,7 +109,7 @@ const double sum(const list& items) { /** * Return the total price of the items in the cart. */ -const failable total(const lambda&)>& cache) { +const failable total(const lvvlambda& cache) { const list cart(getcart(cartId, cache)); return value(sum(cart)); } -- cgit v1.2.3