Example #1
0
bool get_omii_gridsam_contexts(saga::session s, std::vector<saga::context>& ctxs_)
{
    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))
            continue;

        if ("omii_gridsam" == (*it).get_attribute(saga::attributes::context_type))
            ctxs_.push_back(*it);
    }
    return !ctxs_.empty();
}
  // returns a clone of the given session, but without any ssh context.  That
  // way we ensure that future calls in that stripped session will not arrive 
  // in this adaptor again, ever (see also the comment on adaptor preferences 
  // in adaptor_register().
  saga::session filesystem_adaptor::strip_session (const saga::session & s)
  {
    saga::session ret = static_cast <saga::session> (s.clone ());

    std::vector <saga::context> cs = ret.list_contexts ();

    for ( unsigned int i = 0; i < cs.size (); i++ )
    {
      if ( cs[i].get_attribute (saga::attributes::context_type) == "ssh" )
      {
        ret.remove_context (cs[i]);
      }
    }

    return ret;
  }
  void filesystem_adaptor::dump_session (const std::string   & msg, 
                                         const saga::session & s)
  {
    std::cout << " ---------------------------- " << std::endl;
    std::cout << " -- " << msg << " -- "          << std::endl;
    std::cout << " ---------------------------- " << std::endl;

    std::vector <saga::context> cs = s.list_contexts ();
    std::cout << " found " << cs.size () << " contexts " << std::endl;

    for ( unsigned int i = 0; i < cs.size (); i++ )
    {
      std::cout << "  " << i << ": " << cs[i].get_attribute ("Type") << std::endl;
    }

    std::cout << " ---------------------------- " << std::endl;
  }