Developer documentation
Version 3.0.3-105-gd3941f44
loader.h
Go to the documentation of this file.
1/* Copyright (c) 2008-2022 the MRtrix3 contributors.
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 *
7 * Covered Software is provided under this License on an "as is"
8 * basis, without warranty of any kind, either expressed, implied, or
9 * statutory, including, without limitation, warranties that the
10 * Covered Software is free of defects, merchantable, fit for a
11 * particular purpose or non-infringing.
12 * See the Mozilla Public License v. 2.0 for more details.
13 *
14 * For more details, see http://www.mrtrix.org/.
15 */
16
17#ifndef __dwi_tractography_editing_loader_h__
18#define __dwi_tractography_editing_loader_h__
19
20
21#include <string>
22
23#include "memory.h"
24#include "types.h"
25
29
30
31namespace MR {
32 namespace DWI {
33 namespace Tractography {
34 namespace Editing {
35
36
37
38
39 class Loader
40 { MEMALIGN(Loader)
41
42 public:
43 Loader (const vector<std::string>& files) :
44 file_list (files),
45 dummy_properties (),
46 reader (new Reader<> (file_list[0], dummy_properties)),
47 file_index (0) { }
48
49 bool operator() (Streamline<>&);
50
51
52 private:
53 const vector<std::string>& file_list;
54 Properties dummy_properties;
55 std::unique_ptr<Reader<> > reader;
56 size_t file_index;
57
58 };
59
60
61
62 bool Loader::operator() (Streamline<>& out)
63 {
64 out.clear();
65
66 if ((*reader) (out))
67 return true;
68
69 while (++file_index != file_list.size()) {
70 dummy_properties.clear();
71 reader.reset (new Reader<> (file_list[file_index], dummy_properties));
72 if ((*reader) (out))
73 return true;
74 }
75
76 return false;
77
78 }
79
80
81
82
83 }
84 }
85 }
86}
87
88#endif
A class to read streamlines data.
Definition: file.h:63
Definition: base.h:24