SAGA Adaptor CPI v.1.0
|
00001 #ifndef SAGA_PACKAGES_DATA_NAMESPACEENTRY_HPP 00002 #define SAGA_PACKAGES_DATA_NAMESPACEENTRY_HPP 00003 00004 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES) 00005 #pragma wave option(preserve: 2, line: 1, output: "preprocessed/namespace_entry.hpp") 00006 #endif 00007 // Copyright (c) 2005-2009 Hartmut Kaiser 00008 // Copyright (c) 2005-2007 Andre Merzky (andre@merzky.net) 00009 // Copyright (c) 2007 Ole Weidner (oweidner@cct.lsu.edu) 00010 // 00011 // Distributed under the Boost Software License, Version 1.0. (See accompanying 00012 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 00013 00014 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES) 00015 #pragma wave option(preserve: 0, output: null) 00016 #endif 00017 00018 // include stl 00019 #include <string> 00020 00021 // include dependent spec sections 00022 #include <saga/saga/call.hpp> 00023 #include <saga/saga/base.hpp> 00024 #include <saga/saga/object.hpp> 00025 #include <saga/saga/session.hpp> 00026 #include <saga/saga/task.hpp> 00027 #include <saga/saga/permissions.hpp> 00028 #include <saga/saga/url.hpp> 00029 00030 // include package config 00031 #include <saga/saga/packages/namespace/config.hpp> 00032 00033 #include <saga/saga/detail/monitorable.hpp> 00034 #include <saga/saga/detail/permissions.hpp> 00035 00036 // suppress warnings about dependent classes not being exported from the dll 00037 #if defined(BOOST_MSVC) 00038 #pragma warning(push) 00039 #pragma warning(disable: 4251 4231 4275 4660) 00040 #endif 00041 00042 #ifdef SAGA_DEBUG 00043 #include <saga/saga/packages/description/preprocessed/namespace_entry.hpp> 00044 #else 00045 00046 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES) 00047 #pragma wave option(preserve: 2, line: 1, output: "preprocessed/namespace_entry.hpp") 00048 #endif 00049 00050 namespace saga 00051 { 00056 namespace name_space { 00057 00065 enum flags 00066 { 00067 Unknown = -1, 00068 None = 0, 00069 Overwrite = 1, 00070 Recursive = 2, 00071 Dereference = 4, 00072 Create = 8, 00073 Exclusive = 16, 00074 Lock = 32, 00075 CreateParents = 64, 00076 // 128, reserved for Truncate 00077 // 256, reserved for Append 00078 Read = 512, 00079 Write = 1024, 00080 ReadWrite = Read | Write 00081 // 2048, reserved for Binary 00082 }; 00083 00091 class SAGA_NAMESPACE_PACKAGE_EXPORT entry 00092 : public saga::object, 00093 public saga::detail::monitorable<entry>, 00094 public saga::detail::permissions<entry> 00095 { 00096 00097 protected: 00099 00100 TR1::shared_ptr <saga::impl::namespace_entry> get_impl_sp(void) const; 00101 saga::impl::namespace_entry* get_impl (void) const; 00102 00103 friend struct saga::detail::monitorable<entry>; // needs to access get_impl() 00104 friend struct saga::detail::permissions<entry>; 00105 friend class saga::impl::namespace_entry; 00106 00107 typedef saga::detail::monitorable<entry> monitorable_base; 00109 00110 private: 00111 // factory 00112 SAGA_CALL_CREATE_PRIV_3(session const&, saga::url, int) 00113 00114 // basic properties 00115 SAGA_CALL_CONST_PRIV_0(get_url) 00116 SAGA_CALL_CONST_PRIV_0(get_cwd) 00117 SAGA_CALL_CONST_PRIV_0(get_name) 00118 00119 // navigation/query methods 00120 SAGA_CALL_CONST_PRIV_0(read_link) 00121 SAGA_CALL_CONST_PRIV_0(is_dir) 00122 SAGA_CALL_CONST_PRIV_0(is_entry) 00123 SAGA_CALL_CONST_PRIV_0(is_link) 00124 00125 // entry management methods 00126 SAGA_CALL_PRIV_2(copy, saga::url, int) 00127 SAGA_CALL_PRIV_2(link, saga::url, int) 00128 SAGA_CALL_PRIV_2(move, saga::url, int) 00129 SAGA_CALL_PRIV_1(remove, int) 00130 00131 SAGA_CALL_PRIV_1(close, double) 00132 00133 // permissions with flags 00134 SAGA_CALL_PRIV_3(permissions_allow, std::string, int, int) 00135 SAGA_CALL_PRIV_3(permissions_deny, std::string, int, int) 00136 00137 protected: 00139 00140 explicit entry (saga::impl::namespace_entry * init); 00142 00143 public: 00148 entry (session const & s, saga::url url, int mode = Read, 00149 saga::object::type t = saga::object::NSEntry); 00150 00155 explicit 00156 entry (saga::url url, int mode = Read, 00157 saga::object::type t = saga::object::NSEntry); 00158 00163 explicit entry (saga::object const& o); 00164 00169 entry (void); 00170 00175 ~entry (void); 00176 00180 static entry create(session const & s, saga::url url, int mode = Read) 00181 { 00182 return entry(s, url, mode); 00183 } 00184 SAGA_CALL_CREATE_3_DEF_1(session const&, saga::url, int, Read) 00185 00186 00188 static entry create(saga::url url, int mode = Read) 00189 { 00190 return entry(url, mode); 00191 } 00192 template <typename Tag> 00193 static saga::task create(saga::url url, int mode = Read) 00194 { 00195 return create<Tag>(detail::get_the_session(), url, mode); 00196 } 00197 00202 entry &operator= (saga::object const& o); 00203 00210 saga::url get_url() const 00211 { 00212 saga::task t = get_urlpriv(saga::task_base::Sync()); 00213 return t.get_result<saga::url>(); 00214 } 00215 SAGA_CALL_CONST_PUB_0_DEF_0(get_url) 00216 00217 00223 saga::url get_cwd() const 00224 { 00225 saga::task t = get_cwdpriv(saga::task_base::Sync()); 00226 return t.get_result<saga::url>(); 00227 } 00228 SAGA_CALL_CONST_PUB_0_DEF_0(get_cwd) 00229 00230 00236 saga::url get_name() const 00237 { 00238 saga::task t = get_namepriv(saga::task_base::Sync()); 00239 return t.get_result<saga::url>(); 00240 } 00241 SAGA_CALL_CONST_PUB_0_DEF_0(get_name) 00242 00243 00249 saga::url read_link() const 00250 { 00251 saga::task t = read_linkpriv(saga::task_base::Sync()); 00252 return t.get_result<saga::url>(); 00253 } 00254 SAGA_CALL_CONST_PUB_0_DEF_0(read_link) 00255 00256 00262 bool is_dir() const 00263 { 00264 saga::task t = is_dirpriv(saga::task_base::Sync()); 00265 return t.get_result<bool>(); 00266 } 00267 SAGA_CALL_CONST_PUB_0_DEF_0(is_dir) 00268 00269 00275 bool is_entry() const 00276 { 00277 saga::task t = is_entrypriv(saga::task_base::Sync()); 00278 return t.get_result<bool>(); 00279 } 00280 SAGA_CALL_CONST_PUB_0_DEF_0(is_entry) 00281 00282 00287 bool is_link () const 00288 { 00289 saga::task t = is_linkpriv(saga::task_base::Sync()); 00290 return t.get_result<bool>(); 00291 } 00292 SAGA_CALL_CONST_PUB_0_DEF_0(is_link) 00293 00294 00301 void copy(saga::url target, int flags = saga::name_space::None) 00302 { 00303 saga::task t = copypriv(target, flags, saga::task_base::Sync()); 00304 t.get_result (); 00305 } 00306 SAGA_CALL_PUB_2_DEF_1 (copy, saga::url, int, saga::name_space::None) 00307 00308 00315 void link (saga::url target, int flags = saga::name_space::None) 00316 { 00317 saga::task t = linkpriv(target, flags, saga::task_base::Sync()); 00318 t.get_result (); 00319 } 00320 SAGA_CALL_PUB_2_DEF_1 (link, saga::url, int, saga::name_space::None) 00321 00322 00329 void move (saga::url target, int flags = saga::name_space::None) 00330 { 00331 saga::task t = movepriv(target, flags, saga::task_base::Sync()); 00332 t.get_result (); 00333 } 00334 SAGA_CALL_PUB_2_DEF_1 (move, saga::url, int, saga::name_space::None) 00335 00336 00342 void remove (int flags = saga::name_space::None) 00343 { 00344 saga::task t = removepriv(flags, saga::task_base::Sync()); 00345 t.get_result (); 00346 } 00347 SAGA_CALL_PUB_1_DEF_1 (remove, int, saga::name_space::None) 00348 00349 00354 void close (double timeout = 0.0) 00355 { 00356 saga::task t = closepriv(timeout, saga::task_base::Sync()); 00357 t.get_result (); 00358 } 00359 SAGA_CALL_PUB_1_DEF_1 (close, double, 0.0) 00360 00361 // make base class functions available as well 00362 using saga::detail::permissions<entry>::permissions_allow; 00363 using saga::detail::permissions<entry>::permissions_deny; 00364 00374 void permissions_allow (std::string id, int perm, int flags) 00375 { 00376 saga::task t = permissions_allowpriv(id, perm, flags, saga::task_base::Sync()); 00377 t.get_result (); 00378 } 00379 SAGA_CALL_PUB_3_DEF_0 (permissions_allow, std::string, int, int) 00380 00381 00390 void permissions_deny (std::string id, int perm, int flags) 00391 { 00392 saga::task t = permissions_denypriv(id, perm, flags, saga::task_base::Sync()); 00393 t.get_result (); 00394 } 00395 SAGA_CALL_PUB_3_DEF_0 (permissions_deny, std::string, int, int) 00396 00397 }; // namespace_entry 00398 00399 }} 00400 00401 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES) 00402 #pragma wave option(output: null) 00403 #endif 00404 #endif // !defined(SAGA_DEBUG) 00405 00406 // re-enable warnings about dependent classes not being exported from the dll 00407 #if defined(BOOST_MSVC) 00408 #pragma warning(pop) 00409 #endif 00410 00411 #endif // SAGA_PACKAGES_DATA_NAMESPACEENTRY_HPP 00412