SAGA C++ API 1.6
advert.cpp
Go to the documentation of this file.
00001 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES)
00002 #pragma wave option(preserve: 2, line: 1, output: "preprocessed/advert.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__) && defined(SAGA_CREATE_PREPROCESSED_FILES)
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_ADVERT_PACKAGE_EXPORT
00017 
00018 //  this is needed in every file including detail/monitorable_impl.hpp and not 
00019 //  belonging to the engine
00020 #define SAGA_NO_IMPORT_MONITORABLE
00021 
00022 #include <saga/saga/util.hpp>
00023 #include <saga/saga/task.hpp>
00024 
00025 // include file API and implementation
00026 #include <saga/saga/advert.hpp>
00027 #include <saga/impl/advert.hpp>
00028 #include <saga/impl/engine/metric.hpp>
00029 #include <saga/saga/detail/call.hpp>
00030 
00031 #include <saga/saga/detail/attribute_impl.hpp>
00032 #include <saga/saga/detail/monitorable_impl.hpp>
00033 
00034 #ifdef SAGA_DEBUG
00035 #include <saga/saga/packages/filesystem/preprocessed/advert.cpp>
00036 #else
00037 
00038 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES)
00039 #pragma wave option(preserve: 2, line: 1, output: "preprocessed/advert.cpp")
00040 #endif
00041 
00043 namespace saga 
00044 {
00045     namespace advert 
00046     {
00047         namespace metrics
00048         {
00050             saga::metrics::init_data const advert_metric_data[] = 
00051             {
00052                 // advert specific metrics
00053                 {
00054                     advert_modified,
00055                     "Metric fires on advert entry changes, it carries the key of"
00056                     "the modified entry.",
00057                     attributes::metric_mode_readonly,
00058                     "1", 
00059                     attributes::metric_type_string,
00060                     ""
00061                 },
00062                 {
00063                     advert_deleted,
00064                     "Metric fires on advert entry deletes, it carries the key of" 
00065                     "the deleted entry.",
00066                     attributes::metric_mode_readonly,
00067                     "1", 
00068                     attributes::metric_type_string,
00069                     ""
00070                 },
00071             };
00073             
00075         }   // namespace saga::metrics
00076         
00077         
00078         entry::entry (session const& s, saga::url url, int mode)
00079         :   name_space::entry (new saga::impl::advert (s, url, mode))
00080         {
00081             // initialize attribute implementation
00082             this->attribute_base::init (true);    // no constraints on attributes
00083 
00084             // initialize implementation object
00085             this->saga::object::get_impl()->init();
00086 
00087             // initialize metrics
00088             std::vector<saga::metric> metrics;
00089             for (unsigned int i = 0; 
00090                  i < sizeof(saga::advert::metrics::advert_metric_data)/sizeof(saga::metrics::init_data);
00091                  ++i)
00092             {
00093                 saga::metrics::init_data const* p = &saga::advert::metrics::advert_metric_data[i];
00094                 saga::metric m(*this, p->name, p->description, p->mode, p->unit, 
00095                                p->type, p->value);
00096                 metrics.push_back(m);
00097             }
00098             this->monitorable_base::init (metrics);
00099         }
00100         
00101         entry::entry (saga::url url, int mode)
00102         :   name_space::entry (new saga::impl::advert (detail::get_the_session (), url, mode))
00103         {
00104             // initialize attribute implementation
00105             this->attribute_base::init (true);    // no constraints on attributes
00106 
00107             // initialize implementation object
00108             this->saga::object::get_impl()->init();
00109 
00110             // initialize metrics
00111             std::vector<saga::metric> metrics;
00112             for (unsigned int i = 0; 
00113                  i < sizeof(saga::advert::metrics::advert_metric_data)/sizeof(saga::metrics::init_data);
00114                  ++i)
00115             {
00116                 saga::metrics::init_data const* p = &saga::advert::metrics::advert_metric_data[i];
00117                 saga::metric m(*this, p->name, p->description, p->mode, p->unit, 
00118                                p->type, p->value);
00119                 metrics.push_back(m);
00120             }
00121             this->monitorable_base::init (metrics);
00122         }
00123         
00124         entry::entry (void) 
00125         {
00126         }
00127         
00128         entry::entry(saga::impl::advert *impl)
00129         : name_space::entry (impl)
00130         {
00131         }
00132         
00133         entry::entry (saga::object const& o)
00134         : name_space::entry(o)
00135         {
00136             if (this->get_type() != saga::object::Advert)
00137             {
00138                 SAGA_THROW("Bad type conversion.", saga::BadParameter);
00139             }
00140         }
00141         
00142         entry::~entry (void)
00143         {
00144         }
00145         
00146         entry &entry::operator= (saga::object const& o)
00147         {
00148             return this->saga::name_space::entry::operator=(o), *this;
00149         }
00150 
00151         saga::impl::advert* entry::get_impl() const
00152         { 
00153             typedef saga::object base_type;
00154             return static_cast<saga::impl::advert*>(this->base_type::get_impl()); 
00155         }
00156 
00157         TR1::shared_ptr <saga::impl::advert> entry::get_impl_sp(void) const
00158         { 
00159             // FIXME: this needs documentation
00160             typedef saga::object base_type;
00161             return TR1::static_pointer_cast <saga::impl::advert> (
00162                 this->base_type::get_impl_sp());
00163         }
00164 
00165         // factory
00166         SAGA_CALL_CREATE_IMP_3(entry, impl::advert, session const&, saga::url const&, int)
00167 
00168         // methods not covered by the namespace_entry
00169         SAGA_CALL_IMP_1 (entry, store_object, saga::object)
00170         SAGA_CALL_IMP_1 (entry, retrieve_object, saga::session)
00171 
00172         saga::task entry::retrieve_objectpriv (saga::task_base::Sync)
00173         { 
00174             return get_impl()->retrieve_object(saga::detail::get_the_session(), true); 
00175         }
00176         saga::task entry::retrieve_objectpriv (saga::task_base::Async)
00177         { 
00178             return saga::detail::run(get_impl()->retrieve_object(saga::detail::get_the_session())); 
00179         }
00180         saga::task entry::retrieve_objectpriv (saga::task_base::Task)
00181         { 
00182             return get_impl()->retrieve_object(saga::detail::get_the_session()); 
00183         }
00184 
00185         SAGA_CALL_IMP_1 (entry, store_string, std::string)
00186         SAGA_CALL_IMP_0 (entry, retrieve_string)
00187 
00188     }   // namespace advert
00189 
00190     namespace detail
00191     {
00193         //  implement the attribute functions (we need to explicitly specialize 
00194         //  the template because the functions are not implemented inline)
00195         template struct SAGA_ADVERT_PACKAGE_EXPORT_REPEAT attribute<advert::entry>;
00196 
00197         template struct SAGA_ADVERT_PACKAGE_EXPORT attribute_priv<advert::entry, task_base::Sync>;
00198         template struct SAGA_ADVERT_PACKAGE_EXPORT attribute_priv<advert::entry, task_base::Async>;
00199         template struct SAGA_ADVERT_PACKAGE_EXPORT attribute_priv<advert::entry, task_base::Task>;
00200 
00201         template struct SAGA_ADVERT_PACKAGE_EXPORT attribute_sync<advert::entry>;
00202     }
00203 
00205 } // namespace saga
00206 
00207 #endif
00208 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines