Sophie

Sophie

distrib > Fedora > 14 > i386 > by-pkgid > abb2634846290d27f545cecded067e1f > files > 1354

barry-devel-docs-0.17.1-4.fc14.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Barry: m_desktop.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.6 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="classes.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div class="navpath"><a class="el" href="dir_3e14c0bb4416cf979afc3165665fc916.html">src</a>
  </div>
</div>
<div class="contents">
<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>
<a name="l00002"></a>00002 <span class="comment"></span><span class="comment">/// \file       m_desktop.h</span>
<a name="l00003"></a>00003 <span class="comment"></span><span class="comment">///             Mode class for the Desktop mode</span>
<a name="l00004"></a>00004 <span class="comment"></span><span class="comment">///</span>
<a name="l00005"></a>00005 <span class="comment"></span>
<a name="l00006"></a>00006 <span class="comment">/*</span>
<a name="l00007"></a>00007 <span class="comment">    Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/)</span>
<a name="l00008"></a>00008 <span class="comment"></span>
<a name="l00009"></a>00009 <span class="comment">    This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment">    it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment">    the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment">    (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"></span>
<a name="l00014"></a>00014 <span class="comment">    This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment">    but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment">    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</span>
<a name="l00017"></a>00017 <span class="comment"></span>
<a name="l00018"></a>00018 <span class="comment">    See the GNU General Public License in the COPYING file at the</span>
<a name="l00019"></a>00019 <span class="comment">    root directory of this project for more details.</span>
<a name="l00020"></a>00020 <span class="comment">*/</span>
<a name="l00021"></a>00021 
<a name="l00022"></a>00022 <span class="preprocessor">#ifndef __BARRY_M_DESKTOP_H__</span>
<a name="l00023"></a>00023 <span class="preprocessor"></span><span class="preprocessor">#define __BARRY_M_DESKTOP_H__</span>
<a name="l00024"></a>00024 <span class="preprocessor"></span>
<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>
<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>
<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>
<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>
<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>
<a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="parser_8h.html" title="Virtual parser wrapper.">parser.h</a>"</span>
<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>
<a name="l00032"></a>00032 
<a name="l00033"></a>00033 <span class="keyword">namespace </span>Barry {
<a name="l00034"></a>00034 
<a name="l00035"></a>00035 <span class="comment">// forward declarations</span>
<a name="l00036"></a>00036 <span class="keyword">class </span>Parser;
<a name="l00037"></a>00037 <span class="keyword">class </span>IConverter;
<a name="l00038"></a>00038 
<a name="l00039"></a>00039 <span class="keyword">namespace </span>Mode {
<a name="l00040"></a>00040 
<a name="l00041"></a>00041 <span class="keyword">class </span>DBLoader;
<a name="l00042"></a>00042 
<a name="l00043"></a>00043 <span class="comment">//</span>
<a name="l00044"></a>00044 <span class="comment">// Desktop class</span>
<a name="l00045"></a>00045 <span class="comment">//</span><span class="comment"></span>
<a name="l00046"></a>00046 <span class="comment">/// The main interface class to the device databases.</span>
<a name="l00047"></a>00047 <span class="comment">///</span>
<a name="l00048"></a>00048 <span class="comment">/// To use this class, use the following steps:</span>
<a name="l00049"></a>00049 <span class="comment">///</span>
<a name="l00050"></a>00050 <span class="comment">///     - Create a Controller object (see Controller class for more details)</span>
<a name="l00051"></a>00051 <span class="comment">///     - Create this Mode::Desktop object, passing in the Controller</span>
<a name="l00052"></a>00052 <span class="comment">///             object during construction</span>
<a name="l00053"></a>00053 <span class="comment">///     - Call Open() to open database socket and finish constructing.</span>
<a name="l00054"></a>00054 <span class="comment">///     - Call GetDBDB() to get the device's database database</span>
<a name="l00055"></a>00055 <span class="comment">///     - Call GetDBID() to get a database ID by name</span>
<a name="l00056"></a>00056 <span class="comment">///     - Call LoadDatabase() to retrieve and store a database</span>
<a name="l00057"></a>00057 <span class="comment">///</span>
<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>
<a name="l00059"></a>00059 {
<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>;
<a name="l00061"></a>00061 
<a name="l00062"></a>00062 <span class="keyword">public</span>:
<a name="l00063"></a>00063         <span class="keyword">enum</span> CommandType { Unknown, DatabaseAccess };
<a name="l00064"></a>00064 
<a name="l00065"></a>00065 <span class="keyword">private</span>:
<a name="l00066"></a>00066         <span class="comment">// packet data</span>
<a name="l00067"></a>00067         Data m_command, m_response;
<a name="l00068"></a>00068 
<a name="l00069"></a>00069         CommandTable m_commandTable;
<a name="l00070"></a>00070         DatabaseDatabase m_dbdb;
<a name="l00071"></a>00071 
<a name="l00072"></a>00072         <span class="comment">// external objects (optional, can be null)</span>
<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;
<a name="l00074"></a>00074 
<a name="l00075"></a>00075 <span class="keyword">protected</span>:
<a name="l00076"></a>00076         <span class="keywordtype">void</span> LoadCommandTable();
<a name="l00077"></a>00077         <span class="keywordtype">void</span> LoadDBDB();
<a name="l00078"></a>00078 <span class="comment"></span>
<a name="l00079"></a>00079 <span class="comment">        //////////////////////////////////</span>
<a name="l00080"></a>00080 <span class="comment"></span>        <span class="comment">// overrides</span>
<a name="l00081"></a>00081 
<a name="l00082"></a>00082         <span class="keyword">virtual</span> <span class="keywordtype">void</span> OnOpen();
<a name="l00083"></a>00083 
<a name="l00084"></a>00084 <span class="keyword">public</span>:
<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);
<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);
<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>();
<a name="l00088"></a>00088 <span class="comment"></span>
<a name="l00089"></a>00089 <span class="comment">        //////////////////////////////////</span>
<a name="l00090"></a>00090 <span class="comment"></span>        <span class="comment">// meta access</span>
<a name="l00091"></a>00091 <span class="comment"></span>
<a name="l00092"></a>00092 <span class="comment">        /// Returns DatabaseDatabase object for this connection.</span>
<a name="l00093"></a>00093 <span class="comment">        /// Must call Open() first, which loads the DBDB.</span>
<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; }
<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>;
<a name="l00096"></a>00096         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> GetDBCommand(CommandType ct);
<a name="l00097"></a>00097 
<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);
<a name="l00099"></a>00099 <span class="comment"></span>
<a name="l00100"></a>00100 <span class="comment">        //////////////////////////////////</span>
<a name="l00101"></a>00101 <span class="comment"></span>        <span class="comment">// Desktop mode - database specific</span>
<a name="l00102"></a>00102 
<a name="l00103"></a>00103         <span class="comment">// dirty flag related functions, for sync operations</span>
<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);
<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>
<a name="l00106"></a>00106                 <span class="comment">// retrieved from build, and duplicate IDs are allowed,</span>
<a name="l00107"></a>00107                 <span class="comment">// but *not* recommended!</span>
<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);
<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);
<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);
<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);
<a name="l00112"></a>00112 
<a name="l00113"></a>00113         <span class="comment">// pure load/save operations</span>
<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);
<a name="l00115"></a>00115         <span class="keywordtype">void</span> ClearDatabase(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> dbId);
<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);
<a name="l00117"></a>00117 
<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);
<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);
<a name="l00120"></a>00120 
<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);
<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);
<a name="l00123"></a>00123 
<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);
<a name="l00125"></a>00125 
<a name="l00126"></a>00126 };
<a name="l00127"></a>00127 
<a name="l00128"></a>00128 <span class="comment">// used to hold internal-only state</span>
<a name="l00129"></a>00129 <span class="keyword">struct </span>DBLoaderData;
<a name="l00130"></a>00130 
<a name="l00131"></a>00131 <span class="comment">//</span>
<a name="l00132"></a>00132 <span class="comment">// DBLoader</span>
<a name="l00133"></a>00133 <span class="comment">//</span><span class="comment"></span>
<a name="l00134"></a>00134 <span class="comment">/// Database Loader operation class.  Encapsulates the load / save</span>
<a name="l00135"></a>00135 <span class="comment">/// logic of Desktop::LoadDatabase() and someday Desktop::SaveDatabase()</span>
<a name="l00136"></a>00136 <span class="comment">/// in such a way that the loading of individual records is</span>
<a name="l00137"></a>00137 <span class="comment">/// controllable by the user, instead of using the parser callback mechanism.</span>
<a name="l00138"></a>00138 <span class="comment">///</span>
<a name="l00139"></a>00139 <span class="comment">/// This class can be reused to load / save multiple databases, but</span>
<a name="l00140"></a>00140 <span class="comment">/// do not call Desktop members while a load operation is in progress.</span>
<a name="l00141"></a>00141 <span class="comment">///</span>
<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>
<a name="l00143"></a>00143 {
<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;
<a name="l00145"></a>00145         Data m_send;
<a name="l00146"></a>00146         <span class="keywordtype">bool</span> m_loading;
<a name="l00147"></a>00147         std::string m_dbName;
<a name="l00148"></a>00148         DBLoaderData *m_loader;
<a name="l00149"></a>00149 
<a name="l00150"></a>00150 <span class="keyword">public</span>:
<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);
<a name="l00152"></a>00152         ~<a class="code" href="classBarry_1_1Mode_1_1DBLoader.html" title="Database Loader operation class.">DBLoader</a>();
<a name="l00153"></a>00153 <span class="comment"></span>
<a name="l00154"></a>00154 <span class="comment">        /// Do not call Desktop members if this is true.</span>
<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; }
<a name="l00156"></a>00156 
<a name="l00157"></a>00157         <span class="comment">// caller-controllable load/save operations... if</span>
<a name="l00158"></a>00158         <span class="comment">// these functions return true, then new data has</span>
<a name="l00159"></a>00159         <span class="comment">// just been loaded into the data object passed to</span>
<a name="l00160"></a>00160         <span class="comment">// the constructor</span>
<a name="l00161"></a>00161         <span class="comment">//</span>
<a name="l00162"></a>00162         <span class="comment">// Both of these functions use a DBData object in order</span>
<a name="l00163"></a>00163         <span class="comment">// to pass buffers from application code all the way down</span>
<a name="l00164"></a>00164         <span class="comment">// to the socket level, to avoid copies wherever possible.</span>
<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);
<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);
<a name="l00167"></a>00167 };
<a name="l00168"></a>00168 
<a name="l00169"></a>00169 } <span class="comment">// namespace Barry::Mode</span>
<a name="l00170"></a>00170 
<a name="l00171"></a>00171 
<a name="l00172"></a>00172 
<a name="l00173"></a>00173 
<a name="l00174"></a>00174 
<a name="l00175"></a>00175 <span class="comment">//</span>
<a name="l00176"></a>00176 <span class="comment">// DeviceBuilder</span>
<a name="l00177"></a>00177 <span class="comment">//</span><span class="comment"></span>
<a name="l00178"></a>00178 <span class="comment">/// Takes a list of database dbId's and behaves like a Builder,</span>
<a name="l00179"></a>00179 <span class="comment">/// trying to avoid copies where possible on the device loading end.</span>
<a name="l00180"></a>00180 <span class="comment">///</span>
<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>
<a name="l00182"></a>00182 {
<a name="l00183"></a>00183         <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>                            dbid_type;
<a name="l00184"></a>00184 
<a name="l00185"></a>00185         <span class="keyword">struct </span>DBLabel
<a name="l00186"></a>00186         {
<a name="l00187"></a>00187                 dbid_type id;
<a name="l00188"></a>00188                 std::string name;
<a name="l00189"></a>00189 
<a name="l00190"></a>00190                 DBLabel(dbid_type <span class="keywordtype">id</span>, <span class="keyword">const</span> std::string &amp;name)
<a name="l00191"></a>00191                         : id(<span class="keywordtype">id</span>)
<a name="l00192"></a>00192                         , name(name)
<a name="l00193"></a>00193                 {
<a name="l00194"></a>00194                 }
<a name="l00195"></a>00195         };
<a name="l00196"></a>00196 
<a name="l00197"></a>00197         <span class="keyword">typedef</span> std::vector&lt;DBLabel&gt;                    list_type;
<a name="l00198"></a>00198 
<a name="l00199"></a>00199         <span class="comment">// list of databases to fetch during build</span>
<a name="l00200"></a>00200         list_type m_dbIds;
<a name="l00201"></a>00201         list_type::iterator m_current;
<a name="l00202"></a>00202         <span class="keywordtype">bool</span> m_started;
<a name="l00203"></a>00203 
<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;
<a name="l00205"></a>00205 
<a name="l00206"></a>00206         <span class="comment">// loader object to use optimized batch loading while</span>
<a name="l00207"></a>00207         <span class="comment">// giving per-record control</span>
<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;
<a name="l00209"></a>00209 
<a name="l00210"></a>00210 <span class="keyword">public</span>:
<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);
<a name="l00212"></a>00212 
<a name="l00213"></a>00213         <span class="comment">// searches the dbdb from the desktop to find the dbId,</span>
<a name="l00214"></a>00214         <span class="comment">// returns false if not found, and adds it to the list of</span>
<a name="l00215"></a>00215         <span class="comment">// databases to retrieve if found</span>
<a name="l00216"></a>00216         <span class="keywordtype">bool</span> Add(<span class="keyword">const</span> std::string &amp;dbname);
<a name="l00217"></a>00217 
<a name="l00218"></a>00218         <span class="comment">// adds all databases found in the given dbdb</span>
<a name="l00219"></a>00219         <span class="keywordtype">void</span> Add(<span class="keyword">const</span> Barry::DatabaseDatabase &amp;dbdb);
<a name="l00220"></a>00220 <span class="comment"></span>
<a name="l00221"></a>00221 <span class="comment">        /// sets the internal iterator to the start of the list</span>
<a name="l00222"></a>00222 <span class="comment">        /// in order to perform a fresh run</span>
<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>; }
<a name="l00224"></a>00224 
<a name="l00225"></a>00225         <span class="comment">//</span>
<a name="l00226"></a>00226         <span class="comment">// Builder overrides</span>
<a name="l00227"></a>00227         <span class="comment">//</span>
<a name="l00228"></a>00228 
<a name="l00229"></a>00229         <span class="comment">// has both BuildRecord() and Retrieve() functionality,</span>
<a name="l00230"></a>00230         <span class="comment">// and uses data all the way down to the socket level copy</span>
<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,
<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);
<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);
<a name="l00234"></a>00234         <span class="keyword">virtual</span> <span class="keywordtype">bool</span> EndOfFile() <span class="keyword">const</span>;
<a name="l00235"></a>00235 };
<a name="l00236"></a>00236 
<a name="l00237"></a>00237 
<a name="l00238"></a>00238 <span class="comment">//</span>
<a name="l00239"></a>00239 <span class="comment">// DeviceParser</span>
<a name="l00240"></a>00240 <span class="comment">//</span><span class="comment"></span>
<a name="l00241"></a>00241 <span class="comment">/// A parser class that "parses" raw data into a device.  Basically this</span>
<a name="l00242"></a>00242 <span class="comment">/// is a pipe-oriented way to call SaveDatabase().</span>
<a name="l00243"></a>00243 <span class="comment">///</span>
<a name="l00244"></a>00244 <span class="comment">/// Note that this is a multi-record parser.  For each incoming DBData</span>
<a name="l00245"></a>00245 <span class="comment">/// that has a new DBName, a new save will be started.  There is no</span>
<a name="l00246"></a>00246 <span class="comment">/// way to filter out records, except via the callback, so the easiest</span>
<a name="l00247"></a>00247 <span class="comment">/// way to filter out records by database name is on the Builder side.</span>
<a name="l00248"></a>00248 <span class="comment">///</span>
<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>
<a name="l00250"></a>00250 {
<a name="l00251"></a>00251 <span class="keyword">public</span>:
<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>
<a name="l00253"></a>00253 <span class="comment">                /// Similar to SaveDatabase().  Erases all records from</span>
<a name="l00254"></a>00254 <span class="comment">                /// the existing database and then uploads all new records.</span>
<a name="l00255"></a><a class="code" href="classBarry_1_1DeviceParser.html#8df4da696cf6105b28b6eebc9122ac5181058fe19301d5dea85c9487e8f924b6">00255</a> <span class="comment"></span>                ERASE_ALL_WRITE_ALL,
<a name="l00256"></a>00256 <span class="comment"></span>
<a name="l00257"></a>00257 <span class="comment">                /// Adds any new records, and for records with Unique IDs</span>
<a name="l00258"></a>00258 <span class="comment">                /// that already exist, overwrite them.</span>
<a name="l00259"></a><a class="code" href="classBarry_1_1DeviceParser.html#8df4da696cf6105b28b6eebc9122ac515ce9f83a11bba991dc4ed514a5e6a57f">00259</a> <span class="comment"></span>                INDIVIDUAL_OVERWRITE,
<a name="l00260"></a>00260 <span class="comment"></span>
<a name="l00261"></a>00261 <span class="comment">                /// Adds any new records, but if a record exists with the</span>
<a name="l00262"></a>00262 <span class="comment">                /// current Unique ID, skip that record and don't write it</span>
<a name="l00263"></a>00263 <span class="comment">                /// to the device.</span>
<a name="l00264"></a><a class="code" href="classBarry_1_1DeviceParser.html#8df4da696cf6105b28b6eebc9122ac5102dee5c8cce77a177cba1320f31fd68c">00264</a> <span class="comment"></span>                ADD_BUT_NO_OVERWRITE,
<a name="l00265"></a>00265 <span class="comment"></span>
<a name="l00266"></a>00266 <span class="comment">                /// Adds all incoming records as brand new records, generating</span>
<a name="l00267"></a>00267 <span class="comment">                /// a new Unique ID for each one, and leaving any existing</span>
<a name="l00268"></a>00268 <span class="comment">                /// records intact.</span>
<a name="l00269"></a><a class="code" href="classBarry_1_1DeviceParser.html#8df4da696cf6105b28b6eebc9122ac518e02db6b076e3f449b92397b0d75a368">00269</a> <span class="comment"></span>                ADD_WITH_NEW_ID,
<a name="l00270"></a>00270 <span class="comment"></span>
<a name="l00271"></a>00271 <span class="comment">                /// Calls the virtual function DecideWrite(...) for each</span>
<a name="l00272"></a>00272 <span class="comment">                /// record, passing in the data.  DecideWrite() returns one</span>
<a name="l00273"></a>00273 <span class="comment">                /// of these WriteMode values.</span>
<a name="l00274"></a><a class="code" href="classBarry_1_1DeviceParser.html#8df4da696cf6105b28b6eebc9122ac510bf6fb7df3d5e44b1d45ba35b59cf8c8">00274</a> <span class="comment"></span>                DECIDE_BY_CALLBACK,
<a name="l00275"></a>00275 <span class="comment"></span>
<a name="l00276"></a>00276 <span class="comment">                /// Primarily used by DecideWrite(), and causes the current</span>
<a name="l00277"></a>00277 <span class="comment">                /// record to not be written.</span>
<a name="l00278"></a><a class="code" href="classBarry_1_1DeviceParser.html#8df4da696cf6105b28b6eebc9122ac51273f97e2cc7e79856dae803afccd6618">00278</a> <span class="comment"></span>                DROP_RECORD
<a name="l00279"></a>00279         };
<a name="l00280"></a>00280 
<a name="l00281"></a>00281 <span class="keyword">private</span>:
<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;
<a name="l00283"></a>00283         WriteMode m_mode;
<a name="l00284"></a>00284 
<a name="l00285"></a>00285         std::string m_current_db;
<a name="l00286"></a>00286         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> m_current_dbid;
<a name="l00287"></a>00287         RecordStateTable m_rstate;
<a name="l00288"></a>00288 
<a name="l00289"></a>00289 <span class="keyword">protected</span>:
<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);
<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);
<a name="l00292"></a>00292 
<a name="l00293"></a>00293 <span class="keyword">public</span>:
<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);
<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>();
<a name="l00296"></a>00296 <span class="comment"></span>
<a name="l00297"></a>00297 <span class="comment">        /// Callback... you must derive and override this if you use</span>
<a name="l00298"></a>00298 <span class="comment">        /// the DECIDE_BY_CALLBACK mode.</span>
<a name="l00299"></a>00299 <span class="comment">        /// May be called multiple times per record.</span>
<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>
<a name="l00301"></a>00301 <span class="keyword">        </span>{
<a name="l00302"></a>00302                 <span class="keywordflow">return</span> DROP_RECORD;
<a name="l00303"></a>00303         }
<a name="l00304"></a>00304 <span class="comment"></span>
<a name="l00305"></a>00305 <span class="comment">        /// Parser overrides</span>
<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);
<a name="l00307"></a>00307 };
<a name="l00308"></a>00308 
<a name="l00309"></a>00309 
<a name="l00310"></a>00310 } <span class="comment">// namespace Barry</span>
<a name="l00311"></a>00311 
<a name="l00312"></a>00312 <span class="preprocessor">#endif</span>
<a name="l00313"></a>00313 <span class="preprocessor"></span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Tue Mar 1 17:50:15 2011 for Barry by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>
</body>
</html>