1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <!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> </div><div class="line"><a name="l00044"></a><span class="lineno"> 44</span> <span class="keyword">namespace </span><a class="code" href="namespacefv_1_1util.html">fv::util</a>{</div><div class="line"><a name="l00045"></a><span class="lineno"> 45</span> std::string get_type_name(<span class="keyword">const</span> std::type_index& index){</div><div class="line"><a name="l00046"></a><span class="lineno"> 46</span>  std::map<std::type_index, std::string> _map;</div><div class="line"><a name="l00047"></a><span class="lineno"> 47</span>  <span class="comment">// Add to this list as needed :)</span></div><div class="line"><a name="l00048"></a><span class="lineno"> 48</span>  _map[<span class="keyword">typeid</span>(int)]=<span class="stringliteral">"int"</span>;</div><div class="line"><a name="l00049"></a><span class="lineno"> 49</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="l00050"></a><span class="lineno"> 50</span>  _map[<span class="keyword">typeid</span>(float)]=<span class="stringliteral">"float"</span>;</div><div class="line"><a name="l00051"></a><span class="lineno"> 51</span>  _map[<span class="keyword">typeid</span>(double)]=<span class="stringliteral">"double"</span>;</div><div class="line"><a name="l00052"></a><span class="lineno"> 52</span>  _map[<span class="keyword">typeid</span>(std::vector<int>)]=<span class="stringliteral">"std::vector<int>"</span>;</div><div class="line"><a name="l00053"></a><span class="lineno"> 53</span>  _map[<span class="keyword">typeid</span>(std::vector<float>)]=<span class="stringliteral">"std::vector<float>"</span>;</div><div class="line"><a name="l00054"></a><span class="lineno"> 54</span>  _map[<span class="keyword">typeid</span>(std::map<std::string,std::string>)] = <span class="stringliteral">"std::map<std::string,std::string>"</span>;</div><div class="line"><a name="l00055"></a><span class="lineno"> 55</span> </div><div class="line"><a name="l00056"></a><span class="lineno"> 56</span>  <span class="keywordflow">if</span> (_map[index] == <span class="stringliteral">""</span>){</div><div class="line"><a name="l00057"></a><span class="lineno"> 57</span>  CRITICAL(<span class="stringliteral">"Cannot lookup type name of \""</span> << index.name() << <span class="stringliteral">"\""</span>,-1);</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>  <span class="keywordflow">return</span> _map[index];</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> }</div><div class="line"><a name="l00062"></a><span class="lineno"> 62</span> </div><div class="line"><a name="l00063"></a><span class="lineno"> 63</span> <span class="keyword">namespace </span><a class="code" href="namespacefv.html">fv</a>{</div><div class="line"><a name="l00064"></a><span class="lineno"> 64</span> </div><div class="line"><a name="l00069"></a><span class="lineno"><a class="line" href="namespacefv.html#a16a191c4b8935d4c7c5aad79fc4ea97e"> 69</a></span> <span class="keyword">enum</span> <a class="code" href="namespacefv.html#a16a191c4b8935d4c7c5aad79fc4ea97e">SaveOption</a>{</div><div class="line"><a name="l00070"></a><span class="lineno"> 70</span>  PNG = 0,</div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span>  PDF = 1,</div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span>  ROOT = 2</div><div class="line"><a name="l00073"></a><span class="lineno"> 73</span> };</div><div class="line"><a name="l00074"></a><span class="lineno"> 74</span> </div><div class="line"><a name="l00079"></a><span class="lineno"><a class="line" href="classfv_1_1GenContainer.html"> 79</a></span> <span class="keyword">class </span><a class="code" href="classfv_1_1GenContainer.html">GenContainer</a>{</div><div class="line"><a name="l00080"></a><span class="lineno"> 80</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l00081"></a><span class="lineno"> 81</span>  std::string name;</div><div class="line"><a name="l00082"></a><span class="lineno"> 82</span>  std::string desc;</div><div class="line"><a name="l00083"></a><span class="lineno"> 83</span>  std::vector<ObsFilter*> filters;</div><div class="line"><a name="l00084"></a><span class="lineno"> 84</span>  <span class="keyword">protected</span>:</div><div class="line"><a name="l00085"></a><span class="lineno"> 85</span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> _fill() = 0;</div><div class="line"><a name="l00086"></a><span class="lineno"> 86</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00087"></a><span class="lineno"> 87</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="l00088"></a><span class="lineno"> 88</span>  :name(name),desc(desc) { }</div><div class="line"><a name="l00089"></a><span class="lineno"> 89</span> </div><div class="line"><a name="l00090"></a><span class="lineno"> 90</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="l00091"></a><span class="lineno"> 91</span>  :<a class="code" href="classfv_1_1GenContainer.html">GenContainer</a>(name,<span class="stringliteral">"N/A"</span>){ }</div><div class="line"><a name="l00092"></a><span class="lineno"> 92</span> </div><div class="line"><a name="l00093"></a><span class="lineno"> 93</span>  <a class="code" href="classfv_1_1GenContainer.html">GenContainer</a>* add_filter(GenValue* filter){</div><div class="line"><a name="l00094"></a><span class="lineno"> 94</span>  filters.push_back(dynamic_cast<ObsFilter*>(filter));</div><div class="line"><a name="l00095"></a><span class="lineno"> 95</span>  <span class="keywordflow">return</span> <span class="keyword">this</span>;</div><div class="line"><a name="l00096"></a><span class="lineno"> 96</span>  }</div><div class="line"><a name="l00097"></a><span class="lineno"> 97</span> </div><div class="line"><a name="l00098"></a><span class="lineno"> 98</span>  <span class="keywordtype">void</span> fill(){</div><div class="line"><a name="l00099"></a><span class="lineno"> 99</span>  <span class="keywordflow">for</span> (<span class="keyword">auto</span> filter : filters){</div><div class="line"><a name="l00100"></a><span class="lineno"> 100</span>  <span class="keywordflow">if</span> (!filter->get_value()) <span class="keywordflow">return</span>;</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>  _fill();</div><div class="line"><a name="l00103"></a><span class="lineno"> 103</span>  }</div><div class="line"><a name="l00104"></a><span class="lineno"> 104</span> </div><div class="line"><a name="l00105"></a><span class="lineno"> 105</span>  <span class="keywordtype">void</span> set_description(<span class="keyword">const</span> std::string& description){</div><div class="line"><a name="l00106"></a><span class="lineno"> 106</span>  desc = description;</div><div class="line"><a name="l00107"></a><span class="lineno"> 107</span>  }</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">const</span> std::string& get_name(){</div><div class="line"><a name="l00110"></a><span class="lineno"> 110</span>  <span class="keywordflow">return</span> name;</div><div class="line"><a name="l00111"></a><span class="lineno"> 111</span>  }</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>  <span class="keyword">virtual</span> <span class="keyword">const</span> std::string& get_value_name(){</div><div class="line"><a name="l00114"></a><span class="lineno"> 114</span>  <span class="keywordflow">return</span> <span class="stringliteral">"N/A"</span>;</div><div class="line"><a name="l00115"></a><span class="lineno"> 115</span>  }</div><div class="line"><a name="l00116"></a><span class="lineno"> 116</span> </div><div class="line"><a name="l00117"></a><span class="lineno"> 117</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="l00118"></a><span class="lineno"> 118</span> </div><div class="line"><a name="l00119"></a><span class="lineno"> 119</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="l00120"></a><span class="lineno"> 120</span>  save_as(get_name(), option);</div><div class="line"><a name="l00121"></a><span class="lineno"> 121</span>  }</div><div class="line"><a name="l00122"></a><span class="lineno"> 122</span> };</div><div class="line"><a name="l00123"></a><span class="lineno"> 123</span> </div><div class="line"><a name="l00131"></a><span class="lineno"> 131</span> <span class="keyword">template</span> <<span class="keyword">typename</span> H, <span class="keyword">typename</span> V></div><div class="line"><a name="l00132"></a><span class="lineno"><a class="line" href="classfv_1_1Container.html"> 132</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="l00133"></a><span class="lineno"> 133</span>  <span class="keyword">protected</span>:</div><div class="line"><a name="l00134"></a><span class="lineno"> 134</span>  H* container;</div><div class="line"><a name="l00135"></a><span class="lineno"> 135</span>  <a class="code" href="classfv_1_1Value.html">Value<V></a> *value;</div><div class="line"><a name="l00136"></a><span class="lineno"> 136</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00137"></a><span class="lineno"> 137</span>  <a class="code" href="classfv_1_1Container.html">Container</a>(<span class="keyword">const</span> std::string& name, <a class="code" href="classfv_1_1Value.html">Value<V></a>* value)</div><div class="line"><a name="l00138"></a><span class="lineno"> 138</span>  :<a class="code" href="classfv_1_1GenContainer.html">GenContainer</a>(name),</div><div class="line"><a name="l00139"></a><span class="lineno"> 139</span>  container(<span class="keyword">nullptr</span>),</div><div class="line"><a name="l00140"></a><span class="lineno"> 140</span>  value(value){ }</div><div class="line"><a name="l00141"></a><span class="lineno"> 141</span> </div><div class="line"><a name="l00142"></a><span class="lineno"> 142</span>  <span class="keyword">virtual</span> H* get_container(){</div><div class="line"><a name="l00143"></a><span class="lineno"> 143</span>  <span class="keywordflow">return</span> container;</div><div class="line"><a name="l00144"></a><span class="lineno"> 144</span>  }</div><div class="line"><a name="l00145"></a><span class="lineno"> 145</span> </div><div class="line"><a name="l00146"></a><span class="lineno"> 146</span>  <span class="keyword">virtual</span> <span class="keyword">const</span> std::string& get_value_name(){</div><div class="line"><a name="l00147"></a><span class="lineno"> 147</span>  <span class="keywordflow">return</span> value->get_name();</div><div class="line"><a name="l00148"></a><span class="lineno"> 148</span>  }</div><div class="line"><a name="l00149"></a><span class="lineno"> 149</span> };</div><div class="line"><a name="l00150"></a><span class="lineno"> 150</span> </div><div class="line"><a name="l00159"></a><span class="lineno"> 159</span> <span class="keyword">template</span> <<span class="keyword">typename</span> T></div><div class="line"><a name="l00160"></a><span class="lineno"><a class="line" href="classfv_1_1ContainerMean.html"> 160</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,T>{</div><div class="line"><a name="l00161"></a><span class="lineno"> 161</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l00162"></a><span class="lineno"> 162</span>  <span class="keywordtype">int</span> count;</div><div class="line"><a name="l00163"></a><span class="lineno"> 163</span>  T sum;</div><div class="line"><a name="l00164"></a><span class="lineno"> 164</span> </div><div class="line"><a name="l00165"></a><span class="lineno"> 165</span>  <span class="keywordtype">void</span> _fill(){</div><div class="line"><a name="l00166"></a><span class="lineno"> 166</span>  count++;</div><div class="line"><a name="l00167"></a><span class="lineno"> 167</span>  sum += this->value->get_value();</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>  <span class="keyword">public</span>:</div><div class="line"><a name="l00170"></a><span class="lineno"> 170</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="l00171"></a><span class="lineno"> 171</span>  :<a class="code" href="classfv_1_1Container.html">Container<std::vector<T></a>,T>(name, value){</div><div class="line"><a name="l00172"></a><span class="lineno"> 172</span>  this->container = <span class="keyword">new</span> T();</div><div class="line"><a name="l00173"></a><span class="lineno"> 173</span>  }</div><div class="line"><a name="l00174"></a><span class="lineno"> 174</span> </div><div class="line"><a name="l00175"></a><span class="lineno"> 175</span>  T* get_container(){</div><div class="line"><a name="l00176"></a><span class="lineno"> 176</span>  *(this->container) = sum/count;</div><div class="line"><a name="l00177"></a><span class="lineno"> 177</span>  <span class="keywordflow">return</span> (this->container);</div><div class="line"><a name="l00178"></a><span class="lineno"> 178</span>  }</div><div class="line"><a name="l00179"></a><span class="lineno"> 179</span> </div><div class="line"><a name="l00180"></a><span class="lineno"> 180</span> </div><div class="line"><a name="l00181"></a><span class="lineno"> 181</span>  <span class="keywordtype">void</span> save_as(<span class="keyword">const</span> std::string& fname) {</div><div class="line"><a name="l00182"></a><span class="lineno"> 182</span>  WARNING(<span class="stringliteral">"Saving of ContainerMean objects not supported"</span>);</div><div class="line"><a name="l00183"></a><span class="lineno"> 183</span>  }</div><div class="line"><a name="l00184"></a><span class="lineno"> 184</span> </div><div class="line"><a name="l00185"></a><span class="lineno"> 185</span> };</div><div class="line"><a name="l00186"></a><span class="lineno"> 186</span> </div><div class="line"><a name="l00187"></a><span class="lineno"> 187</span> }</div><div class="line"><a name="l00188"></a><span class="lineno"> 188</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> <a href="argparse_8hpp_source.html#l00039">argparse.hpp:39</a></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> <a href="container_8hpp_source.html#l00069">container.hpp:69</a></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> <a href="container_8hpp_source.html#l00160">container.hpp:160</a></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> <a href="api_8hpp_source.html#l00046">api.hpp:46</a></div></div>
- <div class="ttc" id="classfv_1_1Value_html"><div class="ttname"><a href="classfv_1_1Value.html">fv::Value< V ></a></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> <a href="container_8hpp_source.html#l00079">container.hpp:79</a></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> <a href="container_8hpp_source.html#l00132">container.hpp:132</a></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>
|