[Saga-devel] saga SVN commit 3395: /trunk/saga/impl/engine/
Andre Merzky
andre at merzky.net
Tue Jan 27 16:34:37 CST 2009
Quoting [hkaiser at cct.lsu.edu] (Jan 27 2009):
>
> User: hkaiser
> Date: 2009/01/27 10:13 AM
>
> Modified:
> /trunk/saga/impl/engine/
> session.cpp, session.hpp
>
> Log:
> Added possibility to use vector attributes for the proto-context initialization.
> Context objects now have extensible attribute set.
Sorry for not looking at the diff - but is that on API or on
CPI level? On API level, context should have
non-extensible attributes, and there are no vector
attributes defined...
Cheers, Andre.
> File Changes:
>
> Directory: /trunk/saga/impl/engine/
> ===================================
>
> File [modified]: session.cpp
> Delta lines: +73 -15
> ===================================================================
> --- trunk/saga/impl/engine/session.cpp 2009-01-26 13:32:30 UTC (rev 3394)
> +++ trunk/saga/impl/engine/session.cpp 2009-01-27 16:13:17 UTC (rev 3395)
> @@ -16,6 +16,13 @@
> ///////////////////////////////////////////////////////////////////////////
> struct base_context_list
> {
> + typedef
> + std::vector<std::pair<std::string, std::string> >
> + proto_context_type;
> + typedef
> + std::vector<std::pair<std::string, std::vector<std::string> > >
> + vector_proto_context_type;
> +
> base_context_list(saga::impl::session const* s)
> : session_(s)
> {}
> @@ -39,11 +46,16 @@
> SAGA_THROW_VERBATIM(session_, "Not implemented", saga::NotImplemented);
> }
> virtual void
> - add_proto_context(
> - std::vector<std::pair<std::string, std::string> > const& entries)
> + add_proto_context(proto_context_type const& entries)
> {
> SAGA_THROW_VERBATIM(session_, "Not implemented", saga::NotImplemented);
> }
> + virtual void
> + add_proto_context(proto_context_type const& entries,
> + vector_proto_context_type const& vector_entries)
> + {
> + SAGA_THROW_VERBATIM(session_, "Not implemented", saga::NotImplemented);
> + }
>
> saga::impl::session const* session_;
> };
> @@ -63,14 +75,22 @@
> }
>
> // make a temporary copy of the keys and values
> - void add_proto_context(
> - std::vector<std::pair<std::string, std::string> > const& entries)
> + void add_proto_context(proto_context_type const& entries)
> {
> entries_.push_back(entries);
> + vector_entries_.push_back(vector_proto_context_type());
> }
>
> - typedef std::vector<std::pair<std::string, std::string> > proto_context_type;
> + // make a temporary copy of the keys and values
> + void add_proto_context(proto_context_type const& entries,
> + vector_proto_context_type const& vector_entries)
> + {
> + entries_.push_back(entries);
> + vector_entries_.push_back(vector_entries);
> + }
> +
> std::vector<proto_context_type> entries_;
> + std::vector<vector_proto_context_type> vector_entries_;
> };
>
> ///////////////////////////////////////////////////////////////////////////
> @@ -93,11 +113,13 @@
> {
> saga::context c;
> try {
> + // add non-vector attributes
> std::vector<std::pair<std::string, std::string> >& entries =
> protolist->entries_[i];
>
> bool has_type = false;
> - for (std::size_t k = 0; k < entries.size(); ++k) {
> + for (std::size_t k = 0; k < entries.size(); ++k)
> + {
> if (entries[k].first == saga::attributes::context_type)
> has_type = true;
>
> @@ -108,6 +130,16 @@
> "List of attribute keys does not contain the context's "
> "'type'", saga::BadParameter);
> }
> +
> + // add vector_attributes
> + vector_proto_context_type& vector_entries =
> + protolist->vector_entries_[i];
> + for (std::size_t v = 0; v < vector_entries.size(); ++v)
> + {
> + c.set_vector_attribute(vector_entries[v].first,
> + vector_entries[v].second);
> + }
> +
> c.set_defaults();
> }
> catch (saga::exception const&) {
> @@ -181,10 +213,14 @@
> std::vector<saga::context> session::list_contexts() const
> {
> mutex_type::scoped_lock lock(mtx_);
> - if (NULL == contexts_)
> + if (NULL == contexts_) {
> contexts_ = new context_list(this);
> - else if (contexts_->is_proto_context())
> + }
> + else if (contexts_->is_proto_context()) {
> + base_context_list* oldctxs = contexts_;
> contexts_ = new context_list(this, (proto_context_list*)contexts_);
> + delete oldctxs;
> + }
>
> return ((context_list*)contexts_)->contexts_; // make a copy
> }
> @@ -197,10 +233,14 @@
> {
> // create context list if needed
> mutex_type::scoped_lock lock(mtx_);
> - if (NULL == contexts_)
> - contexts_ = new context_list(this);
> - else if (contexts_->is_proto_context())
> - contexts_ = new context_list(this, (proto_context_list*)contexts_);
> + if (NULL == contexts_) {
> + contexts_ = new context_list(this);
> + }
> + else if (contexts_->is_proto_context()) {
> + base_context_list* oldctxs = contexts_;
> + contexts_ = new context_list(this, (proto_context_list*)contexts_);
> + delete oldctxs;
> + }
>
> // can we keep defaults?
> if ( use_defaults )
> @@ -226,8 +266,8 @@
>
> void session::add_context (saga::context const& c)
> {
> - // add context, but do not keep defaults
> - add_context (c, false);
> + // add context, but do not keep defaults
> + add_context (c, false);
> }
>
> void session::remove_context (saga::context const& c)
> @@ -237,8 +277,11 @@
> SAGA_THROW("remove_context: context does not exist",
> saga::DoesNotExist);
> }
> - else if (contexts_->is_proto_context())
> + else if (contexts_->is_proto_context()) {
> + base_context_list* oldctxs = contexts_;
> contexts_ = new context_list(this, (proto_context_list*)contexts_);
> + delete oldctxs;
> + }
>
> contexts_->remove_context(c);
> }
> @@ -257,6 +300,21 @@
> contexts_->add_proto_context(entries);
> }
>
> + void session::add_proto_context (
> + std::vector<std::pair<std::string, std::string> > const& entries,
> + std::vector<std::pair<std::string, std::vector<std::string> > > const& vector_entries)
> + {
> + if (NULL == contexts_)
> + contexts_ = new proto_context_list(this);
> +
> + if (!contexts_->is_proto_context()) {
> + SAGA_THROW("Out of order execution of 'add_proto_context'. This "
> + "should be called during adaptor construction only.",
> + saga::NoSuccess);
> + }
> + contexts_->add_proto_context(entries, vector_entries);
> + }
> +
> void session::release_contexts()
> {
> mutex_type::scoped_lock lock(mtx_);
>
> File [modified]: session.hpp
> Delta lines: +4 -0
> ===================================================================
> --- trunk/saga/impl/engine/session.hpp 2009-01-26 13:32:30 UTC (rev 3394)
> +++ trunk/saga/impl/engine/session.hpp 2009-01-27 16:13:17 UTC (rev 3395)
> @@ -107,6 +107,10 @@
> SAGA_EXPORT void add_proto_context (
> std::vector<std::pair<std::string, std::string> > const& entries);
>
> + SAGA_EXPORT void add_proto_context (
> + std::vector<std::pair<std::string, std::string> > const& entries,
> + std::vector<std::pair<std::string, std::vector<std::string> > > const& vector_entries);
> +
> /**
> * Returns the context attached to the session
> *
>
> _______________________________________________
> saga-devel mailing list
> saga-devel at cct.lsu.edu
> https://mail.cct.lsu.edu/mailman/listinfo/saga-devel
--
Nothing is ever easy.
More information about the saga-devel
mailing list