00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef _COUPLING_POLICY_HXX_
00030 #define _COUPLING_POLICY_HXX_
00031
00032 #include "IteratorTraits.hxx"
00033 #include "FindKeyPredicate.hxx"
00034 #include <algorithm>
00035 #include <functional>
00036 #include <iterator>
00037
00038
00039
00040
00041
00042
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 class CouplingPolicy {
00065
00066 public:
00067
00068
00069
00070
00071
00072
00073
00074
00075 template < typename Container >
00076 bool isDataIdConveniant(Container & storedDatas,
00077 const typename Container::key_type & expectedDataId,
00078 bool & isEqual , bool & isBounded,
00079 typename Container::iterator & wDataIt1 ) const {
00080 typedef typename Container::key_type key_type;
00081 typedef typename Container::value_type value_type;
00082 typedef typename Container::iterator iterator;
00083 isBounded = false;
00084 FindKeyPredicate<value_type> fkp(expectedDataId);
00085 wDataIt1 = std::find_if(storedDatas.begin(),storedDatas.end(),fkp);
00086 isEqual = (wDataIt1 != storedDatas.end());
00087 std::cout << "-------- Generic isDataIdConvenient : isEqual : " << isEqual << " , isBounded " << isBounded << std::endl;
00088 return isEqual || isBounded;
00089 }
00090
00091
00092
00093
00094
00095
00096 template <typename DataManipulator, class EnableIf = void >
00097 struct BoundedDataIdProcessor{
00098 BoundedDataIdProcessor(const CouplingPolicy & couplingPolicy) {};
00099 template < typename Iterator, typename DataId >
00100 void inline apply(typename iterator_t<Iterator>::value_type & data,
00101 const DataId & dataId,
00102 const Iterator & it1) const {
00103 typedef typename iterator_t<Iterator>::value_type value_type;
00104 std::cout << "-------- Generic BoundedDataIdProcessor.apply() called " << std::endl;
00105
00106 }
00107 };
00108
00109
00110
00111
00112
00113
00114 template <typename DataManipulator>
00115 struct EraseDataIdProcessor {
00116
00117 EraseDataIdProcessor(CouplingPolicy couplingPolicy) {};
00118
00119 template < typename Container >
00120 void apply(Container & storedDatas,
00121 typename Container::iterator & wDataIt1 ) const {
00122 typedef typename Container::key_type key_type;
00123 typedef typename Container::value_type value_type;
00124 typedef typename Container::iterator iterator;
00125
00126 std::cout << "-------- Generic eraseDataId called " << std::endl;
00127 }
00128 };
00129
00130
00131
00132
00133
00134
00135 template < typename DataManipulator >
00136 struct DisconnectProcessor {
00137
00138 DisconnectProcessor(const CouplingPolicy & couplingPolicy) {};
00139
00140 template < typename Container, typename DataId >
00141 bool apply(Container & storedDatas,
00142 const DataId & expectedDataId,
00143 typename Container::iterator & wDataIt1 ) const {
00144 typedef typename Container::key_type key_type;
00145 typedef typename Container::value_type value_type;
00146 typedef typename Container::iterator iterator;
00147
00148 std::cout << "-------- Generic DisconnectProcessor called " << std::endl;
00149 return true;
00150 }
00151 };
00152
00153
00154
00155 virtual void wakeupWaiting(){};
00156
00157 virtual ~CouplingPolicy() {}
00158
00159 };
00160
00161 #endif