SAGA Adaptor CPI v.1.0
|
00001 // Copyright (c) 2005-2006 Stephan Hirmer (shirmer@cct.lsu.edu) 00002 // 00003 // Distributed under the Boost Software License, Version 1.0. (See accompanying 00004 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 00005 00006 #ifndef SAGA_ADAPTOR_BULK_CONTAINER_HPP 00007 #define SAGA_ADAPTOR_BULK_CONTAINER_HPP 00008 00009 00010 #include <vector> 00011 00012 #include <boost/spirit/phoenix/tuples.hpp> 00013 00014 #include <saga/saga/adaptors/bulk_container_base.hpp> 00015 #include <saga/saga/uuid.hpp> 00016 00017 #if defined(BOOST_MSVC) 00018 #pragma warning(push) 00019 #pragma warning(disable: 4251 4231 4275 4660) 00020 #endif 00021 00023 namespace saga { namespace adaptors { 00024 00026 // forward declaration 00027 00036 template < 00037 typename Cpi, 00038 typename FuncRetVal, 00039 typename FuncArg0 = phoenix::nil_t, 00040 typename FuncArg1 = phoenix::nil_t, 00041 typename FuncArg2 = phoenix::nil_t, 00042 typename FuncArg3 = phoenix::nil_t, 00043 typename FuncArg4 = phoenix::nil_t, 00044 typename FuncArg5 = phoenix::nil_t, 00045 typename FuncArg6 = phoenix::nil_t> 00046 class bulk_container; 00047 00049 00057 template<typename Cpi, typename FuncRetVal> 00058 inline void 00059 create_bulk_container_or_add_params(Cpi* cpi, bulk_container_base *& bc, 00060 std::vector<saga::uuid> (Cpi::*exec_bulk) 00061 (std::vector<FuncRetVal>&, std::vector<saga::uuid>& ), 00062 FuncRetVal const& retval_, saga::uuid task_uuid_) 00063 { 00064 typedef saga::adaptors::bulk_container<Cpi, FuncRetVal> 00065 bulk_container_type; 00066 00067 /*boost::fusion::tuple<FuncRetVal, saga::uuid> val (retval_, task_uuid_);*/ 00068 00069 if (NULL == bc) 00070 bc = new bulk_container_type(cpi, exec_bulk, retval_, task_uuid_); 00071 else 00072 static_cast<bulk_container_type *>(bc)->add_params(retval_, task_uuid_); 00073 } 00074 00076 00084 template <typename Cpi, typename FuncRetVal> 00085 class bulk_container <Cpi, FuncRetVal, 00086 phoenix::nil_t, phoenix::nil_t, phoenix::nil_t, phoenix::nil_t, 00087 phoenix::nil_t, phoenix::nil_t, phoenix::nil_t> 00088 : public saga::adaptors::bulk_container_base 00089 { 00090 private: 00091 typedef phoenix::tuple <FuncRetVal, saga::uuid> tuple_type; 00092 00093 std::vector<saga::uuid> uuids; 00094 std::vector<FuncRetVal> rets; 00095 00096 std::vector<saga::uuid> (Cpi::*exec_bulk) (std::vector<FuncRetVal>&, 00097 std::vector<saga::uuid>&); 00098 Cpi * my_adaptor; 00099 00100 public: 00106 bulk_container (Cpi* cpi_, 00107 std::vector<saga::uuid> (Cpi::*exec_bulk_) 00108 (std::vector<FuncRetVal>&, 00109 std::vector<saga::uuid>&), 00110 FuncRetVal retval, saga::uuid task_uuid) 00111 : exec_bulk (exec_bulk_), 00112 my_adaptor (cpi_) 00113 00114 { 00115 this->add_params (retval, task_uuid); 00116 } 00117 00121 ~bulk_container (void) {} 00122 00126 bulk_container *add_params (FuncRetVal retval_, saga::uuid task_uuid ) 00127 { 00128 //ops_args.push_back (val); 00129 rets.push_back(retval_); 00130 uuids.push_back(task_uuid); 00131 return this; 00132 } 00133 00138 std::vector<saga::uuid> execute_bulk (void) 00139 { 00140 return (my_adaptor->*exec_bulk) (rets, uuids); 00141 } 00142 00143 }; // class bulk_container 00144 00146 // bring in higher order functions 00147 #include <saga/saga/adaptors/bulk_container_impl.hpp> 00148 00150 }} // namespace saga::adaptors 00151 00152 00153 00154 #endif // SAGA_ADAPTOR_BULK_CONTAINER_HPP 00155