diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-01-17 09:02:29 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-01-17 09:02:29 +0000 |
commit | b00fe2747627bc95ac8d1d548e0621930a1775a2 (patch) | |
tree | 64561e332127d72763850196be5f0538cac9b8bb /sca-cpp/trunk/modules/server/mod-cpp.hpp | |
parent | 9cb610814d58da1ba2617f78e36e9635f2e7d508 (diff) |
Cleaned up test composite files. Adjusted C++ implementation elements to match the spec. Minor refactoring/terminology cleanup in HTTPD modules, renamed readImplementation to evalImplementation and evalImplementation to applyImplementation.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@900071 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/modules/server/mod-cpp.hpp')
-rw-r--r-- | sca-cpp/trunk/modules/server/mod-cpp.hpp | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/sca-cpp/trunk/modules/server/mod-cpp.hpp b/sca-cpp/trunk/modules/server/mod-cpp.hpp index 416ccabf39..f10b91dc28 100644 --- a/sca-cpp/trunk/modules/server/mod-cpp.hpp +++ b/sca-cpp/trunk/modules/server/mod-cpp.hpp @@ -23,7 +23,7 @@ #define tuscany_modcpp_hpp /** - * Evaluation functions used by mod-eval to evaluate implementation.cpp + * Evaluation functions used by mod-eval to evaluate C++ * component implementations. */ @@ -32,6 +32,7 @@ #include "function.hpp" #include "list.hpp" +#include "element.hpp" #include "value.hpp" #include "monad.hpp" #include "dynlib.hpp" @@ -43,31 +44,35 @@ namespace server { namespace modcpp { /** - * Evaluate a C++ component implementation function. + * Apply a C++ component implementation function. */ -struct evalImplementation { +struct applyImplementation { const lib ilib; const lambda<value(const list<value>&)> impl; const list<value> px; - evalImplementation(const lib& ilib, const lambda<value(const list<value>&)>& impl, const list<value>& px) : ilib(ilib), impl(impl), px(px) { + applyImplementation(const lib& ilib, const lambda<value(const list<value>&)>& impl, const list<value>& px) : ilib(ilib), impl(impl), px(px) { } const value operator()(const list<value>& params) const { - debug(params, "modeval::cpp::evalImplementation::input"); + debug(params, "modeval::cpp::applyImplementation::input"); const value val = impl(append(params, px)); - debug(val, "modeval::cpp::evalImplementation::result"); + debug(val, "modeval::cpp::applyImplementation::result"); return val; } }; /** - * Read a C++ component implementation. + * Evaluate a C++ component implementation and convert it to + * an applicable lambda function. */ -const failable<lambda<value(const list<value>&)> > readImplementation(const string& path, const list<value>& px) { - const lib ilib(*(new (gc_new<lib>()) lib(path + dynlibExt))); - const failable<lambda<value(const list<value>&)> > impl(dynlambda<value(const list<value>&)>("eval", ilib)); - if (!hasContent(impl)) - return impl; - return lambda<value(const list<value>&)>(evalImplementation(ilib, content(impl), px)); +const failable<lambda<value(const list<value>&)> > evalImplementation(const string& path, const value& impl, const list<value>& px) { + const value ipath(attributeValue("path", impl)); + const value iname(attributeValue("library", impl)); + const string fpath(isNil(ipath)? path + iname : path + ipath + "/" + iname); + const lib ilib(*(new (gc_new<lib>()) lib(fpath + dynlibExt))); + const failable<lambda<value(const list<value>&)> > evalf(dynlambda<value(const list<value>&)>("apply", ilib)); + if (!hasContent(evalf)) + return evalf; + return lambda<value(const list<value>&)>(applyImplementation(ilib, content(evalf), px)); } } |