SAGA C++ API 1.6
cpr_directory.cpp
Go to the documentation of this file.
00001 #if defined(__WAVE__)
00002 #pragma wave option(preserve: 2, line: 1, output: "preprocessed/cpr_directory.cpp")
00003 #endif
00004 //  Copyright (c) 2005-2009 Hartmut Kaiser
00005 //  Copyright (c) 2008 Andre Merzky (andre@merzky.net)
00006 // 
00007 //  Distributed under the Boost Software License, Version 1.0. (See accompanying 
00008 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
00009 
00010 #if defined(__WAVE__)
00011 #pragma wave option(preserve: 0, output: null)
00012 #endif
00013 
00014 //  this is needed in every file including detail/attribute_impl.hpp and not 
00015 //  belonging to the engine
00016 #define SAGA_NO_IMPORT_ATTRIBUTE
00017 #define SAGA_EXPORT_ATTRIBUTE       SAGA_CPR_PACKAGE_EXPORT
00018 
00019 // include directory api and implementation
00020 #include <string>
00021 #include <vector>
00022 
00023 #include <saga/saga/task.hpp>
00024 
00025 // include the package we implement
00026 #include <saga/saga/call.hpp>
00027 #include <saga/saga/cpr.hpp>
00028 #include <saga/impl/cpr.hpp>
00029 #include <saga/saga/detail/call.hpp>
00030 
00031 #include <saga/saga/detail/attribute_impl.hpp>
00032 
00033 #ifdef SAGA_DEBUG
00034 #include <saga/saga/packages/cpr/preprocessed/cpr_directory.cpp>
00035 #else
00036 
00037 #if defined(__WAVE__)
00038 #pragma wave option(preserve: 2, line: 1, output: "preprocessed/cpr_directory.cpp")
00039 #endif
00040 
00041 namespace saga 
00042 {
00043     namespace cpr 
00044     {
00045         
00046         namespace metrics
00047         {
00049             saga::metrics::init_data const directory_metric_data[] = 
00050             {
00051                 // cpr_directory specific metrics
00052                 {
00053                     directory_created_entry,
00054                     "Metric fires on checkpoint creates, it carries the key of"
00055                     "the new checkpoint.",
00056                     saga::attributes::metric_mode_readonly,
00057                     "1", 
00058                     saga::attributes::metric_type_string,
00059                     ""
00060                 },
00061                 {
00062                     directory_modified_entry,
00063                     "Metric fires on checkpoint changes, it carries the key of"
00064                     "the modified checkpoint.",
00065                     saga::attributes::metric_mode_readonly,
00066                     "1", 
00067                     saga::attributes::metric_type_string,
00068                     ""
00069                 },
00070                 {
00071                     directory_deleted_entry,
00072                     "Metric fires on checkpoint deletes, it carries the key of" 
00073                     "the deleted checkpoint.",
00074                     saga::attributes::metric_mode_readonly,
00075                     "1", 
00076                     saga::attributes::metric_type_string,
00077                     ""
00078                 },
00079             };
00081         } // namespace metrics
00082 
00083         directory::directory (session const& s, saga::url url, 
00084                               int mode)
00085         : name_space::directory (new saga::impl::cpr_directory (s, url, mode))
00086         {
00087             // initialize attribute implementation
00088             this->attribute_base::init (true);    // no constraints on attributes
00089 
00090             // initialize implementation object
00091             this->saga::object::get_impl()->init();
00092 
00093             // initialize metrics
00094             std::vector<saga::metric> metrics;
00095             for (unsigned int i = 0; 
00096                  i < sizeof(saga::cpr::metrics::directory_metric_data)/sizeof(saga::metrics::init_data);
00097                  ++i)
00098             {
00099                 saga::metrics::init_data const* p = &saga::cpr::metrics::directory_metric_data[i];
00100                 saga::metric m(*this, p->name, p->description, p->mode, p->unit, 
00101                                p->type, p->value);
00102                 metrics.push_back(m);
00103             }
00104             this->monitorable_base::init (metrics);
00105         }
00106 
00107         directory::directory (saga::url url, int mode)
00108         : name_space::directory (new saga::impl::cpr_directory (detail::get_the_session (), url, mode))
00109         {
00110             // initialize attribute implementation
00111             this->attribute_base::init (true);    // no constraints on attributes
00112 
00113             // initialize implementation object
00114             this->saga::object::get_impl()->init();
00115 
00116             // initialize metrics
00117             std::vector<saga::metric> metrics;
00118             for (unsigned int i = 0; 
00119                  i < sizeof(saga::cpr::metrics::directory_metric_data)/sizeof(saga::metrics::init_data);
00120                  ++i)
00121             {
00122                 saga::metrics::init_data const* p = &saga::cpr::metrics::directory_metric_data[i];
00123                 saga::metric m(*this, p->name, p->description, p->mode, p->unit, 
00124                                p->type, p->value);
00125                 metrics.push_back(m);
00126             }
00127             this->monitorable_base::init (metrics);
00128         }
00129 
00130         directory::directory(saga::object const& o)
00131         : name_space::directory(o)
00132         {
00133             if (this->get_type() != saga::object::CPRDirectory)
00134             {
00135                 SAGA_THROW("Bad type conversion.", saga::BadParameter);
00136             }
00137         }
00138 
00139         directory::directory (void)
00140         {
00141         }
00142 
00143         directory::directory(saga::impl::cpr_directory *impl)
00144         : name_space::directory (impl)
00145         {
00146         }
00147 
00148         directory::~directory (void)
00149         {
00150         }
00151 
00152         directory &directory::operator= (saga::object const& o)
00153         {
00154             return this->saga::name_space::directory::operator=(o), *this;
00155         }
00156 
00157         saga::impl::cpr_directory* directory::get_impl() const
00158         { 
00159             typedef saga::object base_type;
00160             return static_cast<saga::impl::cpr_directory*>(this->base_type::get_impl()); 
00161         }
00162 
00163         TR1::shared_ptr <saga::impl::cpr_directory> directory::get_impl_sp() const
00164         { 
00165             typedef saga::object base_type;
00166             return TR1::static_pointer_cast<saga::impl::cpr_directory>(
00167                 this->base_type::get_impl_sp()); 
00168         }
00169 
00170         // factory
00171         SAGA_CALL_CREATE_IMP_3(directory, impl::cpr_directory, session const&, saga::url, int)
00172 
00173         
00174         SAGA_CALL_IMP_1    (directory, is_checkpoint,                         saga::url);
00175         SAGA_CALL_IMP_4    (directory, find,                                  std::string, std::vector<std::string>, int, std::string);
00176         SAGA_CALL_IMP_3    (directory, set_parent,                            saga::url, saga::url, int);
00177         SAGA_CALL_IMP_2    (directory, get_parent,                            saga::url, int);
00178         SAGA_CALL_IMP_1    (directory, get_file_num,                          saga::url);
00179         SAGA_CALL_IMP_1    (directory, list_files,                            saga::url);
00180         SAGA_CALL_IMP_2    (directory, add_file,                              saga::url, saga::url);
00181         SAGA_CALL_IMP_2    (directory, get_file,                              saga::url, int);
00182         SAGA_CALL_IMP_3    (directory, open_file,                             saga::url, saga::url, int);
00183         SAGA_CALL_IMP_3_EX (directory, open_file,     open_file_idx,          saga::url, int,       int);
00184         SAGA_CALL_IMP_2    (directory, remove_file,                           saga::url, saga::url);
00185         SAGA_CALL_IMP_2_EX (directory, remove_file,   remove_file_idx,        saga::url, int);
00186         SAGA_CALL_IMP_3    (directory, update_file,                           saga::url, saga::url, saga::url);
00187         SAGA_CALL_IMP_3_EX (directory, update_file,   update_file_idx,        saga::url, int,       saga::url);
00188         SAGA_CALL_IMP_3    (directory, stage_file,                            saga::url, saga::url, saga::url);
00189         SAGA_CALL_IMP_3_EX (directory, stage_file,    stage_file_idx,         saga::url, int,       saga::url);
00190         SAGA_CALL_IMP_2_EX (directory, stage_file,    stage_file_all,         saga::url, saga::url);
00191 
00192         // overload open methods from namespace_dir
00193         SAGA_CALL_IMP_2    (directory, open,                                  saga::url, int);
00194         SAGA_CALL_IMP_2    (directory, open_dir,                              saga::url, int);
00195 
00197 
00198     }   // namespace cpr
00199 
00200     namespace detail
00201     {
00203         //  implement the attribute functions (we need to explicitly specialize 
00204         //  the template because the functions are not implemented inline)
00205         template struct SAGA_CPR_PACKAGE_EXPORT_REPEAT attribute<cpr::directory>;
00206 
00207         template struct SAGA_CPR_PACKAGE_EXPORT attribute_priv<cpr::directory, task_base::Sync>;
00208         template struct SAGA_CPR_PACKAGE_EXPORT attribute_priv<cpr::directory, task_base::Async>;
00209         template struct SAGA_CPR_PACKAGE_EXPORT attribute_priv<cpr::directory, task_base::Task>;
00210 
00211         template struct SAGA_CPR_PACKAGE_EXPORT attribute_sync<cpr::directory>;
00212     }
00213 
00215 } // namespace saga
00216 #endif
00217 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines