[Saga-devel] Context question

Livesey, P (Paul) paul.livesey at stfc.ac.uk
Tue Jan 27 08:35:20 CST 2009


Hi Hartmut,

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.

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.


More information about the saga-devel mailing list