SAGA C++ API 1.6
logical_file.cpp
Go to the documentation of this file.
00001 #if defined(__WAVE__)
00002 #pragma wave option(preserve: 2, line: 1, output: "preprocessed/logical_file.cpp")
00003 #endif
00004 //  Copyright (c) 2005-2009 Hartmut Kaiser
00005 // 
00006 //  Distributed under the Boost Software License, Version 1.0. (See accompanying 
00007 //  job LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
00008 
00009 #if defined(__WAVE__)
00010 #pragma wave option(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 <saga/saga/task.hpp>
00019 
00020 // include file API and implementation
00021 #include <saga/saga/replica.hpp>
00022 #include <saga/impl/replica.hpp>
00023 #include <saga/saga/detail/call.hpp>
00024 
00025 #include <saga/saga/detail/attribute_impl.hpp>
00026 
00027 #ifdef SAGA_DEBUG
00028 #include <saga/saga/packages/replica/preprocessed/logical_file.cpp>
00029 #else
00030 
00031 #if defined(__WAVE__)
00032 #pragma wave option(preserve: 2, line: 1, output: "preprocessed/logical_file.cpp")
00033 #endif
00034 
00035 namespace saga 
00036 {    
00037     namespace replica {
00038  
00040         namespace metrics
00041         {
00043             saga::metrics::init_data const logical_file_metric_data[] = 
00044             {
00045                 // logical_file specific metrics
00046                 {
00047                     saga::replica::metrics::logical_file_modified,
00048                     "Metric fires on logical file changes, it carries the key of"
00049                     "the modified logical file.",
00050                     attributes::metric_mode_readonly,
00051                     "1", 
00052                     attributes::metric_type_string,
00053                     ""
00054                 },
00055                 {
00056                     saga::replica::metrics::logical_file_deleted,
00057                     "Metric fires on logical file deletes, it carries the key of" 
00058                     "the deleted logical file.",
00059                     attributes::metric_mode_readonly,
00060                     "1", 
00061                     attributes::metric_type_string,
00062                     ""
00063                 },
00064             };
00066         }
00067 
00068         logical_file::logical_file (session const& s, saga::url url, int mode)
00069         :   entry (new saga::impl::logical_file (s, url, mode))
00070         {
00071             // initialize attribute implementation
00072             this->attribute_base::init (true);    // no constraints on attributes
00073 
00074             // initialize implementation object
00075             this->saga::object::get_impl()->init();
00076 
00077             // initialize metrics
00078             std::vector<saga::metric> metrics;
00079             for (unsigned int i = 0; 
00080                  i < sizeof(metrics::logical_file_metric_data)/sizeof(saga::metrics::init_data);
00081                  ++i)
00082             {
00083                 saga::metrics::init_data const* p = &metrics::logical_file_metric_data[i];
00084                 saga::metric m(*this, p->name, p->description, p->mode, p->unit, 
00085                                p->type, p->value);
00086                 metrics.push_back(m);
00087             }
00088             this->monitorable_base::init (metrics);
00089         }
00090 
00091         logical_file::logical_file (saga::url url, int mode)
00092         :   entry (new saga::impl::logical_file (detail::get_the_session (), url, mode))
00093         {
00094             // initialize attribute implementation
00095             this->attribute_base::init (true);    // no constraints on attributes
00096 
00097             // initialize implementation object
00098             this->saga::object::get_impl()->init();
00099 
00100             // initialize metrics
00101             std::vector<saga::metric> metrics;
00102             for (unsigned int i = 0; 
00103                  i < sizeof(metrics::logical_file_metric_data)/sizeof(saga::metrics::init_data);
00104                  ++i)
00105             {
00106                 saga::metrics::init_data const* p = &metrics::logical_file_metric_data[i];
00107                 saga::metric m(*this, p->name, p->description, p->mode, p->unit, 
00108                                p->type, p->value);
00109                 metrics.push_back(m);
00110             }
00111             this->monitorable_base::init (metrics);
00112         }
00113 
00114         logical_file::logical_file(saga::object const& o)
00115         : entry(o)
00116         {
00117             if (this->get_type() != saga::object::LogicalFile)
00118             {
00119                 SAGA_THROW("Bad type conversion.", saga::BadParameter);
00120             }
00121         }
00122 
00123         logical_file::logical_file (void) 
00124         {
00125         }
00126 
00127         logical_file::logical_file(saga::impl::logical_file *impl)
00128         : entry (impl)
00129         {
00130         }
00131 
00132         logical_file::~logical_file (void)
00133         {
00134         }
00135 
00136         logical_file &logical_file::operator= (saga::object const& o)
00137         {
00138             return this->saga::name_space::entry::operator=(o), *this;
00139         }
00140 
00141         saga::impl::logical_file* logical_file::get_impl() const
00142         { 
00143             typedef saga::object base_type;
00144             return static_cast<saga::impl::logical_file*>(this->base_type::get_impl()); 
00145         }
00146 
00147         TR1::shared_ptr <saga::impl::logical_file> logical_file::get_impl_sp(void) const
00148         { 
00149             // FIXME: this needs documentation
00150             typedef saga::object base_type;
00151             return TR1::static_pointer_cast <saga::impl::logical_file> (
00152                 this->base_type::get_impl_sp());
00153         }
00154 
00155         // factory
00156         SAGA_CALL_CREATE_IMP_3(logical_file, impl::logical_file, session const&, saga::url, int)
00157 
00158         // methods not covered by the namespace_entry
00159         SAGA_CALL_IMP_1(logical_file, add_location, saga::url)
00160         SAGA_CALL_IMP_1(logical_file, remove_location, saga::url)
00161         SAGA_CALL_IMP_2(logical_file, update_location, saga::url, saga::url)
00162         SAGA_CALL_IMP_0(logical_file, list_locations)
00163         SAGA_CALL_IMP_2(logical_file, replicate, saga::url, int)
00164         
00165     }   // namespace replica
00166 
00167     namespace detail
00168     {
00170         //  implement the attribute functions (we need to explicitly specialize 
00171         //  the template because the functions are not implemented inline)
00172         template struct SAGA_REPLICA_PACKAGE_EXPORT_REPEAT attribute<replica::logical_file>;
00173 
00174         template struct SAGA_REPLICA_PACKAGE_EXPORT attribute_priv<replica::logical_file, task_base::Sync>;
00175         template struct SAGA_REPLICA_PACKAGE_EXPORT attribute_priv<replica::logical_file, task_base::Async>;
00176         template struct SAGA_REPLICA_PACKAGE_EXPORT attribute_priv<replica::logical_file, task_base::Task>;
00177 
00178         template struct SAGA_REPLICA_PACKAGE_EXPORT attribute_sync<replica::logical_file>;
00179     }
00180 
00182 } // namespace saga
00183 
00184 #endif
00185 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines