1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
<html xmlns="http://www.w3.org/1999/xhtml">
4
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5
<title>peekabot: src/client/Result.hh Source File</title>
6
<link href="tabs.css" rel="stylesheet" type="text/css"/>
7
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
10
<!-- Generated by Doxygen 1.7.1 -->
11
<div class="navigation" id="top">
14
<li><a href="main.html"><span>Main Page</span></a></li>
15
<li><a href="pages.html"><span>Related Pages</span></a></li>
16
<li><a href="annotated.html"><span>Classes</span></a></li>
17
<li class="current"><a href="files.html"><span>Files</span></a></li>
22
<li><a href="files.html"><span>File List</span></a></li>
26
<div class="headertitle">
27
<h1>src/client/Result.hh</h1> </div>
29
<div class="contents">
30
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
31
<a name="l00002"></a>00002 <span class="comment"> * Copyright Staffan Gimåker 2007-2010.</span>
32
<a name="l00003"></a>00003 <span class="comment"> *</span>
33
<a name="l00004"></a>00004 <span class="comment"> * ---</span>
34
<a name="l00005"></a>00005 <span class="comment"> *</span>
35
<a name="l00006"></a>00006 <span class="comment"> * Distributed under the Boost Software License, Version 1.0.</span>
36
<a name="l00007"></a>00007 <span class="comment"> * (See accompanying file LICENSE_1_0.txt or copy at</span>
37
<a name="l00008"></a>00008 <span class="comment"> * http://www.boost.org/LICENSE_1_0.txt)</span>
38
<a name="l00009"></a>00009 <span class="comment"> */</span>
39
<a name="l00010"></a>00010
40
<a name="l00011"></a>00011 <span class="preprocessor">#ifndef PEEKABOT_CLIENT_RESULT_HH_INCLUDED</span>
41
<a name="l00012"></a>00012 <span class="preprocessor"></span><span class="preprocessor">#define PEEKABOT_CLIENT_RESULT_HH_INCLUDED</span>
42
<a name="l00013"></a>00013 <span class="preprocessor"></span>
43
<a name="l00014"></a>00014
44
<a name="l00015"></a>00015 <span class="preprocessor">#include <stdexcept></span>
45
<a name="l00016"></a>00016 <span class="preprocessor">#include <boost/shared_ptr.hpp></span>
46
<a name="l00017"></a>00017
47
<a name="l00018"></a>00018 <span class="preprocessor">#include "../Any.hh"</span>
48
<a name="l00019"></a>00019 <span class="preprocessor">#include "OperationResult.hh"</span>
49
<a name="l00020"></a>00020 <span class="preprocessor">#include "Status.hh"</span>
50
<a name="l00021"></a>00021
51
<a name="l00022"></a>00022
52
<a name="l00023"></a>00023 <span class="keyword">namespace </span>peekabot
53
<a name="l00024"></a>00024 {
54
<a name="l00025"></a>00025 <span class="keyword">namespace </span>client
55
<a name="l00026"></a>00026 {
56
<a name="l00036"></a>00036 <span class="keyword">template</span><<span class="keyword">class</span> T>
57
<a name="l00037"></a><a class="code" href="classpeekabot_1_1client_1_1Result.html">00037</a> <span class="keyword">class </span><a class="code" href="classpeekabot_1_1client_1_1Result.html" title="Encapsulates a result from an operation, such as getting an object&#39;s color, executed remotely on ...">Result</a> : <span class="keyword">public</span> <a class="code" href="classpeekabot_1_1client_1_1Status.html" title="Provides a thread-safe way for surveying the outcome, henceforth referred to as status, of one operation (action).">Status</a>
58
<a name="l00038"></a>00038 {
59
<a name="l00039"></a>00039 <span class="keyword">public</span>:
60
<a name="l00044"></a><a class="code" href="classpeekabot_1_1client_1_1Result.html#a6f00c89a8bbfd566f848740f9e563604">00044</a> <a class="code" href="classpeekabot_1_1client_1_1Result.html#a6f00c89a8bbfd566f848740f9e563604" title="Create an unused result object, not associated with the result from an operation.">Result</a>() : <a class="code" href="classpeekabot_1_1client_1_1Status.html" title="Provides a thread-safe way for surveying the outcome, henceforth referred to as status, of one operation (action).">Status</a>() {}
61
<a name="l00045"></a>00045
62
<a name="l00046"></a>00046 <span class="keyword">virtual</span> ~<a class="code" href="classpeekabot_1_1client_1_1Result.html" title="Encapsulates a result from an operation, such as getting an object&#39;s color, executed remotely on ...">Result</a>() {}
63
<a name="l00047"></a>00047
64
<a name="l00051"></a><a class="code" href="classpeekabot_1_1client_1_1Result.html#a9adcb7d75abb72039d8c781bc94facce">00051</a> <a class="code" href="classpeekabot_1_1client_1_1Result.html#a6f00c89a8bbfd566f848740f9e563604" title="Create an unused result object, not associated with the result from an operation.">Result</a>(boost::shared_ptr<OperationResult> result)
65
<a name="l00052"></a>00052 : <a class="code" href="classpeekabot_1_1client_1_1Status.html" title="Provides a thread-safe way for surveying the outcome, henceforth referred to as status, of one operation (action).">Status</a>(result),
66
<a name="l00053"></a>00053 m_result(result)
67
<a name="l00054"></a>00054 {
68
<a name="l00055"></a>00055 }
69
<a name="l00056"></a>00056
70
<a name="l00066"></a><a class="code" href="classpeekabot_1_1client_1_1Result.html#a8bc46dd2bc23fc996e375e0cd50fe956">00066</a> <span class="keyword">const</span> T <a class="code" href="classpeekabot_1_1client_1_1Result.html#a8bc46dd2bc23fc996e375e0cd50fe956" title="Return a copy of the result stored in the Result object.">get_result</a>()<span class="keyword"> const</span>
71
<a name="l00067"></a>00067 <span class="keyword"> </span>{
72
<a name="l00068"></a>00068 <span class="keywordflow">try</span>
73
<a name="l00069"></a>00069 {
74
<a name="l00070"></a>00070 <span class="keywordflow">return</span> any_cast<T>(m_result->get_result());
75
<a name="l00071"></a>00071 }
76
<a name="l00072"></a>00072 <span class="keywordflow">catch</span>(BadAnyCast &)
77
<a name="l00073"></a>00073 {
78
<a name="l00074"></a>00074 <span class="keywordflow">throw</span> std::runtime_error(
79
<a name="l00075"></a>00075 <span class="stringliteral">"The specified and actual result types mismatch"</span>);
80
<a name="l00076"></a>00076 }
81
<a name="l00077"></a>00077 }
82
<a name="l00078"></a>00078
83
<a name="l00079"></a>00079 <span class="keyword">private</span>:
84
<a name="l00088"></a>00088 boost::shared_ptr<OperationResult> m_result;
85
<a name="l00089"></a>00089 };
86
<a name="l00090"></a>00090 }
87
<a name="l00091"></a>00091 }
88
<a name="l00092"></a>00092
89
<a name="l00093"></a>00093
90
<a name="l00094"></a>00094 <span class="preprocessor">#endif // PEEKABOT_CLIENT_RESULT_HH_INCLUDED</span>
93
<hr class="footer"/><address class="footer"><small>Generated on Sun Jan 30 2011 for peekabot by
94
<a href="http://www.doxygen.org/index.html">
95
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address>