-
Notifications
You must be signed in to change notification settings - Fork 0
/
LoadAlgorithmHook.html
207 lines (164 loc) · 10.8 KB
/
LoadAlgorithmHook.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<!DOCTYPE html>
<html lang="en" data-content_root="./">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Load Algorithm Hook</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/bootstrap-sphinx.css?v=fadd4351" />
<link rel="stylesheet" type="text/css" href="_static/custom.css?v=77160d70" />
<script src="_static/documentation_options.js?v=a8da1a53"></script>
<script src="_static/doctools.js?v=9bcbadda"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Logging" href="Logging.html" />
<link rel="prev" title="ISIS SANS Reduction Back-end" href="ISISSANSReductionBackend.html" />
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-59110517-1', 'auto');
ga('send', 'pageview');
</script>
</head><body>
<div id="navbar" class="navbar navbar-default ">
<div class="container">
<div class="navbar-header">
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="http://www.mantidproject.org">
</a>
<span class="navbar-text navbar-version pull-left"><b>main</b></span>
</div>
<div class="collapse navbar-collapse nav-collapse">
<ul class="nav navbar-nav">
<li class="divider-vertical"></li>
<li><a href="index.html">Home</a></li>
<li><a href="https://download.mantidproject.org">Download</a></li>
<li><a href="https://docs.mantidproject.org">User Documentation</a></li>
<li><a href="http://www.mantidproject.org/contact">Contact Us</a></li>
</ul>
<form class="navbar-form navbar-right" action="search.html" method="get">
<div class="form-group">
<input type="text" name="q" class="form-control" placeholder="Search" />
</div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<p>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="nav-item nav-item-0"><a href="index.html">Documentation</a> »</li>
<li class="nav-item nav-item-this"><a href="">Load Algorithm Hook</a></li>
</ul>
</div> </p>
</div>
<div class="container">
<div class="row">
<div class="body col-md-12 content" role="main">
<section id="load-algorithm-hook">
<h1>Load Algorithm Hook<a class="headerlink" href="#load-algorithm-hook" title="Link to this heading">¶</a></h1>
<nav class="contents local" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#the-load-algorithm" id="id1">The Load Algorithm</a></p></li>
<li><p><a class="reference internal" href="#descriptors" id="id2">Descriptors</a></p>
<ul>
<li><p><a class="reference internal" href="#hdf" id="id3">HDF</a></p>
<ul>
<li><p><a class="reference internal" href="#hdfdescriptor" id="id4">HDFDescriptor</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#non-hdf" id="id5">Non-HDF</a></p>
<ul>
<li><p><a class="reference internal" href="#filedescriptor" id="id6">FileDescriptor</a></p></li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>
<section id="the-load-algorithm">
<h2><a class="toc-backref" href="#id1" role="doc-backlink">The Load Algorithm</a><a class="headerlink" href="#the-load-algorithm" title="Link to this heading">¶</a></h2>
<p>This page describes how to register a new file loading algorithm so that it can be used through
the general-purpose <a class="reference external" href="https://docs.mantidproject.org/nightly/algorithms/Load-v1.html#algm-load" title="(in MantidProject v6.11)"><span class="xref std std-ref">Load</span></a> algorithm.
The <a class="reference external" href="https://docs.mantidproject.org/nightly/algorithms/Load-v1.html#algm-load" title="(in MantidProject v6.11)"><span class="xref std std-ref">Load</span></a> algorithm is a special algorithm as does very little work itself.
It instead tries to search for the most suitable algorithm for a given file and then uses this
algorithm as a child to load the file. An algorithm wishing to be included as part of the search
must register itself slightly differently and not use <code class="docutils literal notranslate"><span class="pre">DECLARE_ALGORITHM</span></code> macro.</p>
<p>The process of searching for the correct loader needs to be fairly quick as it will be especially
noticeable in the GUI if the process takes a long time. To speed up the process the loaders are
currently split into 2 categories:</p>
<ul class="simple">
<li><p>HDF - Currently only HDF4/5</p></li>
<li><p>NonHDF - The rest</p></li>
</ul>
<p>A quick check is performed, using <code class="docutils literal notranslate"><span class="pre">HDFDescriptor::isHDF()</span></code>, to test whether the file looks like a
<a class="reference external" href="http://www.hdfgroup.org/">HDF</a> file.
If the check succeeds then only the HDF group of loaders are checked, otherwise only the NonHDF group are checked.</p>
</section>
<section id="descriptors">
<h2><a class="toc-backref" href="#id2" role="doc-backlink">Descriptors</a><a class="headerlink" href="#descriptors" title="Link to this heading">¶</a></h2>
<p>To avoid the file being opened/closed by each <code class="docutils literal notranslate"><span class="pre">confidence</span></code> method, a <code class="docutils literal notranslate"><span class="pre">Descriptor</span></code> object is provided.
The actual <code class="docutils literal notranslate"><span class="pre">Descriptor</span></code> class depends on whether the file is a HDF file or not.</p>
<section id="hdf">
<h3><a class="toc-backref" href="#id3" role="doc-backlink">HDF</a><a class="headerlink" href="#hdf" title="Link to this heading">¶</a></h3>
<p>To register an algorithm as a HDF loader use the IHDFLoader interface as a base class for your algorithm.
In your cpp file include the <code class="docutils literal notranslate"><span class="pre">MantidAPI/RegisterFileLoader.h</span></code> header and use the <code class="docutils literal notranslate"><span class="pre">DECLARE_HDF_FILELOADER</span></code>
macro <em>instead</em> of the standard <code class="docutils literal notranslate"><span class="pre">DECLARE_ALGORITHM</span></code> macro.</p>
<p>The interface requires that the method <code class="docutils literal notranslate"><span class="pre">virtual</span> <span class="pre">int</span> <span class="pre">confidence(Kernel::HDFDescriptor</span> <span class="pre">&</span> <span class="pre">descriptor)</span> <span class="pre">const</span> <span class="pre">=</span> <span class="pre">0;</span></code>
be overloaded in the inheriting class. It should use the provided descriptor to check whether the loader is
able to load the wrapped file and return a confidence level as an integer.</p>
<section id="hdfdescriptor">
<h4><a class="toc-backref" href="#id4" role="doc-backlink">HDFDescriptor</a><a class="headerlink" href="#hdfdescriptor" title="Link to this heading">¶</a></h4>
<p>This provides methods to query characteristics of the current file to avoid repeated accessing of the tree.</p>
</section>
</section>
<section id="non-hdf">
<h3><a class="toc-backref" href="#id5" role="doc-backlink">Non-HDF</a><a class="headerlink" href="#non-hdf" title="Link to this heading">¶</a></h3>
<p>To register an algorithm as a Non-HDF loader use the <code class="docutils literal notranslate"><span class="pre">IFileLoader</span></code> interface as a base class for your algorithm.
In your cpp file include the <code class="docutils literal notranslate"><span class="pre">MantidAPI/RegisterFileLoader.h</span></code> header and use the <code class="docutils literal notranslate"><span class="pre">DECLARE_FILELOADER</span></code> macro
<em>instead</em> of the standard <code class="docutils literal notranslate"><span class="pre">DECLARE_ALGORITHM</span></code> macro.</p>
<p>The interface requires that the method <code class="docutils literal notranslate"><span class="pre">virtual</span> <span class="pre">int</span> <span class="pre">confidence(Kernel::FileDescriptor</span> <span class="pre">&</span> <span class="pre">descriptor)</span> <span class="pre">const</span> <span class="pre">=</span> <span class="pre">0;</span></code>
be overloaded in the inheriting class. It should use the provided descriptor to check whether the loader is
able to load the wrapped file and return a confidence level as an integer.</p>
<section id="filedescriptor">
<h4><a class="toc-backref" href="#id6" role="doc-backlink">FileDescriptor</a><a class="headerlink" href="#filedescriptor" title="Link to this heading">¶</a></h4>
<p>This provides methods to query some characteristics of the current file and also access the open stream to avoid
repeated opening/closing of the file. <em>Avoid</em> closing the stream. The code calling the <code class="docutils literal notranslate"><span class="pre">confidence</span></code> method ensures
that the stream is back at the start of the file before checking the next loader so simply use the stream as
necessary and leave it as it is.</p>
</section>
</section>
</section>
</section>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
<ul class="nav navbar-nav" style=" float: right;">
<li>
<a href="ISISSANSReductionBackend.html" title="Previous Chapter: ISIS SANS Reduction Back-end"><span class="glyphicon glyphicon-chevron-left visible-sm"></span><span class="hidden-sm hidden-tablet">« ISIS SANS Red...</span>
</a>
</li>
<li>
<a href="Logging.html" title="Next Chapter: Logging"><span class="glyphicon glyphicon-chevron-right visible-sm"></span><span class="hidden-sm hidden-tablet">Logging »</span>
</a>
</li>
<li><a href="#">Back to top</a></li>
</ul>
<p>
</p>
</div>
</footer>
</body>
</html>