1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>MySQL++ Reference Manual</title>
<meta http-equiv="Content-type" content="text/html;charset=iso-8859-1">
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="refman.css" rel="stylesheet" type="text/css">
</head>
<body>
<!-- Generated by Doxygen 1.4.7 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li id="current"><a href="files.html"><span>Files</span></a></li>
</ul></div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File List</span></a></li>
<li><a href="globals.html"><span>File Members</span></a></li>
</ul></div>
<h1>insertpolicy.h</h1><a href="insertpolicy_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
<a name="l00002"></a>00002
<a name="l00003"></a>00003
<a name="l00004"></a>00004
<a name="l00005"></a>00005
<a name="l00006"></a>00006
<a name="l00007"></a>00007
<a name="l00008"></a>00008
<a name="l00009"></a>00009
<a name="l00010"></a>00010
<a name="l00011"></a>00011
<a name="l00012"></a>00012
<a name="l00013"></a>00013
<a name="l00014"></a>00014
<a name="l00015"></a>00015
<a name="l00016"></a>00016
<a name="l00017"></a>00017
<a name="l00018"></a>00018
<a name="l00019"></a>00019
<a name="l00020"></a>00020
<a name="l00021"></a>00021
<a name="l00022"></a>00022
<a name="l00023"></a>00023
<a name="l00024"></a>00024
<a name="l00025"></a>00025
<a name="l00026"></a>00026
<a name="l00027"></a>00027
<a name="l00028"></a>00028
<a name="l00029"></a>00029
<a name="l00030"></a>00030
<a name="l00031"></a>00031
<a name="l00032"></a>00032 <span class="comment">/***********************************************************************</span>
<a name="l00033"></a>00033 <span class="comment"> Copyright (c) 2008-2009 by AboveNet, Inc., and (c) 2009 by Educational</span>
<a name="l00034"></a>00034 <span class="comment"> Technology Resources, Inc. Others may also hold copyrights on code</span>
<a name="l00035"></a>00035 <span class="comment"> in this file. See the CREDITS file in the top directory of the</span>
<a name="l00036"></a>00036 <span class="comment"> distribution for details.</span>
<a name="l00037"></a>00037 <span class="comment"></span>
<a name="l00038"></a>00038 <span class="comment"> This file is part of MySQL++.</span>
<a name="l00039"></a>00039 <span class="comment"></span>
<a name="l00040"></a>00040 <span class="comment"> MySQL++ is free software; you can redistribute it and/or modify it</span>
<a name="l00041"></a>00041 <span class="comment"> under the terms of the GNU Lesser General Public License as published</span>
<a name="l00042"></a>00042 <span class="comment"> by the Free Software Foundation; either version 2.1 of the License, or</span>
<a name="l00043"></a>00043 <span class="comment"> (at your option) any later version.</span>
<a name="l00044"></a>00044 <span class="comment"></span>
<a name="l00045"></a>00045 <span class="comment"> MySQL++ is distributed in the hope that it will be useful, but WITHOUT</span>
<a name="l00046"></a>00046 <span class="comment"> ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or</span>
<a name="l00047"></a>00047 <span class="comment"> FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public</span>
<a name="l00048"></a>00048 <span class="comment"> License for more details.</span>
<a name="l00049"></a>00049 <span class="comment"></span>
<a name="l00050"></a>00050 <span class="comment"> You should have received a copy of the GNU Lesser General Public</span>
<a name="l00051"></a>00051 <span class="comment"> License along with MySQL++; if not, write to the Free Software</span>
<a name="l00052"></a>00052 <span class="comment"> Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301</span>
<a name="l00053"></a>00053 <span class="comment"> USA</span>
<a name="l00054"></a>00054 <span class="comment">***********************************************************************/</span>
<a name="l00055"></a>00055
<a name="l00056"></a>00056 <span class="preprocessor">#if !defined(MYSQLPP_INSERTPOLICY_H)</span>
<a name="l00057"></a>00057 <span class="preprocessor"></span><span class="preprocessor">#define MYSQLPP_INSERTPOLICY_H</span>
<a name="l00058"></a>00058 <span class="preprocessor"></span>
<a name="l00065"></a>00065 <span class="keyword">template</span> <<span class="keyword">class</span> AccessController = Transaction>
<a name="l00066"></a><a class="code" href="classRowCountInsertPolicy.html">00066</a> <span class="keyword">class </span>MYSQLPP_EXPORT <a class="code" href="classRowCountInsertPolicy.html">RowCountInsertPolicy</a>
<a name="l00067"></a>00067 {
<a name="l00068"></a>00068 <span class="keyword">public</span>:
<a name="l00070"></a><a class="code" href="classRowCountInsertPolicy.html#da78427b0495b6dcffdbbedfbd91d1bc">00070</a> <a class="code" href="classRowCountInsertPolicy.html">RowCountInsertPolicy</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> rows) :
<a name="l00071"></a>00071 cur_rows_(0),
<a name="l00072"></a>00072 max_rows_(rows)
<a name="l00073"></a>00073 {
<a name="l00074"></a>00074 }
<a name="l00075"></a>00075
<a name="l00077"></a><a class="code" href="classRowCountInsertPolicy.html#ed2bda29ac9d38bff3b47f4a285e1d6b">00077</a> ~<a class="code" href="classRowCountInsertPolicy.html">RowCountInsertPolicy</a>() { }
<a name="l00078"></a>00078
<a name="l00083"></a>00083 <span class="keyword">template</span> <<span class="keyword">class</span> RowT>
<a name="l00084"></a><a class="code" href="classRowCountInsertPolicy.html#bbb91511fa21f267890e0464e17ad69d">00084</a> <span class="keywordtype">bool</span> can_add(<span class="keywordtype">int</span>, <span class="keyword">const</span> RowT&)
<a name="l00085"></a>00085 {
<a name="l00086"></a>00086 <span class="keywordflow">if</span> (++cur_rows_ > max_rows_) {
<a name="l00087"></a>00087 cur_rows_ = 0;
<a name="l00088"></a>00088 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00089"></a>00089 }
<a name="l00090"></a>00090 <span class="keywordflow">else</span> {
<a name="l00091"></a>00091 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00092"></a>00092 }
<a name="l00093"></a>00093 }
<a name="l00094"></a>00094
<a name="l00096"></a><a class="code" href="classRowCountInsertPolicy.html#4904cc50ad00c8eae56bff0d7db9e52c">00096</a> <span class="keyword">typedef</span> AccessController access_controller;
<a name="l00097"></a>00097
<a name="l00098"></a>00098 <span class="keyword">private</span>:
<a name="l00099"></a>00099 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> cur_rows_;
<a name="l00100"></a>00100 <span class="keywordtype">unsigned</span> <span class="keyword">const</span> <span class="keywordtype">int</span> max_rows_;
<a name="l00101"></a>00101 };
<a name="l00102"></a>00102
<a name="l00103"></a>00103
<a name="l00111"></a>00111 <span class="keyword">template</span> <<span class="keyword">class</span> AccessController = Transaction>
<a name="l00112"></a><a class="code" href="classSizeThresholdInsertPolicy.html">00112</a> <span class="keyword">class </span>MYSQLPP_EXPORT SizeThresholdInsertPolicy
<a name="l00113"></a>00113 {
<a name="l00114"></a>00114 <span class="keyword">public</span>:
<a name="l00116"></a><a class="code" href="classSizeThresholdInsertPolicy.html#906fb0ee7cd08e682d348b9d1fb083e6">00116</a> SizeThresholdInsertPolicy(<span class="keywordtype">int</span> size) :
<a name="l00117"></a>00117 size_(size)
<a name="l00118"></a>00118 {
<a name="l00119"></a>00119 }
<a name="l00120"></a>00120
<a name="l00122"></a><a class="code" href="classSizeThresholdInsertPolicy.html#d8258f038c4e5a03b5517558f00e0849">00122</a> ~SizeThresholdInsertPolicy() { }
<a name="l00123"></a>00123
<a name="l00131"></a>00131 <span class="keyword">template</span> <<span class="keyword">class</span> RowT>
<a name="l00132"></a><a class="code" href="classSizeThresholdInsertPolicy.html#2a1e33e96b573ef9e0a58edd89da72a0">00132</a> <span class="keywordtype">bool</span> can_add(<span class="keywordtype">int</span> size, <span class="keyword">const</span> RowT& object)<span class="keyword"> const</span>
<a name="l00133"></a>00133 <span class="keyword"> </span>{
<a name="l00134"></a>00134 <span class="keywordflow">return</span> (size < size_);
<a name="l00135"></a>00135 }
<a name="l00136"></a>00136
<a name="l00138"></a><a class="code" href="classSizeThresholdInsertPolicy.html#33d4e8d394d426d4c0e76301965ac506">00138</a> <span class="keyword">typedef</span> AccessController access_controller;
<a name="l00139"></a>00139
<a name="l00140"></a>00140 <span class="keyword">private</span>:
<a name="l00141"></a>00141 <span class="keywordtype">int</span> size_;
<a name="l00142"></a>00142 };
<a name="l00143"></a>00143
<a name="l00144"></a>00144
<a name="l00152"></a>00152 <span class="keyword">template</span> <<span class="keyword">class</span> AccessController = Transaction>
<a name="l00153"></a><a class="code" href="classMaxPacketInsertPolicy.html">00153</a> <span class="keyword">class </span>MYSQLPP_EXPORT MaxPacketInsertPolicy
<a name="l00154"></a>00154 {
<a name="l00155"></a>00155 <span class="keyword">public</span>:
<a name="l00161"></a><a class="code" href="classMaxPacketInsertPolicy.html#a29c31d5052c44cbf6ee8aa112b1490d">00161</a> MaxPacketInsertPolicy(Connection* con, <span class="keywordtype">int</span> size) :
<a name="l00162"></a>00162 conn_(con), size_(size)
<a name="l00163"></a>00163 {
<a name="l00164"></a>00164 }
<a name="l00165"></a>00165
<a name="l00174"></a><a class="code" href="classMaxPacketInsertPolicy.html#9c313c2291382b11c12b5d5adb5c6b7b">00174</a> MaxPacketInsertPolicy(<span class="keywordtype">int</span> size) :
<a name="l00175"></a>00175 conn_(0), size_(size)
<a name="l00176"></a>00176 {
<a name="l00177"></a>00177 }
<a name="l00178"></a>00178
<a name="l00180"></a><a class="code" href="classMaxPacketInsertPolicy.html#4ec3c03e60ebfdb6d15b76b254826903">00180</a> ~MaxPacketInsertPolicy() { }
<a name="l00181"></a>00181
<a name="l00189"></a>00189 <span class="keyword">template</span> <<span class="keyword">class</span> RowT>
<a name="l00190"></a><a class="code" href="classMaxPacketInsertPolicy.html#519cee157016f1204c3a7115d43c1f4e">00190</a> <span class="keywordtype">bool</span> can_add(<span class="keywordtype">int</span> size, <span class="keyword">const</span> RowT& object)<span class="keyword"> const</span>
<a name="l00191"></a>00191 <span class="keyword"> </span>{
<a name="l00192"></a>00192 <span class="keywordflow">if</span> (size < size_) {
<a name="l00193"></a>00193 <span class="comment">// Haven't hit size threshold yet, so see if this next</span>
<a name="l00194"></a>00194 <span class="comment">// item pushes it over the line.</span>
<a name="l00195"></a>00195 SQLStream s(conn_);
<a name="l00196"></a>00196 s << <span class="stringliteral">",("</span> << object.value_list() << <span class="stringliteral">")"</span>;
<a name="l00197"></a>00197 <span class="keywordflow">return</span> (size_ - size) >= static_cast<int>(s.str().size());
<a name="l00198"></a>00198 }
<a name="l00199"></a>00199 <span class="keywordflow">else</span> {
<a name="l00200"></a>00200 <span class="comment">// Already too much in query buffer!</span>
<a name="l00201"></a>00201 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00202"></a>00202 }
<a name="l00203"></a>00203 }
<a name="l00204"></a>00204
<a name="l00206"></a><a class="code" href="classMaxPacketInsertPolicy.html#12b4378f273aa6c4a398ae3a254d2cfc">00206</a> <span class="keyword">typedef</span> AccessController access_controller;
<a name="l00207"></a>00207
<a name="l00208"></a>00208 <span class="keyword">private</span>:
<a name="l00209"></a>00209 Connection* conn_;
<a name="l00210"></a>00210 <span class="keywordtype">int</span> size_;
<a name="l00211"></a>00211 };
<a name="l00212"></a>00212
<a name="l00213"></a>00213 <span class="preprocessor">#endif // !defined(MYSQLPP_INSERTPOLICY_H)</span>
<a name="l00214"></a>00214 <span class="preprocessor"></span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on 10 Dec 2013 for MySQL++ by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.7 </small></address>
</body>
</html>
|