[Saga-devel] Context question

Hartmut Kaiser hkaiser at cct.lsu.edu
Tue Jan 27 10:18:05 CST 2009


Paul,

> > Further to your email from last week one further question.  If I
> needed
> > vector attributes on my context (which I do) how would stage 4 below
> > work?  I presume that vector attributes are allowed.
> 
> Ohh well. I didn't even think about that yet. So it's currently not
> supported. But I think it should be easy enough to add. What's your
> timeline
> on this?

Actually, after looking into this it turned out to be _really_ simple to
implement, so I went ahead and added a 

  void saga::impl::session::add_proto_context(
    std::vector<std::pair<std::string, std::string> > const&,
    std::vector<std::pair<std::string, std::vector<std::string> > > const&
  ); 

function overload allowing to specify not only the non-vector attributes as
before, but takes a list of proto-vector-attributes as well. Please use this
instead of the old function if you need to predefine at least one vector
attribute.

HTH
Regards Hartmut

> 
> Regards Hartmut
> 
> >
> > Thanks,
> >
> > Paul.
> >
> > -----Original Message-----
> > From: saga-devel-bounces at cct.lsu.edu
> > [mailto:saga-devel-bounces at cct.lsu.edu] On Behalf Of Hartmut Kaiser
> > Sent: 21 January 2009 13:59
> > To: saga-devel at cct.lsu.edu
> > Subject: RE: [Saga-devel] Context question
> >
> >
> > 4) Create a proto-context of your type in the constructor of the
> > adaptor
> > instance (not the CPI!), see default_advert_adaptor.cpp. This has to
> be
> > done
> > only if the session is the default one (only default sessions are
> > filled
> > with default contexts). Use sensible defaults for all attributes:
> >
> >     // create a default security context, if needed
> >     if (s->is_default_session())
> >     {
> >         typedef std::pair<std::string, std::string> entry_type;
> >         using namespace boost::assign;
> >         std::vector<entry_type> entries;
> >
> >         entries +=
> >             entry_type(saga::attributes::context_type,
> > "default_advert_db"),
> >             entry_type(saga::attributes::context_userid, "SAGA"),
> >             entry_type(saga::attributes::context_userpass,
> > "SAGA_client")
> >         ;
> >         s->add_proto_context(entries);
> >     }
> >
> > That's it. All what's left now is in your adaptor to check for your
> > context
> > in the current session when you need the related information:
> >
> >     std::vector<saga::context> ctxs(s.list_contexts());
> >     std::vector<saga::context>::iterator end = ctxs.end();
> >     for (std::vector<saga::context>::iterator it = ctxs.begin(); it
> !=
> > end;
> > ++it)
> >     {
> >         if ((*it).attribute_exists("saga::attributes::context_type")
> &&
> >             "default_advert_db" ==
> > (*it).get_attribute(saga::attributes::context_type))
> >         {
> >             ...=
> > (*it).get_attribute(saga::attributes::context_userid));
> >             ...=
> > (*it).get_attribute(saga::attributes::context_userpass));
> >             break;
> >         }
> >     }
> >
> > Users will have to create a new context using your type, filling in
> > their
> > attributes, and adding this to the sessions object used to create
> your
> > API
> > object:
> >
> >     saga::context ctx("default_advert_db");
> >     ctx.set_attribute(saga::attributes::context_userid, "...");
> >     ctx.set_attribute(saga::attributes::context_userpass, "...");
> >
> >     saga::session s;
> >     s.add_context(ctx);
> >
> >     saga::advert::entry adv(s, ...);
> >
> > HTH
> > Regards Hartmut
> >
> >
> >
> > _______________________________________________
> > saga-devel mailing list
> > saga-devel at cct.lsu.edu
> > https://mail.cct.lsu.edu/mailman/listinfo/saga-devel
> > --
> > Scanned by iCritical.
> 
> _______________________________________________
> saga-devel mailing list
> saga-devel at cct.lsu.edu
> https://mail.cct.lsu.edu/mailman/listinfo/saga-devel



More information about the saga-devel mailing list