- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Search for |

# stream_server.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 //  Use, modification and distribution is subject to the Boost Software
    00006 //  License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
    00007 //  http://www.boost.org/LICENSE_1_0.txt)
    00008
    00009 #ifndef SAGA_COMM_STREAM_STREAMSERVICE_HPP
    00010 #define SAGA_COMM_STREAM_STREAMSERVICE_HPP
    00011
    00012 // include stl
    00013 #include <string>
    00014
    00015 // include dependent spec sections
    00016 #include <saga/saga/util.hpp>
    00017 #include <saga/saga/call.hpp>
    00018 #include <saga/saga/base.hpp>
    00019 #include <saga/saga/task.hpp>
    00020 #include <saga/saga/session.hpp>
    00021 #include <saga/saga/detail/monitorable.hpp>
    00022 #include <saga/saga/detail/permissions.hpp>
    00023
    00024 // include package config
    00025 #include <saga/saga/packages/stream/config.hpp>
    00026
    00027 // need stream
    00028 #include <saga/saga/stream.hpp>
    00029
    00030 // suppress warnings about dependent classes not being exported from the dll
    00031 #if defined(BOOST_MSVC)
    00032 #pragma warning(push)
    00033 #pragma warning(disable: 4251 4231 4660)
    00034 #endif
    00035
    00037 namespace saga
    00038 {
    00039     namespace stream {
    00040
    00041     namespace metrics
    00042     {
    00043         char const* const server_clientconnect = "server.ClientConnect";
    00044     }
    00045
    00052     class SAGA_STREAM_PACKAGE_EXPORT server
    00053         : public saga::object,
    00054           public saga::detail::monitorable<server>,
    00055           public saga::detail::permissions<server>
    00056     {
    00058
    00059         friend struct saga::detail::monitorable<server>;  // needs to access get_impl()
    00060         friend struct saga::detail::permissions<server>;
    00061         typedef saga::detail::monitorable<server> monitorable_base_type;
    00063
    00064     protected:
    00066
    00067         TR1::shared_ptr <saga::impl::server> get_impl_sp(void) const;
    00068         saga::impl::server* get_impl (void) const;
    00069         friend class saga::impl::server;
    00070         friend struct saga::detail::create_default<server>;
    00071
    00072         explicit server (saga::impl::server* impl);
    00073         explicit server (int);    // dummy constructor to create empty facade
    00075
    00076     private:
    00077         // factory
    00078         SAGA_CALL_CREATE_PRIV_2(session const&, saga::url)
    00079
    00080         // stream server methods
    00081         SAGA_CALL_CONST_PRIV_0(get_url)
    00082         SAGA_CALL_PRIV_1(connect, double)
    00083         SAGA_CALL_PRIV_1(serve, double)
    00084         SAGA_CALL_PRIV_1(close, double)
    00085
    00086         void init_metrics();
    00087
    00088     public:
    00093         explicit server (session const& s, saga::url url = saga::url());
    00094
    00099         explicit server (saga::url url);
    00100
    00105         server ();
    00106
    00111         explicit server (saga::object const& o);
    00112
    00117         ~server (void);
    00118
    00122         static server create(session const& s, saga::url name = saga::url())
    00123         {
    00124             return server(s, name);
    00125         }
    00127         SAGA_CALL_CREATE_2_DEF_1(session const&, saga::url, saga::url())
    00129
    00132         static server create(saga::url name = saga::url())
    00133         {
    00134             return server(name);
    00135         }
    00136         template <typename Tag>
    00137         static saga::task create(saga::url name = saga::url())
    00138         {
    00139             return create<Tag>(detail::get_the_session(), name);
    00140         }
    00141
    00146         server &operator= (saga::object const& o);
    00147
    00154         saga::url get_url() const
    00155         {
    00156             saga::task t = get_urlpriv(saga::task_base::Sync());
    00157             return t.get_result<saga::url>();
    00158         }
    00159         SAGA_CALL_CONST_PUB_0_DEF_0(get_url)
    00160
    00161
    00163         saga::stream::stream connect(double timeout = -1.0)
    00164         {
    00165             saga::task t = connectpriv(timeout, saga::task_base::Sync());
    00166             return t.get_result<saga::stream::stream>();
    00167         }
    00168         SAGA_CALL_PUB_1_DEF_1(connect, double, -1.0)
    00169
    00170
    00177         saga::stream::stream serve(double timeout = 0.0)
    00178         {
    00179             saga::task t = servepriv(timeout, saga::task_base::Sync());
    00180             return t.get_result<saga::stream::stream>();
    00181         }
    00182         SAGA_CALL_PUB_1_DEF_1(serve, double, -1.0)
    00183
    00184
    00189         void close(double timeout = 0.0)
    00190         {
    00191           saga::task t = closepriv(timeout, saga::task_base::Sync());
    00192           t.get_result ();
    00193         }
    00194         SAGA_CALL_PUB_1_DEF_1(close, double, 0.0)
    00195     };
    00196
    00197     }   // namespace saga::stream
    00198
    00199     namespace detail
    00200     {
    00201         // we need to specialize the create_default template (used in hold_any)
    00202         // to be able to create a truly default constructed server (empty
    00203         // facade)
    00204         template<>
    00205         struct create_default<saga::stream::server>
    00206         {
    00207             static saga::stream::server* call()
    00208             {
    00209                 return new saga::stream::server(1);    // use dummy constructor
    00210             }
    00211             template <typename T_> static void call(T_* obj)
    00212             {
    00213                 new (obj) saga::stream::server(1);
    00214             }
    00215         };
    00216     }
    00217
    00218 }
    00219
    00220 // re-enable warnings about dependent classes not being exported from the dll
    00221 #if defined(BOOST_MSVC)
    00222 #pragma warning(pop)
    00223 #endif
    00224
    00225 #endif // SAGA_COMM_STREAM_STREAMSERVICE_HPP
    00226