00001 #ifndef SAGA_SAGA_PACKAGES_DATA_CPR_DIRECTORY_HPP
00002 #define SAGA_SAGA_PACKAGES_DATA_CPR_DIRECTORY_HPP
00003
00004 #if defined(__WAVE__)
00005 #pragma wave option(preserve: 2, line: 1, output: "preprocessed/cpr_directory.hpp")
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014 #if defined(__WAVE__)
00015 #pragma wave option(output: null)
00016 #endif
00017
00018 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
00019 #pragma once
00020 #endif
00021
00022
00023 #include <string>
00024
00025
00026 #include <saga/saga/util.hpp>
00027 #include <saga/saga/base.hpp>
00028 #include <saga/saga/call.hpp>
00029 #include <saga/saga/types.hpp>
00030 #include <saga/saga/object.hpp>
00031 #include <saga/saga/session.hpp>
00032 #include <saga/saga/detail/attribute.hpp>
00033
00034 #include <saga/saga/packages/cpr/cpr_checkpoint.hpp>
00035 #include <saga/saga/packages/namespace/namespace_dir.hpp>
00036
00037
00038 #if defined(BOOST_MSVC)
00039 #pragma warning(push)
00040 #pragma warning(disable: 4251 4231 4275 4660 4244)
00041 #endif
00042
00043 #ifdef SAGA_DEBUG
00044 #include <saga/saga/packages/filesystem/preprocessed/cpr_directory.hpp>
00045 #else
00046
00047 #if defined(__WAVE__)
00048 #pragma wave option(preserve: 2, line: 1, output: "preprocessed/cpr_directory.hpp")
00049 #endif
00050
00051 namespace saga
00052 {
00053
00054 namespace cpr
00055 {
00056
00057 namespace metrics
00058 {
00059
00060 char const* const directory_created_entry = "directory.CreatedEntry";
00061 char const* const directory_modified_entry = "directory.ModifiedEntry";
00062 char const* const directory_deleted_entry = "directory.DeletedEntry";
00063 }
00064
00068 class SAGA_CPR_PACKAGE_EXPORT directory
00069 : public saga::name_space::directory,
00070 public saga::detail::attribute<directory>
00071 {
00072 protected:
00074
00075 friend class saga::impl::cpr_directory;
00076 friend struct saga::detail::attribute<directory>;
00077 typedef saga::detail::attribute<directory> attribute_base;
00078 typedef saga::name_space::directory::monitorable_base monitorable_base;
00080
00081 private:
00083
00084 SAGA_CALL_CREATE_PRIV_3(session const&, saga::url, int)
00085
00086
00087 SAGA_CALL_PRIV_1 (is_checkpoint, saga::url)
00088 SAGA_CALL_PRIV_4 (find, std::string, std::vector<std::string>, int, std::string)
00089 SAGA_CALL_PRIV_3 (set_parent, saga::url, saga::url, int)
00090 SAGA_CALL_PRIV_2 (get_parent, saga::url, int)
00091 SAGA_CALL_PRIV_1 (get_file_num, saga::url)
00092 SAGA_CALL_PRIV_1 (list_files, saga::url)
00093 SAGA_CALL_PRIV_2 (add_file, saga::url, saga::url)
00094 SAGA_CALL_PRIV_2 (get_file, saga::url, int)
00095 SAGA_CALL_PRIV_3 (open_file, saga::url, int, int)
00096 SAGA_CALL_PRIV_3 (open_file, saga::url, saga::url, int)
00097 SAGA_CALL_PRIV_2 (remove_file, saga::url, int)
00098 SAGA_CALL_PRIV_2 (remove_file, saga::url, saga::url)
00099 SAGA_CALL_PRIV_3 (update_file, saga::url, int, saga::url)
00100 SAGA_CALL_PRIV_3 (update_file, saga::url, saga::url, saga::url)
00101 SAGA_CALL_PRIV_3 (stage_file, saga::url, int, saga::url)
00102 SAGA_CALL_PRIV_3 (stage_file, saga::url, saga::url, saga::url)
00103 SAGA_CALL_PRIV_2 (stage_file, saga::url, saga::url)
00104
00105
00106 SAGA_CALL_PRIV_2 (open, saga::url, int)
00107 SAGA_CALL_PRIV_2 (open_dir, saga::url, int)
00109
00110 protected:
00112
00113 TR1::shared_ptr <saga::impl::cpr_directory> get_impl_sp() const;
00114 saga::impl::cpr_directory* get_impl() const;
00115 explicit directory(saga::impl::cpr_directory *impl);
00117
00118 public:
00123 directory (session const& s, saga::url url,
00124 int mode = saga::cpr::ReadWrite);
00125
00130 explicit directory (saga::url url,
00131 int mode = saga::cpr::ReadWrite);
00132
00137 explicit directory (saga::object const& o);
00138
00143 directory (void);
00144
00149 ~directory (void);
00150
00154 static directory create(session const& s, saga::url url,
00155 int mode = Read)
00156 {
00157 return directory(s, url, mode);
00158 }
00159 SAGA_CALL_CREATE_3_DEF_1(session const&, saga::url, int, Read)
00160
00161
00163 static directory create(saga::url url, int mode = Read)
00164 {
00165 return directory(url, mode);
00166 }
00167 template <typename Tag>
00168 static saga::task create(saga::url url, int mode = Read)
00169 {
00170 return create<Tag>(detail::get_the_session(), url, mode);
00171 }
00172
00177 directory& operator=(saga::object const& o);
00178
00184 bool is_checkpoint (saga::url url)
00185 {
00186 saga::task t = is_checkpointpriv (url, saga::task_base::Sync());
00187 return t.get_result<bool>();
00188 }
00190 SAGA_CALL_PUB_1_DEF_0 (is_checkpoint, saga::url)
00192
00193
00201 saga::cpr::checkpoint open (saga::url url,
00202 int flags = saga::cpr::Read)
00203 {
00204 saga::task t = openpriv (url, flags, saga::task_base::Sync ());
00205 return t.get_result <saga::cpr::checkpoint> ();
00206 }
00208 SAGA_CALL_PUB_2_DEF_1 (open, saga::url, int, saga::cpr::Read)
00210
00211
00219 saga::cpr::directory open_dir (saga::url url,
00220 int flags = saga::cpr::Read)
00221 {
00222 saga::task t = open_dirpriv(url, flags, saga::task_base::Sync());
00223 return t.get_result<saga::cpr::directory>();
00224 }
00226 SAGA_CALL_PUB_2_DEF_1 (open_dir, saga::url, int, saga::cpr::None)
00228
00229
00238 std::vector<saga::url> find (std::string name_pattern,
00239 std::vector<std::string> const & meta_pattern = std::vector <std::string>(),
00240 int flags = saga::cpr::None,
00241 std::string spec = "")
00242 {
00243 saga::task t = findpriv (name_pattern, meta_pattern, flags, spec,
00244 saga::task_base::Sync());
00245 return t.get_result<std::vector<saga::url> >();
00246 }
00248 SAGA_CALL_PUB_4_DEF_3 (find, std::string,
00249 std::vector<std::string>,
00250 std::vector<std::string>(),
00251 int, saga::cpr::None,
00252 std::string, "");
00254
00261 void set_parent (saga::url checkpoint, saga::url parent, int generation = 1)
00262 {
00263 set_parentpriv (checkpoint, parent, generation,
00264 saga::task_base::Sync());
00265 }
00267 SAGA_CALL_PUB_3_DEF_1 (set_parent, saga::url, saga::url, int, 1)
00269
00270
00275 saga::url get_parent (saga::url checkpoint, int generation = 1)
00276 {
00277 saga::task t = get_parentpriv (checkpoint, generation,
00278 saga::task_base::Sync());
00279 return t.get_result <saga::url> ();
00280 }
00282 SAGA_CALL_PUB_2_DEF_1 (get_parent, saga::url, int, 1)
00284
00285
00286
00291 int get_file_num (saga::url checkpoint)
00292 {
00293 saga::task t = get_file_numpriv(checkpoint, saga::task_base::Sync());
00294 return t.get_result <int> ();
00295 }
00297 SAGA_CALL_PUB_1_DEF_0 (get_file_num, saga::url)
00299
00300
00305 std::vector <saga::url> list_files (saga::url checkpoint)
00306 {
00307 saga::task t = list_filespriv (checkpoint, saga::task_base::Sync());
00308 return t.get_result <std::vector <saga::url> > ();
00309 }
00311 SAGA_CALL_PUB_1_DEF_0 (list_files, saga::url)
00313
00314
00320 int add_file (saga::url checkpoint, saga::url url)
00321 {
00322 saga::task t = add_filepriv(checkpoint, url, saga::task_base::Sync());
00323 return t.get_result <int> ();
00324 }
00326 SAGA_CALL_PUB_2_DEF_0 (add_file, saga::url, saga::url)
00328
00329
00330
00336 saga::url get_file (saga::url checkpoint, int id)
00337 {
00338 saga::task t = get_filepriv(checkpoint, id, saga::task_base::Sync());
00339 return t.get_result <saga::url> ();
00340 }
00342 SAGA_CALL_PUB_2_DEF_0 (get_file, saga::url, int)
00344
00345
00346
00353 saga::filesystem::file open_file (saga::url checkpoint, int id,
00354 int flags = CreateParents | Lock | ReadWrite)
00355 {
00356 saga::task t = open_filepriv(checkpoint, id, flags, saga::task_base::Sync());
00357 return t.get_result <saga::filesystem::file> ();
00358 }
00360 SAGA_CALL_PUB_3_DEF_1 (open_file, saga::url, int, int,
00361 CreateParents | Lock | ReadWrite);
00363
00371 saga::filesystem::file open_file (saga::url checkpoint, saga::url url,
00372 int flags = CreateParents | Lock | ReadWrite)
00373 {
00374 saga::task t = open_filepriv(checkpoint, url, flags, saga::task_base::Sync());
00375 return t.get_result <saga::filesystem::file> ();
00376 }
00378 SAGA_CALL_PUB_3_DEF_1 (open_file, saga::url, saga::url, int,
00379 CreateParents | Lock | ReadWrite);
00381
00382
00389 void remove_file (saga::url checkpoint, int id)
00390 {
00391 saga::task t = remove_filepriv(checkpoint, id, saga::task_base::Sync());
00392 t.get_result ();
00393 }
00395 SAGA_CALL_PUB_2_DEF_0 (remove_file, saga::url, int)
00397
00398
00404 void remove_file (saga::url checkpoint, saga::url url)
00405 {
00406 saga::task t = remove_filepriv(checkpoint, url, saga::task_base::Sync());
00407 t.get_result ();
00408 }
00410 SAGA_CALL_PUB_2_DEF_0 (remove_file, saga::url, saga::url)
00412
00413
00414
00421 void update_file (saga::url checkpoint, int id, saga::url new_url)
00422 {
00423 saga::task t = update_filepriv(checkpoint, id, new_url, saga::task_base::Sync());
00424 t.get_result ();
00425 }
00427 SAGA_CALL_PUB_3_DEF_0 (update_file, saga::url, int, saga::url)
00429
00430
00437 void update_file (saga::url checkpoint, saga::url old_url, saga::url new_url)
00438 {
00439 saga::task t = update_filepriv(checkpoint, old_url, new_url, saga::task_base::Sync());
00440 t.get_result ();
00441 }
00443 SAGA_CALL_PUB_3_DEF_0 (update_file, saga::url, saga::url, saga::url)
00445
00446
00447
00454 void stage_file (saga::url checkpoint, int id, saga::url new_url)
00455 {
00456 saga::task t = stage_filepriv(checkpoint, id, new_url, saga::task_base::Sync());
00457 t.get_result ();
00458 }
00460 SAGA_CALL_PUB_3_DEF_0 (stage_file, saga::url, int, saga::url)
00462
00463
00470 void stage_file (saga::url checkpoint, saga::url old_url, saga::url new_url)
00471 {
00472 saga::task t = stage_filepriv(checkpoint, old_url, new_url, saga::task_base::Sync());
00473 t.get_result ();
00474 }
00476 SAGA_CALL_PUB_3_DEF_0 (stage_file, saga::url, saga::url, saga::url)
00478
00479
00485 void stage_file (saga::url checkpoint, saga::url new_url)
00486 {
00487 saga::task t = stage_filepriv(checkpoint, new_url, saga::task_base::Sync());
00488 t.get_result ();
00489 }
00491 SAGA_CALL_PUB_2_DEF_0 (stage_file, saga::url, saga::url)
00493 };
00494
00495 }}
00496
00497 #if defined(__WAVE__)
00498 #pragma wave option(output: null)
00499 #endif
00500
00501 #endif // !defined(SAGA_DEBUG)
00502
00503
00504 #if defined(BOOST_MSVC)
00505 #pragma warning(pop)
00506 #endif
00507
00508 #endif // SAGA_SAGA_PACKAGES_DATA_CPR_DIRECTORY_HPP