SAGA C++ API 1.6
|
00001 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES) 00002 #pragma wave option(preserve: 2, line: 1, output: "preprocessed/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__) && defined(SAGA_CREATE_PREPROCESSED_FILES) 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_ADVERT_PACKAGE_EXPORT 00017 00018 // include directory API and implementation 00019 #include <string> 00020 #include <vector> 00021 00022 // include the package we implement 00023 #include <saga/saga/call.hpp> 00024 #include <saga/saga/advert.hpp> 00025 #include <saga/saga/adaptors/task.hpp> 00026 #include <saga/impl/advert.hpp> 00027 #include <saga/saga/detail/call.hpp> 00028 00029 #include <saga/saga/detail/attribute_impl.hpp> 00030 00031 #ifdef SAGA_DEBUG 00032 #include <saga/saga/packages/advert/preprocessed/directory.cpp> 00033 #else 00034 00035 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES) 00036 #pragma wave option(preserve: 2, line: 1, output: "preprocessed/directory.cpp") 00037 #endif 00038 00040 namespace saga 00041 { 00042 namespace advert 00043 { 00044 00045 namespace metrics 00046 { 00048 saga::metrics::init_data const directory_metric_data[] = 00049 { 00050 // directory specific metrics 00051 { 00052 directory_created_entry, 00053 "Metric fires on advert entry creates, it carries the key of" 00054 "the new entry.", 00055 attributes::metric_mode_readonly, 00056 "1", 00057 attributes::metric_type_string, 00058 "" 00059 }, 00060 { 00061 directory_modified_entry, 00062 "Metric fires on advert entry changes, it carries the key of" 00063 "the modified entry.", 00064 attributes::metric_mode_readonly, 00065 "1", 00066 attributes::metric_type_string, 00067 "" 00068 }, 00069 { 00070 directory_deleted_entry, 00071 "Metric fires on advert entry deletes, it carries the key of" 00072 "the deleted entry.", 00073 attributes::metric_mode_readonly, 00074 "1", 00075 attributes::metric_type_string, 00076 "" 00077 }, 00078 }; 00080 00082 } // namespace saga::metrics 00083 00084 directory::directory (session const& s, saga::url url, int mode) 00085 : name_space::directory (new saga::impl::advert_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::advert::metrics::directory_metric_data)/sizeof(saga::metrics::init_data); 00097 ++i) 00098 { 00099 saga::metrics::init_data const* p = &saga::advert::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::advert_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::advert::metrics::directory_metric_data)/sizeof(saga::metrics::init_data); 00120 ++i) 00121 { 00122 saga::metrics::init_data const* p = &saga::advert::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 (void) 00131 { 00132 } 00133 00134 directory::directory(saga::impl::advert_directory *impl) 00135 : name_space::directory (impl) 00136 { 00137 } 00138 00139 directory::directory (saga::object const& o) 00140 : name_space::directory(o) 00141 { 00142 if (this->get_type() != saga::object::AdvertDirectory) 00143 { 00144 SAGA_THROW("Bad type conversion.", saga::BadParameter); 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::advert_directory* directory::get_impl() const 00158 { 00159 typedef saga::object base_type; 00160 return static_cast<saga::impl::advert_directory*>(this->base_type::get_impl()); 00161 } 00162 00163 TR1::shared_ptr <saga::impl::advert_directory> directory::get_impl_sp() const 00164 { 00165 typedef saga::object base_type; 00166 return TR1::static_pointer_cast<saga::impl::advert_directory>( 00167 this->base_type::get_impl_sp()); 00168 } 00169 00170 // factory 00171 SAGA_CALL_CREATE_IMP_3(directory, impl::advert_directory, session const&, saga::url const&, int) 00172 00173 // overload open methods from namespace_dir 00174 SAGA_CALL_IMP_2 (directory, open, saga::url, int) 00175 SAGA_CALL_IMP_2 (directory, open_dir, saga::url, int) 00176 SAGA_CALL_IMP_3 (directory, find, std::string, std::vector<std::string>, int) 00177 00178 } // namespace advert 00179 00180 namespace detail 00181 { 00183 // implement the attribute functions (we need to explicitly specialize 00184 // the template because the functions are not implemented inline) 00185 template struct SAGA_ADVERT_PACKAGE_EXPORT_REPEAT attribute<advert::directory>; 00186 00187 template struct SAGA_ADVERT_PACKAGE_EXPORT attribute_priv<advert::directory, task_base::Sync>; 00188 template struct SAGA_ADVERT_PACKAGE_EXPORT attribute_priv<advert::directory, task_base::Async>; 00189 template struct SAGA_ADVERT_PACKAGE_EXPORT attribute_priv<advert::directory, task_base::Task>; 00190 00191 template struct SAGA_ADVERT_PACKAGE_EXPORT attribute_sync<advert::directory>; 00192 } 00193 00195 } // namespace saga 00196 00197 #endif 00198