SAGA C++ API 1.6
|
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 { 00060 namespace name_space { 00061 00069 enum flags 00070 { 00071 Unknown = -1, 00072 None = 0, 00073 Overwrite = 1, 00074 Recursive = 2, 00075 Dereference = 4, 00076 Create = 8, 00077 Exclusive = 16, 00078 Lock = 32, 00079 CreateParents = 64, 00080 // 128, reserved for Truncate 00081 // 256, reserved for Append 00082 Read = 512, 00083 Write = 1024, 00084 ReadWrite = Read | Write 00085 // 2048, reserved for Binary 00086 }; 00087 00095 class SAGA_NAMESPACE_PACKAGE_EXPORT entry 00096 : public saga::object, 00097 public saga::detail::monitorable<entry>, 00098 public saga::detail::permissions<entry> 00099 { 00100 00101 protected: 00103 00104 TR1::shared_ptr <saga::impl::namespace_entry> get_impl_sp(void) const; 00105 saga::impl::namespace_entry* get_impl (void) const; 00106 00107 friend struct saga::detail::monitorable<entry>; // needs to access get_impl() 00108 friend struct saga::detail::permissions<entry>; 00109 friend class saga::impl::namespace_entry; 00110 00111 typedef saga::detail::monitorable<entry> monitorable_base; 00113 00114 private: 00115 // factory 00116 SAGA_CALL_CREATE_PRIV_3(session const&, saga::url, int) 00117 00118 // basic properties 00119 SAGA_CALL_CONST_PRIV_0(get_url) 00120 SAGA_CALL_CONST_PRIV_0(get_cwd) 00121 SAGA_CALL_CONST_PRIV_0(get_name) 00122 00123 // navigation/query methods 00124 SAGA_CALL_CONST_PRIV_0(read_link) 00125 SAGA_CALL_CONST_PRIV_0(is_dir) 00126 SAGA_CALL_CONST_PRIV_0(is_entry) 00127 SAGA_CALL_CONST_PRIV_0(is_link) 00128 00129 // entry management methods 00130 SAGA_CALL_PRIV_2(copy, saga::url, int) 00131 SAGA_CALL_PRIV_2(link, saga::url, int) 00132 SAGA_CALL_PRIV_2(move, saga::url, int) 00133 SAGA_CALL_PRIV_1(remove, int) 00134 00135 SAGA_CALL_PRIV_1(close, double) 00136 00137 // permissions with flags 00138 SAGA_CALL_PRIV_3(permissions_allow, std::string, int, int) 00139 SAGA_CALL_PRIV_3(permissions_deny, std::string, int, int) 00140 00141 protected: 00143 00144 explicit entry (saga::impl::namespace_entry * init); 00146 00147 public: 00152 entry (session const & s, saga::url url, int mode = Read, 00153 saga::object::type t = saga::object::NSEntry); 00154 00159 explicit 00160 entry (saga::url url, int mode = Read, 00161 saga::object::type t = saga::object::NSEntry); 00162 00167 explicit entry (saga::object const& o); 00168 00173 entry (void); 00174 00179 ~entry (void); 00180 00184 static entry create(session const & s, saga::url url, int mode = Read) 00185 { 00186 return entry(s, url, mode); 00187 } 00188 SAGA_CALL_CREATE_3_DEF_1(session const&, saga::url, int, Read) 00189 00190 00192 static entry create(saga::url url, int mode = Read) 00193 { 00194 return entry(url, mode); 00195 } 00196 template <typename Tag> 00197 static saga::task create(saga::url url, int mode = Read) 00198 { 00199 return create<Tag>(detail::get_the_session(), url, mode); 00200 } 00201 00206 entry &operator= (saga::object const& o); 00207 00214 saga::url get_url() const 00215 { 00216 saga::task t = get_urlpriv(saga::task_base::Sync()); 00217 return t.get_result<saga::url>(); 00218 } 00219 SAGA_CALL_CONST_PUB_0_DEF_0(get_url) 00220 00221 00227 saga::url get_cwd() const 00228 { 00229 saga::task t = get_cwdpriv(saga::task_base::Sync()); 00230 return t.get_result<saga::url>(); 00231 } 00232 SAGA_CALL_CONST_PUB_0_DEF_0(get_cwd) 00233 00234 00240 saga::url get_name() const 00241 { 00242 saga::task t = get_namepriv(saga::task_base::Sync()); 00243 return t.get_result<saga::url>(); 00244 } 00245 SAGA_CALL_CONST_PUB_0_DEF_0(get_name) 00246 00247 00253 saga::url read_link() const 00254 { 00255 saga::task t = read_linkpriv(saga::task_base::Sync()); 00256 return t.get_result<saga::url>(); 00257 } 00258 SAGA_CALL_CONST_PUB_0_DEF_0(read_link) 00259 00260 00266 bool is_dir() const 00267 { 00268 saga::task t = is_dirpriv(saga::task_base::Sync()); 00269 return t.get_result<bool>(); 00270 } 00271 SAGA_CALL_CONST_PUB_0_DEF_0(is_dir) 00272 00273 00279 bool is_entry() const 00280 { 00281 saga::task t = is_entrypriv(saga::task_base::Sync()); 00282 return t.get_result<bool>(); 00283 } 00284 SAGA_CALL_CONST_PUB_0_DEF_0(is_entry) 00285 00286 00291 bool is_link () const 00292 { 00293 saga::task t = is_linkpriv(saga::task_base::Sync()); 00294 return t.get_result<bool>(); 00295 } 00296 SAGA_CALL_CONST_PUB_0_DEF_0(is_link) 00297 00298 00305 void copy(saga::url target, int flags = saga::name_space::None) 00306 { 00307 saga::task t = copypriv(target, flags, saga::task_base::Sync()); 00308 t.get_result (); 00309 } 00310 SAGA_CALL_PUB_2_DEF_1 (copy, saga::url, int, saga::name_space::None) 00311 00312 00319 void link (saga::url target, int flags = saga::name_space::None) 00320 { 00321 saga::task t = linkpriv(target, flags, saga::task_base::Sync()); 00322 t.get_result (); 00323 } 00324 SAGA_CALL_PUB_2_DEF_1 (link, saga::url, int, saga::name_space::None) 00325 00326 00333 void move (saga::url target, int flags = saga::name_space::None) 00334 { 00335 saga::task t = movepriv(target, flags, saga::task_base::Sync()); 00336 t.get_result (); 00337 } 00338 SAGA_CALL_PUB_2_DEF_1 (move, saga::url, int, saga::name_space::None) 00339 00340 00346 void remove (int flags = saga::name_space::None) 00347 { 00348 saga::task t = removepriv(flags, saga::task_base::Sync()); 00349 t.get_result (); 00350 } 00351 SAGA_CALL_PUB_1_DEF_1 (remove, int, saga::name_space::None) 00352 00353 00358 void close (double timeout = 0.0) 00359 { 00360 saga::task t = closepriv(timeout, saga::task_base::Sync()); 00361 t.get_result (); 00362 } 00363 SAGA_CALL_PUB_1_DEF_1 (close, double, 0.0) 00364 00365 // make base class functions available as well 00366 using saga::detail::permissions<entry>::permissions_allow; 00367 using saga::detail::permissions<entry>::permissions_deny; 00368 00378 void permissions_allow (std::string id, int perm, int flags) 00379 { 00380 saga::task t = permissions_allowpriv(id, perm, flags, saga::task_base::Sync()); 00381 t.get_result (); 00382 } 00383 SAGA_CALL_PUB_3_DEF_0 (permissions_allow, std::string, int, int) 00384 00385 00394 void permissions_deny (std::string id, int perm, int flags) 00395 { 00396 saga::task t = permissions_denypriv(id, perm, flags, saga::task_base::Sync()); 00397 t.get_result (); 00398 } 00399 SAGA_CALL_PUB_3_DEF_0 (permissions_deny, std::string, int, int) 00400 00401 }; // namespace_entry 00402 00403 }} 00404 00405 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES) 00406 #pragma wave option(output: null) 00407 #endif 00408 #endif // !defined(SAGA_DEBUG) 00409 00410 // re-enable warnings about dependent classes not being exported from the dll 00411 #if defined(BOOST_MSVC) 00412 #pragma warning(pop) 00413 #endif 00414 00415 #endif // SAGA_PACKAGES_DATA_NAMESPACEENTRY_HPP 00416