SAGA C++ API 1.6
advert.hpp
Go to the documentation of this file.
00001 #ifndef SAGA_PACKAGES_DATA_ADVERT_ADVERT_HPP
00002 #define SAGA_PACKAGES_DATA_ADVERT_ADVERT_HPP
00003 
00004 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES)
00005 #pragma wave option(preserve: 2, line: 1, output: "preprocessed/advert.hpp")
00006 #endif
00007 //  Copyright (c) 2005-2009 Hartmut Kaiser
00008 //  Copyright (c) 2007 Ole Weidner (oweidner@cct.lsu.edu)
00009 // 
00010 //  Distributed under the Boost Software License, Version 1.0. (See accompanying 
00011 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
00012 
00013 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES)
00014 #pragma wave option(preserve: 0, output: null)
00015 #endif
00016 
00017 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
00018 #pragma once
00019 #endif 
00020 
00021 #include <string>
00022 #include <vector>
00023 
00024 #include <boost/utility/enable_if.hpp>
00025 #include <boost/lexical_cast.hpp>
00026 
00027 // include dependent spec sections
00028 #include <saga/saga/util.hpp>
00029 #include <saga/saga/base.hpp>
00030 #include <saga/saga/types.hpp>
00031 #include <saga/saga/session.hpp>
00032 #include <saga/saga/call.hpp>
00033 #include <saga/saga/detail/attribute.hpp>
00034 #include <saga/saga/detail/monitorable.hpp>
00035 
00036 #include <saga/saga/packages/namespace/namespace_entry.hpp>
00037 #include <saga/saga/packages/advert/config.hpp>
00038 
00039 // suppress warnings about dependent classes not being exported from the dll
00040 #if defined(BOOST_MSVC)
00041 #pragma warning(push)
00042 #pragma warning(disable: 4251 4231 4275 4660)
00043 #endif
00044 
00045 #ifdef SAGA_DEBUG
00046 #include <saga/saga/packages/advert/preprocessed/advert.hpp>
00047 #else
00048 
00049 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES)
00050 #pragma wave option(preserve: 2, line: 1, output: "preprocessed/advert.hpp")
00051 #endif
00052 
00053 #if !defined(SAGA_ADVERT_NO_DEPRECATED)
00054 #define SAGA_ADVERT_DEPRECATED_MSG "This function is deprecated and will be removed in the future."
00055 #endif
00056 
00058 namespace saga
00059 {
00063     namespace advert 
00064     {
00068         namespace metrics 
00069         {
00073             char const* const advert_modified = "advert.Modified";
00074 
00078             char const* const advert_deleted = "advert.Deleted";
00079         }
00080 
00084         enum flags 
00085         {
00086             Unknown         = /*  -1, */  saga::name_space::Unknown, 
00087             None            = /*   0, */  saga::name_space::None, 
00088             Overwrite       = /*   1, */  saga::name_space::Overwrite, 
00089             Recursive       = /*   2, */  saga::name_space::Recursive, 
00090             Dereference     = /*   4, */  saga::name_space::Dereference, 
00091             Create          = /*   8, */  saga::name_space::Create, 
00092             Exclusive       = /*  16, */  saga::name_space::Exclusive, 
00093             Lock            = /*  32, */  saga::name_space::Lock, 
00094             CreateParents   = /*  64, */  saga::name_space::CreateParents, 
00095             // 256, reserved for Truncate
00096             // 512,  reserved for Append 
00097             Read            =    512, 
00098             Write           =   1024, 
00099             ReadWrite       =   Read | Write 
00100             // 2048, reserved for Binary
00101         }; 
00102 
00110         class SAGA_ADVERT_PACKAGE_EXPORT entry 
00111           : public saga::name_space::entry,
00112             public saga::detail::attribute<entry>
00113         {
00114         protected:
00116 
00117             friend class saga::impl::advert;
00118 
00119             friend struct saga::detail::attribute<entry>; 
00120             typedef saga::detail::attribute<entry> attribute_base;
00121             typedef saga::name_space::entry::monitorable_base monitorable_base;
00122 
00123             TR1::shared_ptr <saga::impl::advert> get_impl_sp(void) const;
00124             saga::impl::advert* get_impl (void) const;
00125             explicit entry(saga::impl::advert *impl);
00127 
00128         private:
00130             // factory
00131             SAGA_CALL_CREATE_PRIV_3(session const&, saga::url const&, int)
00132 
00133             SAGA_CALL_PRIV_1(store_object, saga::object)
00134             SAGA_CALL_PRIV_0(retrieve_object)
00135             SAGA_CALL_PRIV_1(retrieve_object, saga::session)
00136             SAGA_CALL_PRIV_1(store_string, std::string)
00137             SAGA_CALL_PRIV_0(retrieve_string)
00139 
00140             template <typename Tag, typename T>
00141             saga::task store_object_or_string (Tag, T const& object, boost::mpl::true_)
00142             {
00143                 return store_objectpriv(object, Tag());
00144             }
00145 
00146             template <typename Tag, typename T>
00147             saga::task store_object_or_string (Tag, T const& object, boost::mpl::false_)
00148             {
00149                 return store_stringpriv(
00150                     boost::lexical_cast<std::string>(object), Tag()); 
00151             }
00152 
00153         public:
00157             entry (saga::session const& s, saga::url url, int mode = Read);
00158 
00162             explicit entry (saga::url url, int mode = Read);
00163 
00166             explicit entry (saga::object const& other);
00167 
00170             entry (void);
00171 
00175             ~entry (void);
00176 
00180             static entry create(session const& s, saga::url const& url, 
00181                 int mode = Read)
00182             {
00183                 return entry(s, url, mode);
00184             }
00186             SAGA_CALL_CREATE_3_DEF_1(session const&, saga::url const&, int, Read)
00188 
00191             static entry create(saga::url const& url, int mode = Read)
00192             {
00193                 return entry(url, mode);
00194             }
00195             template <typename Tag>
00196             static saga::task create(saga::url const& url, int mode = Read)
00197             {
00198                 return create<Tag>(detail::get_the_session(), url, mode);
00199             }
00200 
00202             entry &operator= (saga::object const& object);
00204 
00210             void store_object (saga::object object) 
00211             { 
00212                 saga::task t = store_objectpriv(object, saga::task_base::Sync()); 
00213                 t.get_result ();
00214             }
00215 
00216             template <typename T>
00217             typename boost::disable_if<detail::has_sync_tag<T> >::type
00218             store_object (T const& object) 
00219             { 
00220                 typedef boost::mpl::bool_<
00221                     detail::is_saga_object<T>::value> is_saga_object;
00222                 saga::task t = store_object_or_string(saga::task_base::Sync(), 
00223                     object, is_saga_object());
00224                 t.get_result();
00225             }
00227             template <typename Tag, typename T>
00228             typename boost::enable_if<detail::has_sync_tag<Tag>, saga::task>::type
00229             store_object (T const& object)
00230             {
00231                 typedef boost::mpl::bool_<
00232                     detail::is_saga_object<T>::value> is_saga_object;
00233                 return store_object_or_string(Tag(), object, is_saga_object());
00234             }
00236 
00242             saga::object retrieve_object() 
00243             { 
00244                 saga::task t = retrieve_objectpriv (saga::task_base::Sync()); 
00245                 return t.get_result<saga::object>();
00246             }
00248 //            SAGA_CALL_PUB_0_DEF_0(retrieve_object)
00249             template <typename Tag>
00250             typename boost::enable_if<detail::has_sync_tag<Tag>, saga::task>::type
00251             retrieve_object()
00252             { 
00253                 return retrieve_objectpriv(Tag()); 
00254             }
00256 
00257             template <typename T>
00258             T& retrieve_object(
00259                 typename boost::disable_if<detail::has_sync_tag<T> >::type* = 0) 
00260             { 
00261                 saga::task t = retrieve_stringpriv (saga::task_base::Sync()); 
00262                 return t.get_result<T>();
00263             }
00265             template <typename T, typename Tag>
00266             typename boost::disable_if<detail::has_sync_tag<T>, saga::task>::type
00267             retrieve_object() 
00268             {
00269                 return retrieve_stringpriv(Tag());
00270             }
00272 
00280             saga::object retrieve_object (saga::session const& s) 
00281             { 
00282                 saga::task t = retrieve_objectpriv(s, saga::task_base::Sync()); 
00283                 return t.get_result<saga::object>();
00284             }
00286             template <typename Tag>
00287             typename boost::enable_if<detail::has_sync_tag<Tag>, saga::task>::type
00288             retrieve_object(saga::session const& s)
00289             { 
00290                 return retrieve_objectpriv(s, Tag()); 
00291             }
00293 
00294 #if !defined(SAGA_ADVERT_NO_DEPRECATED)
00295 
00296 
00301             SAGA_DEPRECATED(SAGA_ADVERT_DEPRECATED_MSG) 
00302             void store_string (std::string str) 
00303             { 
00304                 saga::task t = store_stringpriv(str, saga::task_base::Sync()); 
00305                 t.get_result ();
00306             }
00307 //             SAGA_CALL_PUB_1_DEF_0(store_string, std::string)
00309             template <typename Tag>
00310             SAGA_DEPRECATED(SAGA_ADVERT_DEPRECATED_MSG) 
00311             saga::task store_string(std::string str) 
00312             {
00313                 return store_stringpriv(str, Tag());
00314             }
00316 
00322             SAGA_DEPRECATED(SAGA_ADVERT_DEPRECATED_MSG) 
00323             std::string retrieve_string (void) 
00324             { 
00325                 saga::task t = retrieve_stringpriv (saga::task_base::Sync()); 
00326                 return t.get_result<std::string>();
00327             }
00328 //             SAGA_CALL_PUB_0_DEF_0(retrieve_string)
00330             template <typename Tag>
00331             SAGA_DEPRECATED(SAGA_ADVERT_DEPRECATED_MSG) 
00332             saga::task retrieve_string()
00333             { 
00334                 return retrieve_stringpriv(Tag()); 
00335             }
00337 #endif
00338 
00339         }; // class advert
00340     } // namespace advert
00341 } // namespace saga
00342 
00343 #undef SAGA_ADVERT_DEPRECATED_MSG
00344 
00345 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES)
00346 #pragma wave option(output: null)
00347 #endif
00348 
00349 #endif // !defined(SAGA_DEBUG)
00350 
00351 // re-enable warnings about dependent classes not being exported from the dll
00352 #if defined(BOOST_MSVC)
00353 #pragma warning(pop)
00354 #endif
00355 
00356 #endif // !defined(SAGA_PACKAGES_DATA_ADVERT_ADVERT_HPP)
00357 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines