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
00030 #ifndef _COUPLING_POLICY_HXX_
00031 #define _COUPLING_POLICY_HXX_
00032
00033 #include "IteratorTraits.hxx"
00034 #include "FindKeyPredicate.hxx"
00035 #include <algorithm>
00036 #include <functional>
00037 #include <iterator>
00038
00039
00040
00041
00042
00043
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 class CouplingPolicy {
00066
00067 public:
00068
00069
00070
00071
00072
00073
00074
00075
00076 template < typename Container >
00077 bool isDataIdConveniant(Container & storedDatas,
00078 const typename Container::key_type & expectedDataId,
00079 bool & isEqual , bool & isBounded,
00080 typename Container::iterator & wDataIt1 ) const {
00081 typedef typename Container::key_type key_type;
00082 typedef typename Container::value_type value_type;
00083 typedef typename Container::iterator iterator;
00084 isBounded = false;
00085 FindKeyPredicate<value_type> fkp(expectedDataId);
00086 wDataIt1 = std::find_if(storedDatas.begin(),storedDatas.end(),fkp);
00087 isEqual = (wDataIt1 != storedDatas.end());
00088 std::cout << "-------- Generic isDataIdConvenient : isEqual : " << isEqual << " , isBounded " << isBounded << std::endl;
00089 return isEqual || isBounded;
00090 }
00091
00092
00093
00094
00095
00096
00097 template <typename DataManipulator, class EnableIf = void >
00098 struct BoundedDataIdProcessor{
00099 BoundedDataIdProcessor(const CouplingPolicy & couplingPolicy) {};
00100 template < typename Iterator, typename DataId >
00101 void inline apply(typename iterator_t<Iterator>::value_type & data,
00102 const DataId & dataId,
00103 const Iterator & it1) const {
00104 typedef typename iterator_t<Iterator>::value_type value_type;
00105 std::cout << "-------- Generic BoundedDataIdProcessor.apply() called " << std::endl;
00106
00107 }
00108 };
00109
00110
00111
00112
00113
00114
00115 template <typename DataManipulator>
00116 struct EraseDataIdProcessor {
00117
00118 EraseDataIdProcessor(CouplingPolicy couplingPolicy) {};
00119
00120 template < typename Container >
00121 void apply(Container & storedDatas,
00122 typename Container::iterator & wDataIt1 ) const {
00123 typedef typename Container::key_type key_type;
00124 typedef typename Container::value_type value_type;
00125 typedef typename Container::iterator iterator;
00126
00127 std::cout << "-------- Generic eraseDataId called " << std::endl;
00128 }
00129 };
00130
00131
00132
00133
00134
00135
00136 template < typename DataManipulator >
00137 struct DisconnectProcessor {
00138
00139 DisconnectProcessor(const CouplingPolicy & couplingPolicy) {};
00140
00141 template < typename Container, typename DataId >
00142 bool apply(Container & storedDatas,
00143 const DataId & expectedDataId,
00144 typename Container::iterator & wDataIt1 ) const {
00145 typedef typename Container::key_type key_type;
00146 typedef typename Container::value_type value_type;
00147 typedef typename Container::iterator iterator;
00148
00149 std::cout << "-------- Generic DisconnectProcessor called " << std::endl;
00150 return true;
00151 }
00152 };
00153
00154
00155 template <typename DataManipulator>
00156 struct EraseDataIdBeforeOrAfterTagProcessor {
00157
00158 EraseDataIdBeforeOrAfterTagProcessor(CouplingPolicy couplingPolicy) {};
00159
00160 template < typename Container , typename TimeType , typename TagType >
00161 void apply(Container & storedDatas, TimeType time, TagType tag, bool before ) const {
00162 typedef typename Container::key_type key_type;
00163 typedef typename Container::value_type value_type;
00164 typedef typename Container::iterator iterator;
00165 }
00166 };
00167
00168
00169
00170 virtual void wakeupWaiting(){};
00171
00172 virtual ~CouplingPolicy() {}
00173
00174 };
00175
00176 #endif