SAGA C++ API 1.6
logical_directory.cpp
Go to the documentation of this file.
00001 #if defined(__WAVE__)
00002 #pragma wave option(preserve: 2, line: 1, output: "preprocessed/logical_directory.cpp")
00003 #endif
00004 //  Copyright (c) 2005-2009 Hartmut Kaiser
00005 // 
00006 //  Distributed under the Boost Software License, Version 1.0. (See accompanying 
00007 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
00008 
00009 #if defined(__WAVE__)
00010 #pragma wave option(preserve: 0, output: null)
00011 #endif
00012 
00013 //  this is needed in every file including detail/attribute_impl.hpp and not 
00014 //  belonging to the engine
00015 #define SAGA_NO_IMPORT_ATTRIBUTE
00016 #define SAGA_EXPORT_ATTRIBUTE     SAGA_REPLICA_PACKAGE_EXPORT
00017 
00018 // include directory api and implementation
00019 #include <string>
00020 #include <vector>
00021 
00022 #include <saga/saga/task.hpp>
00023 
00024 // include the package we implement
00025 #include <saga/saga/call.hpp>
00026 #include <saga/saga/replica.hpp>
00027 #include <saga/impl/replica.hpp>
00028 #include <saga/saga/detail/call.hpp>
00029 
00030 #include <saga/saga/detail/attribute_impl.hpp>
00031 
00032 #ifdef SAGA_DEBUG
00033 #include <saga/saga/packages/replica/preprocessed/logical_directory.cpp>
00034 #else
00035 
00036 #if defined(__WAVE__)
00037 #pragma wave option(preserve: 2, line: 1, output: "preprocessed/logical_directory.cpp")
00038 #endif
00039 
00040 namespace saga 
00041 {
00042     
00043     namespace replica {
00044         
00046         namespace metrics
00047         {
00049             saga::metrics::init_data const logical_directory_metric_data[] = 
00050             {
00051                 // logical_directory specific metrics
00052                 {
00053                     saga::replica::metrics::logical_directory_created_entry,
00054                     "Metric fires on logical file creates, it carries the key of"
00055                     "the new logical file.",
00056                     saga::attributes::metric_mode_readonly,
00057                     "1", 
00058                     saga::attributes::metric_type_string,
00059                     ""
00060                 },
00061                 {
00062                     saga::replica::metrics::logical_directory_modified_entry,
00063                     "Metric fires on logical file changes, it carries the key of"
00064                     "the modified logical file.",
00065                     saga::attributes::metric_mode_readonly,
00066                     "1", 
00067                     saga::attributes::metric_type_string,
00068                     ""
00069                 },
00070                 {
00071                     saga::replica::metrics::logical_directory_deleted_entry,
00072                     "Metric fires on logical file deletes, it carries the key of" 
00073                     "the deleted logical file.",
00074                     saga::attributes::metric_mode_readonly,
00075                     "1", 
00076                     saga::attributes::metric_type_string,
00077                     ""
00078                 },
00079             };
00081         }
00082         
00083         logical_directory::logical_directory (session const& s, saga::url url, 
00084                                               int mode)
00085         : name_space::directory (new saga::impl::logical_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(metrics::logical_directory_metric_data)/sizeof(saga::metrics::init_data);
00097                  ++i)
00098             {
00099                 saga::metrics::init_data const* p = &metrics::logical_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         logical_directory::logical_directory (saga::url url, int mode)
00108         : name_space::directory (new saga::impl::logical_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(metrics::logical_directory_metric_data)/sizeof(saga::metrics::init_data);
00120                  ++i)
00121             {
00122                 saga::metrics::init_data const* p = &metrics::logical_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         logical_directory::logical_directory(saga::object const& o)
00131         : name_space::directory(o)
00132         {
00133             if (this->get_type() != saga::object::LogicalDirectory)
00134             {
00135                 SAGA_THROW("Bad type conversion.", saga::BadParameter);
00136             }
00137         }
00138 
00139         logical_directory::logical_directory (void)
00140         {
00141         }
00142 
00143         logical_directory::logical_directory(saga::impl::logical_directory *impl)
00144         : name_space::directory (impl)
00145         {
00146         }
00147 
00148         logical_directory::~logical_directory (void)
00149         {
00150         }
00151         
00152         logical_directory &logical_directory::operator= (saga::object const& o)
00153         {
00154             return this->saga::name_space::directory::operator=(o), *this;
00155         }
00156 
00157         saga::impl::logical_directory* logical_directory::get_impl() const
00158         { 
00159             typedef saga::object base_type;
00160             return static_cast<saga::impl::logical_directory*>(this->base_type::get_impl()); 
00161         }
00162 
00163         TR1::shared_ptr <saga::impl::logical_directory> logical_directory::get_impl_sp() const
00164         { 
00165             typedef saga::object base_type;
00166             return TR1::static_pointer_cast<saga::impl::logical_directory>(
00167                 this->base_type::get_impl_sp()); 
00168         }
00169 
00170         // factory
00171         SAGA_CALL_CREATE_IMP_3(logical_directory, impl::logical_directory, session const&, saga::url, int)
00172 
00173         // get file info
00174         SAGA_CALL_IMP_1 (logical_directory, is_file,  saga::url)
00175 
00176         // overload open methods from namespace_dir
00177         SAGA_CALL_IMP_2 (logical_directory, open, saga::url, int)
00178         SAGA_CALL_IMP_2 (logical_directory, open_dir, saga::url, int)
00179         SAGA_CALL_IMP_3 (logical_directory, find, std::string, std::vector<std::string>, int)
00180     }   // namespace replica
00181 
00182     namespace detail
00183     {
00185         //  implement the attribute functions (we need to explicitly specialize 
00186         //  the template because the functions are not implemented inline)
00187         template struct SAGA_REPLICA_PACKAGE_EXPORT_REPEAT attribute<replica::logical_directory>;
00188 
00189         template struct SAGA_REPLICA_PACKAGE_EXPORT attribute_priv<replica::logical_directory, task_base::Sync>;
00190         template struct SAGA_REPLICA_PACKAGE_EXPORT attribute_priv<replica::logical_directory, task_base::Async>;
00191         template struct SAGA_REPLICA_PACKAGE_EXPORT attribute_priv<replica::logical_directory, task_base::Task>;
00192 
00193         template struct SAGA_REPLICA_PACKAGE_EXPORT attribute_sync<replica::logical_directory>;
00194     }
00195 
00197 } // namespace saga
00198 #endif
00199 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines