// Copyright (c) 2005-2007 Andre Merzky (andre@merzky.net) // Copyright (c) 2005-2007 Hartmut Kaiser (hartmut.kaiser@gmail.com) // Copyright (c) 2005 Michel Zandstra (michelzandstra@gmail.com) // // Distributed under 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) #ifndef SAGA_IMPL_ENGINE_SESSION_HPP #define SAGA_IMPL_ENGINE_SESSION_HPP #include #include #include #include #include #include #include /////////////////////////////////////////////////////////////////////////////// namespace saga { namespace impl { /** * Session: provides the functionality of a session handle. * * Multiple context's can be added to the session handle. Session * also handles the shared adaptor data of the session, and * contains an instance of the saga::engine that is used by * the proxy classes. * * @see Saga API, adaptor_data/instance_data, engine */ class session : public saga::impl::object { private: typedef v1_0::preference_type preference_type; typedef v1_0::cpi cpi; /*! the instance of the saga::engine */ engine engine_; /*! the list of context */ typedef std::list context_list_type; context_list_type contexts_; public: /** * Constructor / Destructor */ session (void) : object(saga::object::Session) { engine_.load (this); } ~session (void) { } // saga::object interface saga::object clone() const; /** * Returns the context attached to the session * * @return the context list */ context_list_type list_contexts (saga::context::type t) const; /** * Removes a context from the context list * * @param the context to be added */ void remove_context (saga::context const& c); /** * Adds the context to the context list * * @param the context to be added */ void add_context (saga::context const& c); /** * Creates an adaptor object implementing the interface * * @param cpi_name a string specifying the interface for which an object * is needed * @param op_name a description method wanted from the adaptor * @param prefs a description table describing the adaptor needed * * @return a pointer of type T* to the created object, or NULL of no suitable * adaptor could be found * * @see saga::adaptor_selector::select_adaptor */ v1_0::cpi* get_adaptor (std::string const& cpi_name, std::string const& op_name, preference_type const& prefs, proxy* proxy_, adaptor_selector::adaptor_info_list_type &no_no_list) const { return engine_.get_adaptor(cpi_name, op_name, prefs, no_no_list, proxy_); } /** * Tests, whether a given adaptor object implements the required interface * * @param adaptor a pointer to the adaptor to test * @param cpi_name a string specifying the interface for which an object * is needed * @param op_name a description method wanted from the adaptor * @param prefs a description table describing the adaptor needed * * @return a pointer of type T* to the created object, or NULL of no suitable * adaptor could be found * * @see saga::adaptor_selector::select_adaptor */ bool test_adaptor (v1_0::cpi const* adaptor, std::string const& cpi_name, std::string const& op_name, preference_type const& prefs) const { return engine_.test_adaptor(adaptor, cpi_name, op_name, prefs); } // return the name of the adaptor with the given adaptor id std::string get_adaptor_name(saga::uuid id) const { return engine_.get_adaptor_name(id); } }; // class session /////////////////////////////////////////////////////////////////////////////// }} // namespace saga::impl #endif // SAGA_IMPL_ENGINE_SESSION_HPP