// Copyright (c) 2005-2007 Andre Merzky (andre@merzky.net) // Copyright (c) 2005-2007 Hartmut Kaiser (hartmut.kaiser@gmail.com) // // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /////////////////////////////////////////////////////////////////////////////// namespace saga { namespace impl { /////////////////////////////////////////////////////////////////////////// attribute::attribute (void) : cache_only_(false) { } // copy constructor attribute::attribute (attribute const& rhs) : attributes_(rhs.attributes_), cache_only_(rhs.cache_only_) { } bool attribute::is_valid_key(std::string const& key) const { return attributes_.is_valid_key(key); } void attribute::init (bool extensible, bool cache_only) { cache_only_ = cache_only; attributes_.init(extensible); } void attribute::init (strmap_type const& ro_scalar, strmap_type const& rw_scalar, strmap_type const& ro_vector, strmap_type const& rw_vector) { attributes_.init(ro_scalar, rw_scalar, ro_vector, rw_vector); } void attribute::init_keynames(strvec_type const& keynames) { attributes_.init_keynames(keynames); } bool attribute::attributes_extensible (void) const { return attributes_.attributes_extensible(); } attribute attribute::clone() const { return *this; } bool attribute::is_equal(attribute const& rhs) const { return attributes_.is_equal(rhs.attributes_); } /////////////////////////////////////////////////////////////////////////// saga::impl::proxy* attribute::get_proxy() { SAGA_THROW( "This object does not expose the SAGA proxy interface", saga::NotImplemented); return NULL; } saga::impl::proxy const* attribute::get_proxy() const { SAGA_THROW( "This object does not expose the SAGA proxy interface", saga::NotImplemented); return NULL; } /////////////////////////////////////////////////////////////////////////// // API functions, these get routed through a adaptor (if one exists) and // otherwise use the implementation of the associated attribute_cache task_type attribute::get_attribute (std::string& ret, std::string key, bool sync) { if (!cache_only_) { typedef saga::impl::v1_0::attribute_cpi attribute_cpi; saga::impl::v1_0::preference_type prefs; return saga::impl::execute_sync_async(get_proxy(), "attribute_cpi", "get_attribute", "attribute::get_attribute", prefs, sync, &attribute_cpi::sync_get_attribute, &attribute_cpi::async_get_attribute, TR1::ref(ret), key); } ret = attributes_.get_attribute(key); return task_type(task_type::Done); } /////////////////////////////////////////////////////////////////////////// task_type attribute::set_attribute (saga::void_t& ret, std::string key, std::string val, bool sync) { if (!cache_only_) { typedef saga::impl::v1_0::attribute_cpi attribute_cpi; saga::impl::v1_0::preference_type prefs; return saga::impl::execute_sync_async(get_proxy(), "attribute_cpi", "set_attribute", "attribute::set_attribute", prefs, sync, &attribute_cpi::sync_set_attribute, &attribute_cpi::async_set_attribute, TR1::ref(ret), key, val); } attributes_.set_attribute(key, val); return task_type(task_type::Done); } /////////////////////////////////////////////////////////////////////////// task_type attribute::set_vector_attribute (saga::void_t& ret, std::string key, strvec_type val, bool sync) { if (!cache_only_) { typedef saga::impl::v1_0::attribute_cpi attribute_cpi; saga::impl::v1_0::preference_type prefs; return saga::impl::execute_sync_async(get_proxy(), "attribute_cpi", "set_vector_attribute", "attribute::set_vector_attribute", prefs, sync, &attribute_cpi::sync_set_vector_attribute, &attribute_cpi::async_set_vector_attribute, TR1::ref(ret), key, val); } attributes_.set_vector_attribute(key, val); return task_type(task_type::Done); } /////////////////////////////////////////////////////////////////////////// // set/get vector attribute task_type attribute::get_vector_attribute (attribute::strvec_type& ret, std::string key, bool sync) { if (!cache_only_) { typedef saga::impl::v1_0::attribute_cpi attribute_cpi; saga::impl::v1_0::preference_type prefs; return saga::impl::execute_sync_async(get_proxy(), "attribute_cpi", "get_vector_attribute", "attribute::get_vector_attribute", prefs, sync, &attribute_cpi::sync_get_vector_attribute, &attribute_cpi::async_get_vector_attribute, TR1::ref(ret), key); } ret = attributes_.get_vector_attribute(key); return task_type(task_type::Done); } /////////////////////////////////////////////////////////////////////////// task_type attribute::remove_attribute (saga::void_t& ret, std::string key, bool sync) { if (!cache_only_) { typedef saga::impl::v1_0::attribute_cpi attribute_cpi; saga::impl::v1_0::preference_type prefs; return saga::impl::execute_sync_async(get_proxy(), "attribute_cpi", "remove_attribute", "attribute::remove_attribute", prefs, sync, &attribute_cpi::sync_remove_attribute, &attribute_cpi::async_remove_attribute, TR1::ref(ret), key); } attributes_.remove_attribute(key); return task_type(task_type::Done); } /////////////////////////////////////////////////////////////////////////// // list attribute task_type attribute::list_attributes (attribute::strvec_type& ret, bool sync) { if (!cache_only_) { typedef saga::impl::v1_0::attribute_cpi attribute_cpi; saga::impl::v1_0::preference_type prefs; return saga::impl::execute_sync_async(get_proxy(), "attribute_cpi", "list_attributes", "attribute::list_attributes", prefs, sync, &attribute_cpi::sync_list_attributes, &attribute_cpi::async_list_attributes, TR1::ref(ret)); } ret = attributes_.list_attributes(); return task_type(task_type::Done); } /////////////////////////////////////////////////////////////////////////// task_type attribute::find_attributes (attribute::strvec_type& ret, std::string pattern, bool sync) { if (!cache_only_) { typedef saga::impl::v1_0::attribute_cpi attribute_cpi; saga::impl::v1_0::preference_type prefs; return saga::impl::execute_sync_async(get_proxy(), "attribute_cpi", "find_attributes", "attribute::find_attributes", prefs, sync, &attribute_cpi::sync_find_attributes, &attribute_cpi::async_find_attributes, TR1::ref(ret), pattern); } ret = attributes_.find_attributes(pattern); return task_type(task_type::Done); } /////////////////////////////////////////////////////////////////////////// task_type attribute::attribute_exists (bool& ret, std::string key, bool sync) { if (!cache_only_) { typedef saga::impl::v1_0::attribute_cpi attribute_cpi; saga::impl::v1_0::preference_type prefs; return saga::impl::execute_sync_async(get_proxy(), "attribute_cpi", "attribute_exists", "attribute::attribute_exists", prefs, sync, &attribute_cpi::sync_attribute_exists, &attribute_cpi::async_attribute_exists, TR1::ref(ret), key); } ret = attributes_.attribute_exists(key); return task_type(task_type::Done); } /////////////////////////////////////////////////////////////////////////// task_type attribute::attribute_is_readonly (bool& ret, std::string key, bool sync) { if (!cache_only_) { typedef saga::impl::v1_0::attribute_cpi attribute_cpi; saga::impl::v1_0::preference_type prefs; return saga::impl::execute_sync_async(get_proxy(), "attribute_cpi", "attribute_is_readonly", "attribute::attribute_is_readonly", prefs, sync, &attribute_cpi::sync_attribute_is_readonly, &attribute_cpi::async_attribute_is_readonly, TR1::ref(ret), key); } ret = attributes_.attribute_is_readonly(key); return task_type(task_type::Done); } /////////////////////////////////////////////////////////////////////////// task_type attribute::attribute_is_writable (bool& ret, std::string key, bool sync) { if (!cache_only_) { typedef saga::impl::v1_0::attribute_cpi attribute_cpi; saga::impl::v1_0::preference_type prefs; return saga::impl::execute_sync_async(get_proxy(), "attribute_cpi", "attribute_is_writable", "attribute::attribute_is_writable", prefs, sync, &attribute_cpi::sync_attribute_is_writable, &attribute_cpi::async_attribute_is_writable, TR1::ref(ret), key); } ret = attributes_.attribute_is_writable(key); return task_type(task_type::Done); } /////////////////////////////////////////////////////////////////////////// task_type attribute::attribute_is_vector (bool& ret, std::string key, bool sync) { if (!cache_only_) { typedef saga::impl::v1_0::attribute_cpi attribute_cpi; saga::impl::v1_0::preference_type prefs; return saga::impl::execute_sync_async(get_proxy(), "attribute_cpi", "attribute_is_vector", "attribute::attribute_is_vector", prefs, sync, &attribute_cpi::sync_attribute_is_vector, &attribute_cpi::async_attribute_is_vector, TR1::ref(ret), key); } ret = attributes_.attribute_is_vector(key); return task_type(task_type::Done); } /////////////////////////////////////////////////////////////////////////// task_type attribute::attribute_is_extended (bool& ret, std::string key, bool sync) { if (!cache_only_) { typedef saga::impl::v1_0::attribute_cpi attribute_cpi; saga::impl::v1_0::preference_type prefs; return saga::impl::execute_sync_async(get_proxy(), "attribute_cpi", "attribute_is_extended", "attribute::attribute_is_extended", prefs, sync, &attribute_cpi::sync_attribute_is_extended, &attribute_cpi::async_attribute_is_extended, TR1::ref(ret), key); } ret = attributes_.attribute_is_extended(key); return task_type(task_type::Done); } /////////////////////////////////////////////////////////////////////////////// }} // namespace saga::impl