00001
00009 #ifndef BS_FOR_EACH_WELL_H_
00010 #define BS_FOR_EACH_WELL_H_
00011
00012 namespace blue_sky {
00013
00019 template <typename strategy_t, typename method_t>
00020 void
00021 for_each_well (facility_manager <strategy_t> &facility_list, method_t method)
00022 {
00023 typename facility_manager <strategy_t>::well_const_iterator_t wb = facility_list.wells_begin ();
00024 typename facility_manager <strategy_t>::well_const_iterator_t we = facility_list.wells_end ();
00025 typedef well <strategy_t> well_t;
00026 typedef smart_ptr <well_t, true> sp_well_t;
00027
00028 for (; wb != we; ++wb)
00029 {
00030 sp_well_t well (wb->second, bs_dynamic_cast ());
00031 BS_ASSERT (well);
00032
00033 if (well->get_connections_count ())
00034 {
00035 method (*well);
00036 }
00037 }
00038 }
00039
00045 template <typename strategy_t, typename method_t>
00046 void
00047 for_each_facility (facility_manager <strategy_t> &facility_list, method_t method)
00048 {
00049 typename facility_manager <strategy_t>::well_const_iterator_t wb = facility_list.wells_begin ();
00050 typename facility_manager <strategy_t>::well_const_iterator_t we = facility_list.wells_end ();
00051
00052 for (; wb != we; ++wb)
00053 {
00054 method (*wb->second);
00055
00056
00057
00058
00059
00060 }
00061 }
00062
00070 template <typename strategy_t, typename method_t>
00071 bool
00072 for_each_well_while_cond (facility_manager <strategy_t> &facility_list, method_t method)
00073 {
00074 typename facility_manager <strategy_t>::well_const_iterator_t wb = facility_list.wells_begin ();
00075 typename facility_manager <strategy_t>::well_const_iterator_t we = facility_list.wells_end ();
00076 typedef well <strategy_t> well_t;
00077 typedef smart_ptr <well_t, true> sp_well_t;
00078
00079 for (; wb != we; ++wb)
00080 {
00081 sp_well_t well (wb->second, bs_dynamic_cast ());
00082 BS_ASSERT (well);
00083 if (well->get_connections_count () && method (*well))
00084 {
00085 return true;
00086 }
00087 }
00088
00089 return false;
00090 }
00098 template <typename strategy_t, typename method_t>
00099 size_t
00100 for_each_well_acc (facility_manager <strategy_t> &facility_list, method_t method)
00101 {
00102 typename facility_manager <strategy_t>::well_const_iterator_t wb = facility_list.wells_begin ();
00103 typename facility_manager <strategy_t>::well_const_iterator_t we = facility_list.wells_end ();
00104 typedef well <strategy_t> well_t;
00105 typedef smart_ptr <well_t, true> sp_well_t;
00106
00107 size_t acc = 0;
00108 for (; wb != we; ++wb)
00109 {
00110 sp_well_t well (wb->second, bs_dynamic_cast ());
00111 BS_ASSERT (well);
00112
00113 if (well->get_connections_count ())
00114 {
00115 acc += method (*well);
00116 }
00117 }
00118
00119 return acc;
00120 }
00121
00122 }
00123
00124 #endif // #ifndef BS_FOR_EACH_WELL_H_
00125