<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>Wt: Wt::Dbo::Dbo< C > Class Template Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css" /> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="search/search.js"></script> <script type="text/javascript"> $(document).ready(function() { searchBox.OnSelectItem(0); }); </script> </head> <body> <div id="top"><!-- do not remove this div! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">Wt  <span id="projectnumber">3.2.3</span> </div> </td> </tr> </tbody> </table> </div> <!-- Generated by Doxygen 1.7.5.1 --> <script type="text/javascript"> var searchBox = new SearchBox("searchBox", "search",false,'Search'); </script> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li class="current"><a href="annotated.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li> <div id="MSearchBox" class="MSearchBoxInactive"> <span class="left"> <img id="MSearchSelect" src="search/mag_sel.png" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" alt=""/> <input type="text" id="MSearchField" value="Search" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)" onkeyup="searchBox.OnSearchFieldChange(event)"/> </span><span class="right"> <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> </span> </div> </li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="annotated.html"><span>Class List</span></a></li> <li><a href="inherits.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Class Members</span></a></li> </ul> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="namespaceWt.html">Wt</a> </li> <li class="navelem"><a class="el" href="namespaceWt_1_1Dbo.html">Dbo</a> </li> <li class="navelem"><a class="el" href="classWt_1_1Dbo_1_1Dbo.html">Dbo</a> </li> </ul> </div> </div> <div class="header"> <div class="summary"> <a href="#pub-methods">Public Member Functions</a> </div> <div class="headertitle"> <div class="title">Wt::Dbo::Dbo< C > Class Template Reference<div class="ingroups"><a class="el" href="group__dbo.html">Database Objects (Wt::Dbo)</a></div></div> </div> </div> <div class="contents"> <!-- doxytag: class="Wt::Dbo::Dbo" --> <p>A base class for database objects. <a href="classWt_1_1Dbo_1_1Dbo.html#details">More...</a></p> <p><code>#include <Wt/Dbo/Dbo></code></p> <p><a href="classWt_1_1Dbo_1_1Dbo-members.html">List of all members.</a></p> <table class="memberdecls"> <tr><td colspan="2"><h2><a name="pub-methods"></a> Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a8f4aadc99b20bfccbeb446ae0eac312f"></a><!-- doxytag: member="Wt::Dbo::Dbo::Dbo" ref="a8f4aadc99b20bfccbeb446ae0eac312f" args="()" -->  </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Dbo_1_1Dbo.html#a8f4aadc99b20bfccbeb446ae0eac312f">Dbo</a> ()</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Constructor. <br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="structWt_1_1Dbo_1_1dbo__traits.html">dbo_traits</a>< C >::IdType </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Dbo_1_1Dbo.html#ae1f77ea4a99f84e0e7561001c5e6d1fb">id</a> () const </td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Returns the database id. <a href="#ae1f77ea4a99f84e0e7561001c5e6d1fb"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classWt_1_1Dbo_1_1Session.html">Session</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Dbo_1_1Dbo.html#aa8ad4b9425c131f82dc257ed7ec9643e">session</a> () const </td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Returns the session. <a href="#aa8ad4b9425c131f82dc257ed7ec9643e"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Dbo_1_1Dbo.html#a5083ea4d43e159632f147ba056f9d5ea">setDirty</a> ()</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Marks the object as modified. <a href="#a5083ea4d43e159632f147ba056f9d5ea"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classWt_1_1Dbo_1_1ptr.html">ptr</a>< C > </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Dbo_1_1Dbo.html#a0ded5fbbf0eda130a283b1070b6ce6b1">self</a> () const </td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Returns a dbo::ptr to this object. <a href="#a0ded5fbbf0eda130a283b1070b6ce6b1"></a><br/></td></tr> </table> <hr/><a name="details" id="details"></a><h2>Detailed Description</h2> <div class="textblock"><h3>template<class C><br/> class Wt::Dbo::Dbo< C ></h3> <p>A base class for database objects. </p> <p>The only requirement for a class to be be persisted is to have a <code>persist()</code> method. In some cases however, it may be convenient to be able to access database information of an object, such as its database id and its session, from the object itself.</p> <p>By deriving your database class directly or indirectly from this class, you can have access to its <a class="el" href="classWt_1_1Dbo_1_1Dbo.html#ae1f77ea4a99f84e0e7561001c5e6d1fb" title="Returns the database id.">id()</a> and <a class="el" href="classWt_1_1Dbo_1_1Dbo.html#aa8ad4b9425c131f82dc257ed7ec9643e" title="Returns the session.">session()</a>. This will increase the size of your object with one pointer.</p> <p>The following example shows a skeleton for a database object which has access to its own id and session information:</p> <div class="fragment"><pre class="fragment"> <span class="keyword">class </span>Cat : <span class="keyword">public</span> Wt::<a class="code" href="classWt_1_1Dbo_1_1Dbo.html#a8f4aadc99b20bfccbeb446ae0eac312f" title="Constructor.">Dbo</a>::<a class="code" href="classWt_1_1Dbo_1_1Dbo.html#a8f4aadc99b20bfccbeb446ae0eac312f" title="Constructor.">Dbo</a><Cat> { <span class="keyword">public</span>: <span class="keyword">template</span> <<span class="keyword">class</span> Action> <span class="keywordtype">void</span> persist(Action& a) { } }; </pre></div><p>Compare this to the skeleton for a minimum valid database class:</p> <div class="fragment"><pre class="fragment"> <span class="keyword">class </span>Cat { <span class="keyword">public</span>: <span class="keyword">template</span> <<span class="keyword">class</span> Action> <span class="keywordtype">void</span> persist(Action& a) { } }; </pre></div> </div><hr/><h2>Member Function Documentation</h2> <a class="anchor" id="ae1f77ea4a99f84e0e7561001c5e6d1fb"></a><!-- doxytag: member="Wt::Dbo::Dbo::id" ref="ae1f77ea4a99f84e0e7561001c5e6d1fb" args="() const " --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<class C > </div> <table class="memname"> <tr> <td class="memname"><a class="el" href="structWt_1_1Dbo_1_1dbo__traits.html">dbo_traits</a>< C >::IdType <a class="el" href="classWt_1_1Dbo_1_1Dbo.html">Wt::Dbo::Dbo</a>< C >::id </td> <td>(</td> <td class="paramname"></td><td>)</td> <td> const</td> </tr> </table> </div> <div class="memdoc"> <p>Returns the database id. </p> <p>Returns the database id of this object, or <a class="el" href="structWt_1_1Dbo_1_1dbo__traits.html#aae2a13a4ca038f5bad337fbc2d70d37c" title="Returns the sentinel value for a null id.">Wt::Dbo::dbo_traits<C>::invalidId()</a> if the object is associated with a session or not yet stored in the database. </p> </div> </div> <a class="anchor" id="a0ded5fbbf0eda130a283b1070b6ce6b1"></a><!-- doxytag: member="Wt::Dbo::Dbo::self" ref="a0ded5fbbf0eda130a283b1070b6ce6b1" args="() const " --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<class C > </div> <table class="memname"> <tr> <td class="memname"><a class="el" href="classWt_1_1Dbo_1_1ptr.html">ptr</a>< C > <a class="el" href="classWt_1_1Dbo_1_1Dbo.html">Wt::Dbo::Dbo</a>< C >::self </td> <td>(</td> <td class="paramname"></td><td>)</td> <td> const</td> </tr> </table> </div> <div class="memdoc"> <p>Returns a dbo::ptr to this object. </p> <p>The returned pointer points to the current object only if there exists at least one other pointer to the object. Otherwise it returns a <code>null</code> ptr.</p> <p>This means that in practice you should adopt the habit of wrapping a newly created database object directly in a ptr (and perhaps also add it to a session): </p> </div> </div> <a class="anchor" id="aa8ad4b9425c131f82dc257ed7ec9643e"></a><!-- doxytag: member="Wt::Dbo::Dbo::session" ref="aa8ad4b9425c131f82dc257ed7ec9643e" args="() const " --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<class C > </div> <table class="memname"> <tr> <td class="memname"><a class="el" href="classWt_1_1Dbo_1_1Session.html">Session</a> * <a class="el" href="classWt_1_1Dbo_1_1Dbo.html">Wt::Dbo::Dbo</a>< C >::session </td> <td>(</td> <td class="paramname"></td><td>)</td> <td> const</td> </tr> </table> </div> <div class="memdoc"> <p>Returns the session. </p> <p>Returns the session to which this object belongs, or 0 if the object is not associated with a session. </p> </div> </div> <a class="anchor" id="a5083ea4d43e159632f147ba056f9d5ea"></a><!-- doxytag: member="Wt::Dbo::Dbo::setDirty" ref="a5083ea4d43e159632f147ba056f9d5ea" args="()" --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<class C > </div> <table class="memname"> <tr> <td class="memname">void <a class="el" href="classWt_1_1Dbo_1_1Dbo.html">Wt::Dbo::Dbo</a>< C >::setDirty </td> <td>(</td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Marks the object as modified. </p> <p>When accessing a database object using <a class="el" href="classWt_1_1Dbo_1_1ptr.html#ac14d20e52b5cd9eee356488c7416c044" title="Dereference operator, for writing.">ptr.modify()</a>, the object is marked as dirty. Any intermediate query will however flush the current transaction and other changes within a member method will not be recorded.</p> <p>You can call this method to achieve the same as <a class="el" href="classWt_1_1Dbo_1_1ptr.html#ac14d20e52b5cd9eee356488c7416c044" title="Dereference operator, for writing.">ptr.modify()</a> but from within member methods. </p> </div> </div> </div> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Enumerator</a></div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <hr size="1"><address style="text-align: right; margin: 3px"><small> Generated on Thu Nov 1 2012 for <a href="http://www.webtoolkit.eu/wt">the C++ Web Toolkit (Wt)</a> by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" border="0" style="vertical-align: middle; display: inline-block; height: 2em"></a> 1.7.5.1</small></address> </body> </html>