Tarball tree for barry-0.17.0.tar.bz2
[barry.git] / doc / www / doxygen / html / m__desktop_8h-source.html
blob9c0bdcf6f5698f0cde239101d2d16d0da3fa170e
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
3 <title>Barry: m_desktop.h Source File</title>
4 <link href="doxygen.css" rel="stylesheet" type="text/css">
5 <link href="tabs.css" rel="stylesheet" type="text/css">
6 </head><body>
7 <!-- Generated by Doxygen 1.5.6 -->
8 <div class="navigation" id="top">
9 <div class="tabs">
10 <ul>
11 <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
12 <li><a href="modules.html"><span>Modules</span></a></li>
13 <li><a href="namespaces.html"><span>Namespaces</span></a></li>
14 <li><a href="classes.html"><span>Classes</span></a></li>
15 <li class="current"><a href="files.html"><span>Files</span></a></li>
16 <li><a href="dirs.html"><span>Directories</span></a></li>
17 </ul>
18 </div>
19 <div class="navpath"><a class="el" href="dir_edc0f428e3eefcfdce9c25befd901c57.html">src</a>
20 </div>
21 </div>
22 <div class="contents">
23 <h1>m_desktop.h</h1><a href="m__desktop_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">///</span>
24 <a name="l00002"></a>00002 <span class="comment"></span><span class="comment">/// \file m_desktop.h</span>
25 <a name="l00003"></a>00003 <span class="comment"></span><span class="comment">/// Mode class for the Desktop mode</span>
26 <a name="l00004"></a>00004 <span class="comment"></span><span class="comment">///</span>
27 <a name="l00005"></a>00005 <span class="comment"></span>
28 <a name="l00006"></a>00006 <span class="comment">/*</span>
29 <a name="l00007"></a>00007 <span class="comment"> Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/)</span>
30 <a name="l00008"></a>00008 <span class="comment"></span>
31 <a name="l00009"></a>00009 <span class="comment"> This program is free software; you can redistribute it and/or modify</span>
32 <a name="l00010"></a>00010 <span class="comment"> it under the terms of the GNU General Public License as published by</span>
33 <a name="l00011"></a>00011 <span class="comment"> the Free Software Foundation; either version 2 of the License, or</span>
34 <a name="l00012"></a>00012 <span class="comment"> (at your option) any later version.</span>
35 <a name="l00013"></a>00013 <span class="comment"></span>
36 <a name="l00014"></a>00014 <span class="comment"> This program is distributed in the hope that it will be useful,</span>
37 <a name="l00015"></a>00015 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
38 <a name="l00016"></a>00016 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</span>
39 <a name="l00017"></a>00017 <span class="comment"></span>
40 <a name="l00018"></a>00018 <span class="comment"> See the GNU General Public License in the COPYING file at the</span>
41 <a name="l00019"></a>00019 <span class="comment"> root directory of this project for more details.</span>
42 <a name="l00020"></a>00020 <span class="comment">*/</span>
43 <a name="l00021"></a>00021
44 <a name="l00022"></a>00022 <span class="preprocessor">#ifndef __BARRY_M_DESKTOP_H__</span>
45 <a name="l00023"></a>00023 <span class="preprocessor"></span><span class="preprocessor">#define __BARRY_M_DESKTOP_H__</span>
46 <a name="l00024"></a>00024 <span class="preprocessor"></span>
47 <a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="dll_8h.html" title="Macros for handling DLL/library API visibility.">dll.h</a>"</span>
48 <a name="l00026"></a>00026 <span class="preprocessor">#include "<a class="code" href="m__mode__base_8h.html" title="Base for mode classes.">m_mode_base.h</a>"</span>
49 <a name="l00027"></a>00027 <span class="preprocessor">#include "<a class="code" href="data_8h.html" title="Class to deal with pre-saved data files.">data.h</a>"</span>
50 <a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="socket_8h.html" title="Class wrapper to encapsulate the Blackberry USB logical socket.">socket.h</a>"</span>
51 <a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="record_8h.html" title="Blackberry database record classes.">record.h</a>"</span>
52 <a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="parser_8h.html" title="Virtual parser wrapper.">parser.h</a>"</span>
53 <a name="l00031"></a>00031 <span class="preprocessor">#include "<a class="code" href="builder_8h.html" title="Virtual protocol packet builder wrapper.">builder.h</a>"</span>
54 <a name="l00032"></a>00032
55 <a name="l00033"></a>00033 <span class="keyword">namespace </span>Barry {
56 <a name="l00034"></a>00034
57 <a name="l00035"></a>00035 <span class="comment">// forward declarations</span>
58 <a name="l00036"></a>00036 <span class="keyword">class </span>Parser;
59 <a name="l00037"></a>00037 <span class="keyword">class </span>IConverter;
60 <a name="l00038"></a>00038
61 <a name="l00039"></a>00039 <span class="keyword">namespace </span>Mode {
62 <a name="l00040"></a>00040
63 <a name="l00041"></a>00041 <span class="keyword">class </span>DBLoader;
64 <a name="l00042"></a>00042
65 <a name="l00043"></a>00043 <span class="comment">//</span>
66 <a name="l00044"></a>00044 <span class="comment">// Desktop class</span>
67 <a name="l00045"></a>00045 <span class="comment">//</span><span class="comment"></span>
68 <a name="l00046"></a>00046 <span class="comment">/// The main interface class to the device databases.</span>
69 <a name="l00047"></a>00047 <span class="comment">///</span>
70 <a name="l00048"></a>00048 <span class="comment">/// To use this class, use the following steps:</span>
71 <a name="l00049"></a>00049 <span class="comment">///</span>
72 <a name="l00050"></a>00050 <span class="comment">/// - Create a Controller object (see Controller class for more details)</span>
73 <a name="l00051"></a>00051 <span class="comment">/// - Create this Mode::Desktop object, passing in the Controller</span>
74 <a name="l00052"></a>00052 <span class="comment">/// object during construction</span>
75 <a name="l00053"></a>00053 <span class="comment">/// - Call Open() to open database socket and finish constructing.</span>
76 <a name="l00054"></a>00054 <span class="comment">/// - Call GetDBDB() to get the device's database database</span>
77 <a name="l00055"></a>00055 <span class="comment">/// - Call GetDBID() to get a database ID by name</span>
78 <a name="l00056"></a>00056 <span class="comment">/// - Call LoadDatabase() to retrieve and store a database</span>
79 <a name="l00057"></a>00057 <span class="comment">///</span>
80 <a name="l00058"></a><a class="code" href="classBarry_1_1Mode_1_1Desktop.html">00058</a> <span class="comment"></span><span class="keyword">class </span>BXEXPORT <a class="code" href="classBarry_1_1Mode_1_1Desktop.html" title="The main interface class to the device databases.">Desktop</a> : <span class="keyword">public</span> <a class="code" href="classBarry_1_1Mode_1_1Mode.html" title="Base class for simple mode classes.">Mode</a>
81 <a name="l00059"></a>00059 {
82 <a name="l00060"></a>00060 <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classBarry_1_1Mode_1_1DBLoader.html" title="Database Loader operation class.">DBLoader</a>;
83 <a name="l00061"></a>00061
84 <a name="l00062"></a>00062 <span class="keyword">public</span>:
85 <a name="l00063"></a>00063 <span class="keyword">enum</span> CommandType { Unknown, DatabaseAccess };
86 <a name="l00064"></a>00064
87 <a name="l00065"></a>00065 <span class="keyword">private</span>:
88 <a name="l00066"></a>00066 <span class="comment">// packet data</span>
89 <a name="l00067"></a>00067 Data m_command, m_response;
90 <a name="l00068"></a>00068
91 <a name="l00069"></a>00069 CommandTable m_commandTable;
92 <a name="l00070"></a>00070 DatabaseDatabase m_dbdb;
93 <a name="l00071"></a>00071
94 <a name="l00072"></a>00072 <span class="comment">// external objects (optional, can be null)</span>
95 <a name="l00073"></a>00073 <span class="keyword">const</span> <a class="code" href="classBarry_1_1IConverter.html" title="Main charset conversion class, primarily focused on converting between the Blackberry...">IConverter</a> *m_ic;
96 <a name="l00074"></a>00074
97 <a name="l00075"></a>00075 <span class="keyword">protected</span>:
98 <a name="l00076"></a>00076 <span class="keywordtype">void</span> LoadCommandTable();
99 <a name="l00077"></a>00077 <span class="keywordtype">void</span> LoadDBDB();
100 <a name="l00078"></a>00078 <span class="comment"></span>
101 <a name="l00079"></a>00079 <span class="comment"> //////////////////////////////////</span>
102 <a name="l00080"></a>00080 <span class="comment"></span> <span class="comment">// overrides</span>
103 <a name="l00081"></a>00081
104 <a name="l00082"></a>00082 <span class="keyword">virtual</span> <span class="keywordtype">void</span> OnOpen();
105 <a name="l00083"></a>00083
106 <a name="l00084"></a>00084 <span class="keyword">public</span>:
107 <a name="l00085"></a>00085 <a class="code" href="classBarry_1_1Mode_1_1Desktop.html" title="The main interface class to the device databases.">Desktop</a>(<a class="code" href="classBarry_1_1Controller.html" title="The main interface class.">Controller</a> &amp;con);
108 <a name="l00086"></a>00086 <a class="code" href="classBarry_1_1Mode_1_1Desktop.html" title="The main interface class to the device databases.">Desktop</a>(<a class="code" href="classBarry_1_1Controller.html" title="The main interface class.">Controller</a> &amp;con, <span class="keyword">const</span> <a class="code" href="classBarry_1_1IConverter.html" title="Main charset conversion class, primarily focused on converting between the Blackberry...">IConverter</a> &amp;ic);
109 <a name="l00087"></a>00087 ~<a class="code" href="classBarry_1_1Mode_1_1Desktop.html" title="The main interface class to the device databases.">Desktop</a>();
110 <a name="l00088"></a>00088 <span class="comment"></span>
111 <a name="l00089"></a>00089 <span class="comment"> //////////////////////////////////</span>
112 <a name="l00090"></a>00090 <span class="comment"></span> <span class="comment">// meta access</span>
113 <a name="l00091"></a>00091 <span class="comment"></span>
114 <a name="l00092"></a>00092 <span class="comment"> /// Returns DatabaseDatabase object for this connection.</span>
115 <a name="l00093"></a>00093 <span class="comment"> /// Must call Open() first, which loads the DBDB.</span>
116 <a name="l00094"></a><a class="code" href="classBarry_1_1Mode_1_1Desktop.html#41d83954c0bcc4b3a707c7501269c5b9">00094</a> <span class="comment"></span> <span class="keyword">const</span> DatabaseDatabase&amp; GetDBDB()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_dbdb; }
117 <a name="l00095"></a>00095 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> GetDBID(<span class="keyword">const</span> std::string &amp;name) <span class="keyword">const</span>;
118 <a name="l00096"></a>00096 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> GetDBCommand(CommandType ct);
119 <a name="l00097"></a>00097
120 <a name="l00098"></a>00098 <span class="keywordtype">void</span> SetIConverter(<span class="keyword">const</span> <a class="code" href="classBarry_1_1IConverter.html" title="Main charset conversion class, primarily focused on converting between the Blackberry...">IConverter</a> &amp;ic);
121 <a name="l00099"></a>00099 <span class="comment"></span>
122 <a name="l00100"></a>00100 <span class="comment"> //////////////////////////////////</span>
123 <a name="l00101"></a>00101 <span class="comment"></span> <span class="comment">// Desktop mode - database specific</span>
124 <a name="l00102"></a>00102
125 <a name="l00103"></a>00103 <span class="comment">// dirty flag related functions, for sync operations</span>
126 <a name="l00104"></a>00104 <span class="keywordtype">void</span> GetRecordStateTable(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> dbId, RecordStateTable &amp;result);
127 <a name="l00105"></a>00105 <span class="keywordtype">void</span> AddRecord(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> dbId, <a class="code" href="classBarry_1_1Builder.html" title="Base class for the builder functor hierarchy.">Builder</a> &amp;build); <span class="comment">// RecordId is</span>
128 <a name="l00106"></a>00106 <span class="comment">// retrieved from build, and duplicate IDs are allowed,</span>
129 <a name="l00107"></a>00107 <span class="comment">// but *not* recommended!</span>
130 <a name="l00108"></a>00108 <span class="keywordtype">void</span> GetRecord(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> dbId, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> stateTableIndex, <a class="code" href="classBarry_1_1Parser.html" title="Base class for the parser hierarchy.">Parser</a> &amp;parser);
131 <a name="l00109"></a>00109 <span class="keywordtype">void</span> SetRecord(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> dbId, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> stateTableIndex, <a class="code" href="classBarry_1_1Builder.html" title="Base class for the builder functor hierarchy.">Builder</a> &amp;build);
132 <a name="l00110"></a>00110 <span class="keywordtype">void</span> ClearDirty(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> dbId, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> stateTableIndex);
133 <a name="l00111"></a>00111 <span class="keywordtype">void</span> DeleteRecord(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> dbId, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> stateTableIndex);
134 <a name="l00112"></a>00112
135 <a name="l00113"></a>00113 <span class="comment">// pure load/save operations</span>
136 <a name="l00114"></a>00114 <span class="keywordtype">void</span> LoadDatabase(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> dbId, <a class="code" href="classBarry_1_1Parser.html" title="Base class for the parser hierarchy.">Parser</a> &amp;parser);
137 <a name="l00115"></a>00115 <span class="keywordtype">void</span> ClearDatabase(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> dbId);
138 <a name="l00116"></a>00116 <span class="keywordtype">void</span> SaveDatabase(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> dbId, <a class="code" href="classBarry_1_1Builder.html" title="Base class for the builder functor hierarchy.">Builder</a> &amp;builder);
139 <a name="l00117"></a>00117
140 <a name="l00118"></a>00118 <span class="keyword">template</span> &lt;<span class="keyword">class</span> RecordT, <span class="keyword">class</span> StorageT&gt; <span class="keywordtype">void</span> LoadDatabaseByType(StorageT &amp;store);
141 <a name="l00119"></a>00119 <span class="keyword">template</span> &lt;<span class="keyword">class</span> RecordT, <span class="keyword">class</span> StorageT&gt; <span class="keywordtype">void</span> SaveDatabaseByType(StorageT &amp;store);
142 <a name="l00120"></a>00120
143 <a name="l00121"></a>00121 <span class="keyword">template</span> &lt;<span class="keyword">class</span> StorageT&gt; <span class="keywordtype">void</span> LoadDatabaseByName(<span class="keyword">const</span> std::string &amp;name, StorageT &amp;store);
144 <a name="l00122"></a>00122 <span class="keyword">template</span> &lt;<span class="keyword">class</span> StorageT&gt; <span class="keywordtype">void</span> SaveDatabaseByName(<span class="keyword">const</span> std::string &amp;name, StorageT &amp;store);
145 <a name="l00123"></a>00123
146 <a name="l00124"></a>00124 <span class="keyword">template</span> &lt;<span class="keyword">class</span> RecordT&gt; <span class="keywordtype">void</span> AddRecordByType(uint32_t recordId, <span class="keyword">const</span> RecordT &amp;rec);
147 <a name="l00125"></a>00125
148 <a name="l00126"></a>00126 };
149 <a name="l00127"></a>00127
150 <a name="l00128"></a>00128 <span class="comment">// used to hold internal-only state</span>
151 <a name="l00129"></a>00129 <span class="keyword">struct </span>DBLoaderData;
152 <a name="l00130"></a>00130
153 <a name="l00131"></a>00131 <span class="comment">//</span>
154 <a name="l00132"></a>00132 <span class="comment">// DBLoader</span>
155 <a name="l00133"></a>00133 <span class="comment">//</span><span class="comment"></span>
156 <a name="l00134"></a>00134 <span class="comment">/// Database Loader operation class. Encapsulates the load / save</span>
157 <a name="l00135"></a>00135 <span class="comment">/// logic of Desktop::LoadDatabase() and someday Desktop::SaveDatabase()</span>
158 <a name="l00136"></a>00136 <span class="comment">/// in such a way that the loading of individual records is</span>
159 <a name="l00137"></a>00137 <span class="comment">/// controllable by the user, instead of using the parser callback mechanism.</span>
160 <a name="l00138"></a>00138 <span class="comment">///</span>
161 <a name="l00139"></a>00139 <span class="comment">/// This class can be reused to load / save multiple databases, but</span>
162 <a name="l00140"></a>00140 <span class="comment">/// do not call Desktop members while a load operation is in progress.</span>
163 <a name="l00141"></a>00141 <span class="comment">///</span>
164 <a name="l00142"></a><a class="code" href="classBarry_1_1Mode_1_1DBLoader.html">00142</a> <span class="comment"></span><span class="keyword">class </span>BXEXPORT <a class="code" href="classBarry_1_1Mode_1_1DBLoader.html" title="Database Loader operation class.">DBLoader</a>
165 <a name="l00143"></a>00143 {
166 <a name="l00144"></a>00144 <a class="code" href="classBarry_1_1Mode_1_1Desktop.html" title="The main interface class to the device databases.">Desktop</a> &amp;m_desktop;
167 <a name="l00145"></a>00145 Data m_send;
168 <a name="l00146"></a>00146 <span class="keywordtype">bool</span> m_loading;
169 <a name="l00147"></a>00147 std::string m_dbName;
170 <a name="l00148"></a>00148 DBLoaderData *m_loader;
171 <a name="l00149"></a>00149
172 <a name="l00150"></a>00150 <span class="keyword">public</span>:
173 <a name="l00151"></a>00151 <span class="keyword">explicit</span> <a class="code" href="classBarry_1_1Mode_1_1DBLoader.html" title="Database Loader operation class.">DBLoader</a>(<a class="code" href="classBarry_1_1Mode_1_1Desktop.html" title="The main interface class to the device databases.">Desktop</a> &amp;desktop);
174 <a name="l00152"></a>00152 ~<a class="code" href="classBarry_1_1Mode_1_1DBLoader.html" title="Database Loader operation class.">DBLoader</a>();
175 <a name="l00153"></a>00153 <span class="comment"></span>
176 <a name="l00154"></a>00154 <span class="comment"> /// Do not call Desktop members if this is true.</span>
177 <a name="l00155"></a><a class="code" href="classBarry_1_1Mode_1_1DBLoader.html#951ebb66ec127c4ee47ead54ac21dbca">00155</a> <span class="comment"></span> <span class="keywordtype">bool</span> IsBusy()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_loading; }
178 <a name="l00156"></a>00156
179 <a name="l00157"></a>00157 <span class="comment">// caller-controllable load/save operations... if</span>
180 <a name="l00158"></a>00158 <span class="comment">// these functions return true, then new data has</span>
181 <a name="l00159"></a>00159 <span class="comment">// just been loaded into the data object passed to</span>
182 <a name="l00160"></a>00160 <span class="comment">// the constructor</span>
183 <a name="l00161"></a>00161 <span class="comment">//</span>
184 <a name="l00162"></a>00162 <span class="comment">// Both of these functions use a DBData object in order</span>
185 <a name="l00163"></a>00163 <span class="comment">// to pass buffers from application code all the way down</span>
186 <a name="l00164"></a>00164 <span class="comment">// to the socket level, to avoid copies wherever possible.</span>
187 <a name="l00165"></a>00165 <span class="keywordtype">bool</span> StartDBLoad(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> dbId, <a class="code" href="classBarry_1_1DBData.html" title="Database record data class.">DBData</a> &amp;data);
188 <a name="l00166"></a>00166 <span class="keywordtype">bool</span> GetNextRecord(<a class="code" href="classBarry_1_1DBData.html" title="Database record data class.">DBData</a> &amp;data);
189 <a name="l00167"></a>00167 };
190 <a name="l00168"></a>00168
191 <a name="l00169"></a>00169 } <span class="comment">// namespace Barry::Mode</span>
192 <a name="l00170"></a>00170
193 <a name="l00171"></a>00171
194 <a name="l00172"></a>00172
195 <a name="l00173"></a>00173
196 <a name="l00174"></a>00174
197 <a name="l00175"></a>00175 <span class="comment">//</span>
198 <a name="l00176"></a>00176 <span class="comment">// DeviceBuilder</span>
199 <a name="l00177"></a>00177 <span class="comment">//</span><span class="comment"></span>
200 <a name="l00178"></a>00178 <span class="comment">/// Takes a list of database dbId's and behaves like a Builder,</span>
201 <a name="l00179"></a>00179 <span class="comment">/// trying to avoid copies where possible on the device loading end.</span>
202 <a name="l00180"></a>00180 <span class="comment">///</span>
203 <a name="l00181"></a><a class="code" href="classBarry_1_1DeviceBuilder.html">00181</a> <span class="comment"></span><span class="keyword">class </span>BXEXPORT <a class="code" href="classBarry_1_1DeviceBuilder.html" title="Takes a list of database dbId&amp;#39;s and behaves like a Builder, trying to avoid copies...">DeviceBuilder</a> : <span class="keyword">public</span> <a class="code" href="classBarry_1_1Builder.html" title="Base class for the builder functor hierarchy.">Builder</a>
204 <a name="l00182"></a>00182 {
205 <a name="l00183"></a>00183 <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> dbid_type;
206 <a name="l00184"></a>00184
207 <a name="l00185"></a>00185 <span class="keyword">struct </span>DBLabel
208 <a name="l00186"></a>00186 {
209 <a name="l00187"></a>00187 dbid_type id;
210 <a name="l00188"></a>00188 std::string name;
211 <a name="l00189"></a>00189
212 <a name="l00190"></a>00190 DBLabel(dbid_type <span class="keywordtype">id</span>, <span class="keyword">const</span> std::string &amp;name)
213 <a name="l00191"></a>00191 : id(<span class="keywordtype">id</span>)
214 <a name="l00192"></a>00192 , name(name)
215 <a name="l00193"></a>00193 {
216 <a name="l00194"></a>00194 }
217 <a name="l00195"></a>00195 };
218 <a name="l00196"></a>00196
219 <a name="l00197"></a>00197 <span class="keyword">typedef</span> std::vector&lt;DBLabel&gt; list_type;
220 <a name="l00198"></a>00198
221 <a name="l00199"></a>00199 <span class="comment">// list of databases to fetch during build</span>
222 <a name="l00200"></a>00200 list_type m_dbIds;
223 <a name="l00201"></a>00201 list_type::iterator m_current;
224 <a name="l00202"></a>00202 <span class="keywordtype">bool</span> m_started;
225 <a name="l00203"></a>00203
226 <a name="l00204"></a>00204 <a class="code" href="classBarry_1_1Mode_1_1Desktop.html" title="The main interface class to the device databases.">Mode::Desktop</a> &amp;m_desktop;
227 <a name="l00205"></a>00205
228 <a name="l00206"></a>00206 <span class="comment">// loader object to use optimized batch loading while</span>
229 <a name="l00207"></a>00207 <span class="comment">// giving per-record control</span>
230 <a name="l00208"></a>00208 <a class="code" href="classBarry_1_1Mode_1_1DBLoader.html" title="Database Loader operation class.">Mode::DBLoader</a> m_loader;
231 <a name="l00209"></a>00209
232 <a name="l00210"></a>00210 <span class="keyword">public</span>:
233 <a name="l00211"></a>00211 <span class="keyword">explicit</span> <a class="code" href="classBarry_1_1DeviceBuilder.html" title="Takes a list of database dbId&amp;#39;s and behaves like a Builder, trying to avoid copies...">DeviceBuilder</a>(<a class="code" href="classBarry_1_1Mode_1_1Desktop.html" title="The main interface class to the device databases.">Mode::Desktop</a> &amp;desktop);
234 <a name="l00212"></a>00212
235 <a name="l00213"></a>00213 <span class="comment">// searches the dbdb from the desktop to find the dbId,</span>
236 <a name="l00214"></a>00214 <span class="comment">// returns false if not found, and adds it to the list of</span>
237 <a name="l00215"></a>00215 <span class="comment">// databases to retrieve if found</span>
238 <a name="l00216"></a>00216 <span class="keywordtype">bool</span> Add(<span class="keyword">const</span> std::string &amp;dbname);
239 <a name="l00217"></a>00217
240 <a name="l00218"></a>00218 <span class="comment">// adds all databases found in the given dbdb</span>
241 <a name="l00219"></a>00219 <span class="keywordtype">void</span> Add(<span class="keyword">const</span> Barry::DatabaseDatabase &amp;dbdb);
242 <a name="l00220"></a>00220 <span class="comment"></span>
243 <a name="l00221"></a>00221 <span class="comment"> /// sets the internal iterator to the start of the list</span>
244 <a name="l00222"></a>00222 <span class="comment"> /// in order to perform a fresh run</span>
245 <a name="l00223"></a><a class="code" href="classBarry_1_1DeviceBuilder.html#5f0d85ef656fdcdbbc285ef0d783b978">00223</a> <span class="comment"></span> <span class="keywordtype">void</span> Restart() { m_current = m_dbIds.begin(); m_started = <span class="keyword">false</span>; }
246 <a name="l00224"></a>00224
247 <a name="l00225"></a>00225 <span class="comment">//</span>
248 <a name="l00226"></a>00226 <span class="comment">// Builder overrides</span>
249 <a name="l00227"></a>00227 <span class="comment">//</span>
250 <a name="l00228"></a>00228
251 <a name="l00229"></a>00229 <span class="comment">// has both BuildRecord() and Retrieve() functionality,</span>
252 <a name="l00230"></a>00230 <span class="comment">// and uses data all the way down to the socket level copy</span>
253 <a name="l00231"></a>00231 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> BuildRecord(<a class="code" href="classBarry_1_1DBData.html" title="Database record data class.">DBData</a> &amp;data, <span class="keywordtype">size_t</span> &amp;offset,
254 <a name="l00232"></a>00232 <span class="keyword">const</span> <a class="code" href="classBarry_1_1IConverter.html" title="Main charset conversion class, primarily focused on converting between the Blackberry...">IConverter</a> *ic);
255 <a name="l00233"></a>00233 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> FetchRecord(<a class="code" href="classBarry_1_1DBData.html" title="Database record data class.">DBData</a> &amp;data, <span class="keyword">const</span> <a class="code" href="classBarry_1_1IConverter.html" title="Main charset conversion class, primarily focused on converting between the Blackberry...">IConverter</a> *ic);
256 <a name="l00234"></a>00234 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> EndOfFile() <span class="keyword">const</span>;
257 <a name="l00235"></a>00235 };
258 <a name="l00236"></a>00236
259 <a name="l00237"></a>00237
260 <a name="l00238"></a>00238 <span class="comment">//</span>
261 <a name="l00239"></a>00239 <span class="comment">// DeviceParser</span>
262 <a name="l00240"></a>00240 <span class="comment">//</span><span class="comment"></span>
263 <a name="l00241"></a>00241 <span class="comment">/// A parser class that "parses" raw data into a device. Basically this</span>
264 <a name="l00242"></a>00242 <span class="comment">/// is a pipe-oriented way to call SaveDatabase().</span>
265 <a name="l00243"></a>00243 <span class="comment">///</span>
266 <a name="l00244"></a>00244 <span class="comment">/// Note that this is a multi-record parser. For each incoming DBData</span>
267 <a name="l00245"></a>00245 <span class="comment">/// that has a new DBName, a new save will be started. There is no</span>
268 <a name="l00246"></a>00246 <span class="comment">/// way to filter out records, except via the callback, so the easiest</span>
269 <a name="l00247"></a>00247 <span class="comment">/// way to filter out records by database name is on the Builder side.</span>
270 <a name="l00248"></a>00248 <span class="comment">///</span>
271 <a name="l00249"></a><a class="code" href="classBarry_1_1DeviceParser.html">00249</a> <span class="comment"></span><span class="keyword">class </span>BXEXPORT <a class="code" href="classBarry_1_1DeviceParser.html" title="A parser class that &amp;quot;parses&amp;quot; raw data into a device.">DeviceParser</a> : <span class="keyword">public</span> Barry::<a class="code" href="classBarry_1_1Parser.html" title="Base class for the parser hierarchy.">Parser</a>
272 <a name="l00250"></a>00250 {
273 <a name="l00251"></a>00251 <span class="keyword">public</span>:
274 <a name="l00252"></a><a class="code" href="classBarry_1_1DeviceParser.html#8df4da696cf6105b28b6eebc9122ac51">00252</a> <span class="keyword">enum</span> <a class="code" href="classBarry_1_1DeviceParser.html#8df4da696cf6105b28b6eebc9122ac51">WriteMode</a> {<span class="comment"></span>
275 <a name="l00253"></a>00253 <span class="comment"> /// Similar to SaveDatabase(). Erases all records from</span>
276 <a name="l00254"></a>00254 <span class="comment"> /// the existing database and then uploads all new records.</span>
277 <a name="l00255"></a><a class="code" href="classBarry_1_1DeviceParser.html#8df4da696cf6105b28b6eebc9122ac5181058fe19301d5dea85c9487e8f924b6">00255</a> <span class="comment"></span> ERASE_ALL_WRITE_ALL,
278 <a name="l00256"></a>00256 <span class="comment"></span>
279 <a name="l00257"></a>00257 <span class="comment"> /// Adds any new records, and for records with Unique IDs</span>
280 <a name="l00258"></a>00258 <span class="comment"> /// that already exist, overwrite them.</span>
281 <a name="l00259"></a><a class="code" href="classBarry_1_1DeviceParser.html#8df4da696cf6105b28b6eebc9122ac515ce9f83a11bba991dc4ed514a5e6a57f">00259</a> <span class="comment"></span> INDIVIDUAL_OVERWRITE,
282 <a name="l00260"></a>00260 <span class="comment"></span>
283 <a name="l00261"></a>00261 <span class="comment"> /// Adds any new records, but if a record exists with the</span>
284 <a name="l00262"></a>00262 <span class="comment"> /// current Unique ID, skip that record and don't write it</span>
285 <a name="l00263"></a>00263 <span class="comment"> /// to the device.</span>
286 <a name="l00264"></a><a class="code" href="classBarry_1_1DeviceParser.html#8df4da696cf6105b28b6eebc9122ac5102dee5c8cce77a177cba1320f31fd68c">00264</a> <span class="comment"></span> ADD_BUT_NO_OVERWRITE,
287 <a name="l00265"></a>00265 <span class="comment"></span>
288 <a name="l00266"></a>00266 <span class="comment"> /// Adds all incoming records as brand new records, generating</span>
289 <a name="l00267"></a>00267 <span class="comment"> /// a new Unique ID for each one, and leaving any existing</span>
290 <a name="l00268"></a>00268 <span class="comment"> /// records intact.</span>
291 <a name="l00269"></a><a class="code" href="classBarry_1_1DeviceParser.html#8df4da696cf6105b28b6eebc9122ac518e02db6b076e3f449b92397b0d75a368">00269</a> <span class="comment"></span> ADD_WITH_NEW_ID,
292 <a name="l00270"></a>00270 <span class="comment"></span>
293 <a name="l00271"></a>00271 <span class="comment"> /// Calls the virtual function DecideWrite(...) for each</span>
294 <a name="l00272"></a>00272 <span class="comment"> /// record, passing in the data. DecideWrite() returns one</span>
295 <a name="l00273"></a>00273 <span class="comment"> /// of these WriteMode values.</span>
296 <a name="l00274"></a><a class="code" href="classBarry_1_1DeviceParser.html#8df4da696cf6105b28b6eebc9122ac510bf6fb7df3d5e44b1d45ba35b59cf8c8">00274</a> <span class="comment"></span> DECIDE_BY_CALLBACK,
297 <a name="l00275"></a>00275 <span class="comment"></span>
298 <a name="l00276"></a>00276 <span class="comment"> /// Primarily used by DecideWrite(), and causes the current</span>
299 <a name="l00277"></a>00277 <span class="comment"> /// record to not be written.</span>
300 <a name="l00278"></a><a class="code" href="classBarry_1_1DeviceParser.html#8df4da696cf6105b28b6eebc9122ac51273f97e2cc7e79856dae803afccd6618">00278</a> <span class="comment"></span> DROP_RECORD
301 <a name="l00279"></a>00279 };
302 <a name="l00280"></a>00280
303 <a name="l00281"></a>00281 <span class="keyword">private</span>:
304 <a name="l00282"></a>00282 <a class="code" href="classBarry_1_1Mode_1_1Desktop.html" title="The main interface class to the device databases.">Mode::Desktop</a> &amp;m_desktop;
305 <a name="l00283"></a>00283 WriteMode m_mode;
306 <a name="l00284"></a>00284
307 <a name="l00285"></a>00285 std::string m_current_db;
308 <a name="l00286"></a>00286 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> m_current_dbid;
309 <a name="l00287"></a>00287 RecordStateTable m_rstate;
310 <a name="l00288"></a>00288
311 <a name="l00289"></a>00289 <span class="keyword">protected</span>:
312 <a name="l00290"></a>00290 <span class="keywordtype">void</span> StartDB(<span class="keyword">const</span> <a class="code" href="classBarry_1_1DBData.html" title="Database record data class.">DBData</a> &amp;data, <span class="keyword">const</span> <a class="code" href="classBarry_1_1IConverter.html" title="Main charset conversion class, primarily focused on converting between the Blackberry...">IConverter</a> *ic);
313 <a name="l00291"></a>00291 <span class="keywordtype">void</span> WriteNext(<span class="keyword">const</span> <a class="code" href="classBarry_1_1DBData.html" title="Database record data class.">DBData</a> &amp;data, <span class="keyword">const</span> <a class="code" href="classBarry_1_1IConverter.html" title="Main charset conversion class, primarily focused on converting between the Blackberry...">IConverter</a> *ic);
314 <a name="l00292"></a>00292
315 <a name="l00293"></a>00293 <span class="keyword">public</span>:
316 <a name="l00294"></a>00294 <a class="code" href="classBarry_1_1DeviceParser.html" title="A parser class that &amp;quot;parses&amp;quot; raw data into a device.">DeviceParser</a>(<a class="code" href="classBarry_1_1Mode_1_1Desktop.html" title="The main interface class to the device databases.">Mode::Desktop</a> &amp;desktop, WriteMode mode);
317 <a name="l00295"></a>00295 <span class="keyword">virtual</span> ~<a class="code" href="classBarry_1_1DeviceParser.html" title="A parser class that &amp;quot;parses&amp;quot; raw data into a device.">DeviceParser</a>();
318 <a name="l00296"></a>00296 <span class="comment"></span>
319 <a name="l00297"></a>00297 <span class="comment"> /// Callback... you must derive and override this if you use</span>
320 <a name="l00298"></a>00298 <span class="comment"> /// the DECIDE_BY_CALLBACK mode.</span>
321 <a name="l00299"></a>00299 <span class="comment"> /// May be called multiple times per record.</span>
322 <a name="l00300"></a><a class="code" href="classBarry_1_1DeviceParser.html#53dc89b54689532b586fc4940d98fc77">00300</a> <span class="comment"></span> <span class="keyword">virtual</span> <a class="code" href="classBarry_1_1DeviceParser.html#8df4da696cf6105b28b6eebc9122ac51">WriteMode</a> DecideWrite(<span class="keyword">const</span> <a class="code" href="classBarry_1_1DBData.html" title="Database record data class.">DBData</a> &amp;record)<span class="keyword"> const</span>
323 <a name="l00301"></a>00301 <span class="keyword"> </span>{
324 <a name="l00302"></a>00302 <span class="keywordflow">return</span> DROP_RECORD;
325 <a name="l00303"></a>00303 }
326 <a name="l00304"></a>00304 <span class="comment"></span>
327 <a name="l00305"></a>00305 <span class="comment"> /// Parser overrides</span>
328 <a name="l00306"></a>00306 <span class="comment"></span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> ParseRecord(<span class="keyword">const</span> <a class="code" href="classBarry_1_1DBData.html" title="Database record data class.">DBData</a> &amp;data, <span class="keyword">const</span> <a class="code" href="classBarry_1_1IConverter.html" title="Main charset conversion class, primarily focused on converting between the Blackberry...">IConverter</a> *ic);
329 <a name="l00307"></a>00307 };
330 <a name="l00308"></a>00308
331 <a name="l00309"></a>00309
332 <a name="l00310"></a>00310 } <span class="comment">// namespace Barry</span>
333 <a name="l00311"></a>00311
334 <a name="l00312"></a>00312 <span class="preprocessor">#endif</span>
335 <a name="l00313"></a>00313 <span class="preprocessor"></span>
336 </pre></div></div>
337 <hr size="1"><address style="text-align: right;"><small>Generated on Thu Feb 10 16:13:58 2011 for Barry by&nbsp;
338 <a href="http://www.doxygen.org/index.html">
339 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>
340 </body>
341 </html>