SAGA C++ API 1.6
discoverer.hpp
Go to the documentation of this file.
00001 //  Copyright (c) 2009 STFC
00002 // 
00003 //  Distributed under the Boost Software License, Version 1.0. (See accompanying 
00004 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
00005 #ifndef SAGA_PACKAGES_SD_DISCOVERER_HPP
00006 
00007 #define SAGA_PACKAGES_SD_DISCOVERER_HPP
00008 
00009 // include dependent spec sections
00010 #include <saga/saga/util.hpp>
00011 #include <saga/saga/base.hpp>
00012 #include <saga/saga/types.hpp>
00013 #include <saga/saga/session.hpp>
00014 #include <saga/saga/call.hpp> 
00015 #include <saga/saga/exception.hpp>
00016 #include <saga/saga/url.hpp>
00017 
00018 #include <saga/saga/packages/sd/config.hpp>
00019 #include <saga/saga/packages/sd/service_description.hpp>
00020 
00021 namespace saga
00022 {
00023   namespace sd {
00024 
00179   class SAGA_SD_PACKAGE_EXPORT discoverer 
00180        : public saga::object
00181   {
00182 
00183    public:
00184 
00185    private:
00186       // factory
00187       SAGA_CALL_CREATE_PRIV_2(session const&, saga::url)
00188 
00189       SAGA_CALL_PRIV_2 (list_services, std::string, std::string)
00190       SAGA_CALL_PRIV_3 (list_services, std::string, std::string, std::string)
00191 
00192    protected:
00193       TR1::shared_ptr <saga::impl::discoverer> get_impl_sp (void) const;
00194       saga::impl::discoverer* get_impl (void) const;
00195       friend class saga::impl::discoverer;
00196       explicit discoverer(saga::impl::discoverer* impl)
00197          SAGA_THROW_SPEC(throw(saga::not_implemented,
00198                                saga::incorrect_url,
00199                                saga::does_not_exist,
00200                                saga::authorization_failed,
00201                                saga::authentication_failed,
00202                                saga::timeout,
00203                                saga::no_success));
00204 
00205    public:
00239      explicit discoverer(saga::url loc = saga::url())
00240          SAGA_THROW_SPEC(throw(saga::not_implemented,
00241                                saga::incorrect_url,
00242                                saga::does_not_exist,
00243                                saga::authorization_failed,
00244                                saga::authentication_failed,
00245                                saga::timeout,
00246                                saga::no_success));
00247 
00283       explicit discoverer(session const& s, saga::url loc = saga::url())
00284          SAGA_THROW_SPEC(throw(saga::not_implemented,
00285                                saga::incorrect_url,
00286                                saga::does_not_exist,
00287                                saga::authorization_failed,
00288                                saga::authentication_failed,
00289                                saga::timeout,
00290                                saga::no_success));
00291 
00292       // explicit discoverer(saga::object const& o); // is this ctor necessary?
00296       ~discoverer (void) SAGA_THROW_SPEC(throw());
00297 
00333       static discoverer create(session const& s, saga::url loc = saga::url())
00334          SAGA_THROW_SPEC(throw(saga::not_implemented,
00335                                saga::incorrect_url,
00336                                saga::does_not_exist,
00337                                saga::authorization_failed,
00338                                saga::authentication_failed,
00339                                saga::timeout,
00340                                saga::no_success))
00341       {
00342           return discoverer(s, loc);
00343       }
00344       SAGA_CALL_CREATE_2_DEF_1(session const&, saga::url, saga::url())
00345 
00346     /*saga*
00347      * discoverer factory.  Constructs a discoverer object using
00348      * a default session and the given URL.
00349      * 
00350      * @param loc      URL to use.
00351      *
00352      * @throws not_implemented
00353      *                 if the discoverer class is not implemented
00354      *                 by the SAGA implementation at all.
00355      * @throws incorrect_url
00356      *                 if an implementation cannot handle the specified
00357      *                 protocol, or that access to the specified entity
00358      *                 via the given protocol is impossible.
00359      * @throws does_not_exist
00360      *                 if the url is syntactically valid, but no service
00361      *                 can be contacted at that URL.
00362      * @throws authorization_failed
00363      *                 if none of the available contexts of the used
00364      *                 session could be used for successful authorization.
00365      *                 That error indicates that the resource could not be
00366      *                 accessed at all, and not that an operation was not
00367      *                 available due to restricted permissions.
00368      * @throws authentication_failed
00369      *                 if none of the available session contexts could
00370      *                 successfully be used for authentication.
00371      * @throws timeout
00372      *                 if a remote operation did not complete
00373      *                 successfully because the network communication
00374      *                 or the remote service timed out.
00375      * @throws no_success
00376      *                 if no result can be returned because of
00377      *                 information system or other internal problems.
00378      */
00379       static discoverer create(saga::url loc = saga::url())
00380          SAGA_THROW_SPEC(throw(saga::not_implemented,
00381                                saga::incorrect_url,
00382                                saga::not_implemented,
00383                                saga::authorization_failed,
00384                                saga::authentication_failed,
00385                                saga::timeout,
00386                                saga::no_success))
00387       {
00388           return discoverer(loc);
00389       }
00390 
00391       template <typename Tag>
00392       static saga::task create(saga::url loc = saga::url())
00393       {
00394          return create<Tag>(saga::detail::get_the_session(), loc);
00395       }
00396 
00397       // default operator=() and copy ctor
00398       discoverer& operator= (saga::object const& o) 
00399           SAGA_THROW_SPEC(throw());
00400 
00401       // public methods for the service discoverer
00402 
00441       std::vector<saga::sd::service_description>
00442          list_services(std::string service_filter, 
00443                        std::string data_filter,
00444                        std::string authz_filter)
00445             SAGA_THROW_SPEC(throw(saga::bad_parameter,
00446                   saga::authorization_failed,
00447                   saga::authentication_failed,
00448                   saga::timeout,
00449                   saga::no_success))
00450       {
00451          saga::task t = list_servicespriv(service_filter,
00452                                           data_filter, 
00453                                           authz_filter,
00454                                           saga::task_base::Sync());
00455          return t.get_result<std::vector<saga::sd::service_description> >();
00456       }
00457       SAGA_CALL_PUB_3_DEF_0 (list_services, std::string, std::string, std::string)
00458 
00459     
00496       std::vector<saga::sd::service_description>
00497          list_services(std::string service_filter, 
00498                        std::string data_filter)
00499             SAGA_THROW_SPEC(throw(saga::bad_parameter,
00500                   saga::authorization_failed,
00501                   saga::authentication_failed,
00502                   saga::timeout,
00503                   saga::no_success))
00504       {
00505          saga::task t = list_servicespriv(service_filter,
00506                                           data_filter, 
00507                                           saga::task_base::Sync());
00508          return t.get_result<std::vector<saga::sd::service_description> >();
00509       }
00510       SAGA_CALL_PUB_2_DEF_0 (list_services, std::string, std::string)
00511   }; // discoverer
00512  } // namespace sd
00513 }  // namespace saga
00514 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines