123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <!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"/>
- <meta http-equiv="X-UA-Compatible" content="IE=9"/>
- <meta name="generator" content="Doxygen 1.8.13"/>
- <meta name="viewport" content="width=device-width, initial-scale=1"/>
- <title>TTTT Analysis: /home/caleb/Sources/TTTT/filval/container.hpp Source File</title>
- <link href="tabs.css" rel="stylesheet" type="text/css"/>
- <script type="text/javascript" src="jquery.js"></script>
- <script type="text/javascript" src="dynsections.js"></script>
- <link href="search/search.css" rel="stylesheet" type="text/css"/>
- <script type="text/javascript" src="search/searchdata.js"></script>
- <script type="text/javascript" src="search/search.js"></script>
- <link href="doxygen.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
- <div id="titlearea">
- <table cellspacing="0" cellpadding="0">
- <tbody>
- <tr style="height: 56px;">
- <td id="projectalign" style="padding-left: 0.5em;">
- <div id="projectname">TTTT Analysis
-  <span id="projectnumber">0.1</span>
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <!-- end header part -->
- <!-- Generated by Doxygen 1.8.13 -->
- <script type="text/javascript">
- var searchBox = new SearchBox("searchBox", "search",false,'Search');
- </script>
- <script type="text/javascript" src="menudata.js"></script>
- <script type="text/javascript" src="menu.js"></script>
- <script type="text/javascript">
- $(function() {
- initMenu('',true,false,'search.php','Search');
- $(document).ready(function() { init_search(); });
- });
- </script>
- <div id="main-nav"></div>
- <!-- window showing the filter options -->
- <div id="MSearchSelectWindow"
- onmouseover="return searchBox.OnSearchSelectShow()"
- onmouseout="return searchBox.OnSearchSelectHide()"
- onkeydown="return searchBox.OnSearchSelectKey(event)">
- </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>
- <div id="nav-path" class="navpath">
- <ul>
- <li class="navelem"><a class="el" href="dir_b2e1228fdb7fe80fc606210a4045f658.html">filval</a></li> </ul>
- </div>
- </div><!-- top -->
- <div class="header">
- <div class="headertitle">
- <div class="title">container.hpp</div> </div>
- </div><!--header-->
- <div class="contents">
- <a href="container_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> </div><div class="line"><a name="l00031"></a><span class="lineno"> 31</span> <span class="preprocessor">#ifndef container_hpp</span></div><div class="line"><a name="l00032"></a><span class="lineno"> 32</span> <span class="preprocessor">#define container_hpp</span></div><div class="line"><a name="l00033"></a><span class="lineno"> 33</span> <span class="preprocessor">#include <typeindex></span></div><div class="line"><a name="l00034"></a><span class="lineno"> 34</span> <span class="preprocessor">#include <vector></span></div><div class="line"><a name="l00035"></a><span class="lineno"> 35</span> <span class="preprocessor">#include <map></span></div><div class="line"><a name="l00036"></a><span class="lineno"> 36</span> </div><div class="line"><a name="l00037"></a><span class="lineno"> 37</span> <span class="preprocessor">#include "value.hpp"</span></div><div class="line"><a name="l00038"></a><span class="lineno"> 38</span> <span class="preprocessor">#include "filter.hpp"</span></div><div class="line"><a name="l00039"></a><span class="lineno"> 39</span> </div><div class="line"><a name="l00040"></a><span class="lineno"> 40</span> <span class="keyword">template</span> <span class="keyword">class </span>std::vector<std::vector<float> >;</div><div class="line"><a name="l00041"></a><span class="lineno"> 41</span> <span class="keyword">template</span> <span class="keyword">class </span>std::vector<std::vector<int> >;</div><div class="line"><a name="l00042"></a><span class="lineno"> 42</span> </div><div class="line"><a name="l00043"></a><span class="lineno"> 43</span> <span class="keyword">namespace </span><a class="code" href="namespacefv_1_1util.html">fv::util</a>{</div><div class="line"><a name="l00044"></a><span class="lineno"> 44</span> std::string get_type_name(<span class="keyword">const</span> std::type_index& index){</div><div class="line"><a name="l00045"></a><span class="lineno"> 45</span>  std::map<std::type_index, std::string> _map;</div><div class="line"><a name="l00046"></a><span class="lineno"> 46</span>  <span class="comment">// Add to this list as needed :)</span></div><div class="line"><a name="l00047"></a><span class="lineno"> 47</span>  _map[<span class="keyword">typeid</span>(int)]=<span class="stringliteral">"int"</span>;</div><div class="line"><a name="l00048"></a><span class="lineno"> 48</span>  _map[<span class="keyword">typeid</span>(<span class="keywordtype">unsigned</span> int)]=<span class="stringliteral">"unsigned int"</span>;</div><div class="line"><a name="l00049"></a><span class="lineno"> 49</span>  _map[<span class="keyword">typeid</span>(float)]=<span class="stringliteral">"float"</span>;</div><div class="line"><a name="l00050"></a><span class="lineno"> 50</span>  _map[<span class="keyword">typeid</span>(double)]=<span class="stringliteral">"double"</span>;</div><div class="line"><a name="l00051"></a><span class="lineno"> 51</span>  _map[<span class="keyword">typeid</span>(std::vector<int>)]=<span class="stringliteral">"std::vector<int>"</span>;</div><div class="line"><a name="l00052"></a><span class="lineno"> 52</span>  _map[<span class="keyword">typeid</span>(std::vector<float>)]=<span class="stringliteral">"std::vector<float>"</span>;</div><div class="line"><a name="l00053"></a><span class="lineno"> 53</span> </div><div class="line"><a name="l00054"></a><span class="lineno"> 54</span>  <span class="keywordflow">if</span> (_map[index] == <span class="stringliteral">""</span>){</div><div class="line"><a name="l00055"></a><span class="lineno"> 55</span>  CRITICAL(<span class="stringliteral">"Cannot lookup type name of \""</span> << index.name() << <span class="stringliteral">"\""</span>,-1);</div><div class="line"><a name="l00056"></a><span class="lineno"> 56</span>  }</div><div class="line"><a name="l00057"></a><span class="lineno"> 57</span>  <span class="keywordflow">return</span> _map[index];</div><div class="line"><a name="l00058"></a><span class="lineno"> 58</span> }</div><div class="line"><a name="l00059"></a><span class="lineno"> 59</span> }</div><div class="line"><a name="l00060"></a><span class="lineno"> 60</span> </div><div class="line"><a name="l00061"></a><span class="lineno"> 61</span> <span class="keyword">namespace </span><a class="code" href="namespacefv.html">fv</a>{</div><div class="line"><a name="l00062"></a><span class="lineno"> 62</span> </div><div class="line"><a name="l00067"></a><span class="lineno"><a class="line" href="namespacefv.html#a16a191c4b8935d4c7c5aad79fc4ea97e"> 67</a></span> <span class="keyword">enum</span> <a class="code" href="namespacefv.html#a16a191c4b8935d4c7c5aad79fc4ea97e">SaveOption</a>{</div><div class="line"><a name="l00068"></a><span class="lineno"> 68</span>  PNG = 0,</div><div class="line"><a name="l00069"></a><span class="lineno"> 69</span>  PDF = 1,</div><div class="line"><a name="l00070"></a><span class="lineno"> 70</span>  ROOT = 2</div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span> };</div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span> </div><div class="line"><a name="l00077"></a><span class="lineno"><a class="line" href="classfv_1_1GenContainer.html"> 77</a></span> <span class="keyword">class </span><a class="code" href="classfv_1_1GenContainer.html">GenContainer</a>{</div><div class="line"><a name="l00078"></a><span class="lineno"> 78</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l00079"></a><span class="lineno"> 79</span>  std::string name;</div><div class="line"><a name="l00080"></a><span class="lineno"> 80</span>  std::string desc;</div><div class="line"><a name="l00081"></a><span class="lineno"> 81</span>  std::vector<ObsFilter*> filters;</div><div class="line"><a name="l00082"></a><span class="lineno"> 82</span>  <span class="keyword">protected</span>:</div><div class="line"><a name="l00083"></a><span class="lineno"> 83</span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> _fill() = 0;</div><div class="line"><a name="l00084"></a><span class="lineno"> 84</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00085"></a><span class="lineno"> 85</span>  <a class="code" href="classfv_1_1GenContainer.html">GenContainer</a>(<span class="keyword">const</span> std::string name, <span class="keyword">const</span> std::string& desc)</div><div class="line"><a name="l00086"></a><span class="lineno"> 86</span>  :name(name),desc(desc) { }</div><div class="line"><a name="l00087"></a><span class="lineno"> 87</span> </div><div class="line"><a name="l00088"></a><span class="lineno"> 88</span>  <a class="code" href="classfv_1_1GenContainer.html">GenContainer</a>(<span class="keyword">const</span> std::string name)</div><div class="line"><a name="l00089"></a><span class="lineno"> 89</span>  :<a class="code" href="classfv_1_1GenContainer.html">GenContainer</a>(name,<span class="stringliteral">"N/A"</span>){ }</div><div class="line"><a name="l00090"></a><span class="lineno"> 90</span> </div><div class="line"><a name="l00091"></a><span class="lineno"> 91</span>  <a class="code" href="classfv_1_1GenContainer.html">GenContainer</a>* add_filter(GenValue* filter){</div><div class="line"><a name="l00092"></a><span class="lineno"> 92</span>  filters.push_back(dynamic_cast<ObsFilter*>(filter));</div><div class="line"><a name="l00093"></a><span class="lineno"> 93</span>  <span class="keywordflow">return</span> <span class="keyword">this</span>;</div><div class="line"><a name="l00094"></a><span class="lineno"> 94</span>  }</div><div class="line"><a name="l00095"></a><span class="lineno"> 95</span> </div><div class="line"><a name="l00096"></a><span class="lineno"> 96</span>  <span class="keywordtype">void</span> fill(){</div><div class="line"><a name="l00097"></a><span class="lineno"> 97</span>  <span class="keywordflow">for</span> (<span class="keyword">auto</span> filter : filters){</div><div class="line"><a name="l00098"></a><span class="lineno"> 98</span>  <span class="keywordflow">if</span> (!filter->get_value()) <span class="keywordflow">return</span>;</div><div class="line"><a name="l00099"></a><span class="lineno"> 99</span>  }</div><div class="line"><a name="l00100"></a><span class="lineno"> 100</span>  _fill();</div><div class="line"><a name="l00101"></a><span class="lineno"> 101</span>  }</div><div class="line"><a name="l00102"></a><span class="lineno"> 102</span> </div><div class="line"><a name="l00103"></a><span class="lineno"> 103</span>  <span class="keywordtype">void</span> set_description(<span class="keyword">const</span> std::string& description){</div><div class="line"><a name="l00104"></a><span class="lineno"> 104</span>  desc = description;</div><div class="line"><a name="l00105"></a><span class="lineno"> 105</span>  }</div><div class="line"><a name="l00106"></a><span class="lineno"> 106</span>  <span class="keyword">const</span> std::string& get_name(){</div><div class="line"><a name="l00107"></a><span class="lineno"> 107</span>  <span class="keywordflow">return</span> name;</div><div class="line"><a name="l00108"></a><span class="lineno"> 108</span>  }</div><div class="line"><a name="l00109"></a><span class="lineno"> 109</span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> save_as(<span class="keyword">const</span> std::string& fname, <span class="keyword">const</span> <a class="code" href="namespacefv.html#a16a191c4b8935d4c7c5aad79fc4ea97e">SaveOption</a>& option) = 0;</div><div class="line"><a name="l00110"></a><span class="lineno"> 110</span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> save(<span class="keyword">const</span> <a class="code" href="namespacefv.html#a16a191c4b8935d4c7c5aad79fc4ea97e">SaveOption</a>& option=SaveOption::PNG) {</div><div class="line"><a name="l00111"></a><span class="lineno"> 111</span>  save_as(get_name(), option);</div><div class="line"><a name="l00112"></a><span class="lineno"> 112</span>  }</div><div class="line"><a name="l00113"></a><span class="lineno"> 113</span> };</div><div class="line"><a name="l00114"></a><span class="lineno"> 114</span> </div><div class="line"><a name="l00122"></a><span class="lineno"> 122</span> <span class="keyword">template</span> <<span class="keyword">typename</span> H></div><div class="line"><a name="l00123"></a><span class="lineno"><a class="line" href="classfv_1_1Container.html"> 123</a></span> <span class="keyword">class </span><a class="code" href="classfv_1_1Container.html">Container</a> : <span class="keyword">public</span> <a class="code" href="classfv_1_1GenContainer.html">GenContainer</a>{</div><div class="line"><a name="l00124"></a><span class="lineno"> 124</span>  <span class="keyword">protected</span>:</div><div class="line"><a name="l00125"></a><span class="lineno"> 125</span>  H* container;</div><div class="line"><a name="l00126"></a><span class="lineno"> 126</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00127"></a><span class="lineno"> 127</span>  <a class="code" href="classfv_1_1Container.html">Container</a>(<span class="keyword">const</span> std::string& name, H* container)</div><div class="line"><a name="l00128"></a><span class="lineno"> 128</span>  :<a class="code" href="classfv_1_1GenContainer.html">GenContainer</a>(name),</div><div class="line"><a name="l00129"></a><span class="lineno"> 129</span>  container(container){ }</div><div class="line"><a name="l00130"></a><span class="lineno"> 130</span>  <span class="keyword">virtual</span> H* get_container(){</div><div class="line"><a name="l00131"></a><span class="lineno"> 131</span>  <span class="keywordflow">return</span> container;</div><div class="line"><a name="l00132"></a><span class="lineno"> 132</span>  }</div><div class="line"><a name="l00133"></a><span class="lineno"> 133</span> </div><div class="line"><a name="l00134"></a><span class="lineno"> 134</span> };</div><div class="line"><a name="l00135"></a><span class="lineno"> 135</span> </div><div class="line"><a name="l00144"></a><span class="lineno"> 144</span> <span class="keyword">template</span> <<span class="keyword">typename</span> T></div><div class="line"><a name="l00145"></a><span class="lineno"><a class="line" href="classfv_1_1ContainerMean.html"> 145</a></span> <span class="keyword">class </span><a class="code" href="classfv_1_1ContainerMean.html">ContainerMean</a> : <span class="keyword">public</span> <a class="code" href="classfv_1_1Container.html">Container</a><T>{</div><div class="line"><a name="l00146"></a><span class="lineno"> 146</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l00147"></a><span class="lineno"> 147</span>  <a class="code" href="classfv_1_1Value.html">Value<T></a>* value;</div><div class="line"><a name="l00148"></a><span class="lineno"> 148</span>  <span class="keywordtype">int</span> count;</div><div class="line"><a name="l00149"></a><span class="lineno"> 149</span>  T sum;</div><div class="line"><a name="l00150"></a><span class="lineno"> 150</span> </div><div class="line"><a name="l00151"></a><span class="lineno"> 151</span>  <span class="keywordtype">void</span> _fill(){</div><div class="line"><a name="l00152"></a><span class="lineno"> 152</span>  count++;</div><div class="line"><a name="l00153"></a><span class="lineno"> 153</span>  sum += value-><a class="code" href="classfv_1_1Value.html#a4cc70444ceaf5d7651922adf9b7beeff">get_value</a>();</div><div class="line"><a name="l00154"></a><span class="lineno"> 154</span>  }</div><div class="line"><a name="l00155"></a><span class="lineno"> 155</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00156"></a><span class="lineno"> 156</span>  <a class="code" href="classfv_1_1ContainerMean.html">ContainerMean</a>(<span class="keyword">const</span> std::string& name, <a class="code" href="classfv_1_1Value.html">Value<T></a>* value)</div><div class="line"><a name="l00157"></a><span class="lineno"> 157</span>  :<a class="code" href="classfv_1_1Container.html">Container<std::vector<T></a> >(name, <span class="keyword">nullptr</span>),</div><div class="line"><a name="l00158"></a><span class="lineno"> 158</span>  value(value){</div><div class="line"><a name="l00159"></a><span class="lineno"> 159</span>  this->container = <span class="keyword">new</span> T();</div><div class="line"><a name="l00160"></a><span class="lineno"> 160</span>  }</div><div class="line"><a name="l00161"></a><span class="lineno"> 161</span> </div><div class="line"><a name="l00162"></a><span class="lineno"> 162</span>  T* get_container(){</div><div class="line"><a name="l00163"></a><span class="lineno"> 163</span>  *(this->container) = sum/count;</div><div class="line"><a name="l00164"></a><span class="lineno"> 164</span>  <span class="keywordflow">return</span> (this->container);</div><div class="line"><a name="l00165"></a><span class="lineno"> 165</span>  }</div><div class="line"><a name="l00166"></a><span class="lineno"> 166</span>  <span class="keywordtype">void</span> save_as(<span class="keyword">const</span> std::string& fname) {</div><div class="line"><a name="l00167"></a><span class="lineno"> 167</span>  WARNING(<span class="stringliteral">"Saving of ContainerMean objects not supported"</span>);</div><div class="line"><a name="l00168"></a><span class="lineno"> 168</span>  }</div><div class="line"><a name="l00169"></a><span class="lineno"> 169</span> };</div><div class="line"><a name="l00170"></a><span class="lineno"> 170</span> </div><div class="line"><a name="l00171"></a><span class="lineno"> 171</span> }</div><div class="line"><a name="l00172"></a><span class="lineno"> 172</span> <span class="preprocessor">#endif // container_hpp</span></div><div class="ttc" id="namespacefv_1_1util_html"><div class="ttname"><a href="namespacefv_1_1util.html">fv::util</a></div><div class="ttdef"><b>Definition:</b> argparse.hpp:39</div></div>
- <div class="ttc" id="namespacefv_html_a16a191c4b8935d4c7c5aad79fc4ea97e"><div class="ttname"><a href="namespacefv.html#a16a191c4b8935d4c7c5aad79fc4ea97e">fv::SaveOption</a></div><div class="ttdeci">SaveOption</div><div class="ttdoc">Enumeration of different options that can be used to save Containers. </div><div class="ttdef"><b>Definition:</b> container.hpp:67</div></div>
- <div class="ttc" id="classfv_1_1ContainerMean_html"><div class="ttname"><a href="classfv_1_1ContainerMean.html">fv::ContainerMean</a></div><div class="ttdoc">Calculate the Mean of a Value over a series of observations. </div><div class="ttdef"><b>Definition:</b> container.hpp:145</div></div>
- <div class="ttc" id="namespacefv_html"><div class="ttname"><a href="namespacefv.html">fv</a></div><div class="ttdoc">The namespace containing all filval classes and functions. </div><div class="ttdef"><b>Definition:</b> api.hpp:6</div></div>
- <div class="ttc" id="classfv_1_1Value_html"><div class="ttname"><a href="classfv_1_1Value.html">fv::Value</a></div><div class="ttdoc">A generic value. </div><div class="ttdef"><b>Definition:</b> value.hpp:352</div></div>
- <div class="ttc" id="classfv_1_1GenContainer_html"><div class="ttname"><a href="classfv_1_1GenContainer.html">fv::GenContainer</a></div><div class="ttdoc">Generic, untyped parent class of Container. </div><div class="ttdef"><b>Definition:</b> container.hpp:77</div></div>
- <div class="ttc" id="classfv_1_1Value_html_a4cc70444ceaf5d7651922adf9b7beeff"><div class="ttname"><a href="classfv_1_1Value.html#a4cc70444ceaf5d7651922adf9b7beeff">fv::Value::get_value</a></div><div class="ttdeci">virtual T & get_value()=0</div><div class="ttdoc">Calculate, if necessary, and return the value held by this object. </div></div>
- <div class="ttc" id="classfv_1_1Container_html"><div class="ttname"><a href="classfv_1_1Container.html">fv::Container</a></div><div class="ttdoc">A class that is used to "hold" values. </div><div class="ttdef"><b>Definition:</b> container.hpp:123</div></div>
- </div><!-- fragment --></div><!-- contents -->
- <!-- start footer part -->
- <hr class="footer"/><address class="footer"><small>
- Generated by  <a href="http://www.doxygen.org/index.html">
- <img class="footer" src="doxygen.png" alt="doxygen"/>
- </a> 1.8.13
- </small></address>
- </body>
- </html>
|