SAGA C++ API 1.6
session.hpp
Go to the documentation of this file.
00001 //  Copyright (c) 2005-2007 Andre Merzky (andre@merzky.net)
00002 //  Copyright (c) 2005-2009 Hartmut Kaiser
00003 //  Copyright (c) 2007 Ole Weidner (oweidner@cct.lsu.edu)
00004 // 
00005 //  Distributed under the Boost Software License, Version 1.0. (See accompanying 
00006 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
00007 
00008 #ifndef SAGA_SESSION_HPP
00009 #define SAGA_SESSION_HPP
00010 
00011 // include stl
00012 #include <list>
00013 #include <set>
00014 
00015 // include dependent spec sections
00016 #include <saga/saga/util.hpp>
00017 #include <saga/saga/base.hpp>
00018 #include <saga/saga/object.hpp>
00019 #include <saga/saga/detail/preferences.hpp>
00020 
00021 // suppress warnings about dependent classes not being exported from the dll
00022 #if defined(BOOST_MSVC)
00023 #pragma warning(push)
00024 #pragma warning(disable: 4251 4231 4275 4660)
00025 #endif
00026 
00028 namespace saga
00029 {
00031     namespace detail 
00032     {
00033         // the default session as singleton, and the no-session singleton
00034         SAGA_EXPORT session& get_the_session();
00035         #define SAGA_DEFAULT_SESSION detail::get_the_session()
00036 
00037         // helper function to create exactly one instance of a default session
00038         session& get_instance();
00039     }
00041 
00051   class SAGA_EXPORT session
00052     : public saga::object
00053   {
00054     protected: 
00056 
00057       TR1::shared_ptr<saga::impl::session> get_impl_sp (void) const;
00058       saga::impl::session* get_impl (void) const;
00059 
00060       friend class  saga::object; // needs to get impl
00061       friend struct impl::runtime;
00062       friend session& detail::get_instance();
00064 
00065       // this is protected now to avoid abuse
00066       explicit session(bool default_session);
00067 
00068     public:
00073       explicit session();
00074 
00080       explicit session(saga::object const& obj);
00081 
00086      ~session (void);
00087 
00092       session &operator= (saga::object const& o);
00093 
00099       void add_context(saga::context const& c);
00100 
00106       void remove_context(saga::context const& c);
00107 
00113       std::vector <saga::context> list_contexts() const;
00114       
00119       friend SAGA_EXPORT 
00120       bool operator== (session const& lhs, session const& rhs);
00121 
00124       void close (double timeout = 0.0);
00125   };
00126 
00127   saga::session SAGA_EXPORT get_default_session();
00128 
00130 } // namespace saga
00131 
00132 // re-enable warnings about dependent classes not being exported from the dll
00133 #if defined(BOOST_MSVC)
00134 #pragma warning(pop)
00135 #endif
00136 
00137 #endif // SAGA_SESSION_HPP
00138 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines