File: DatasetFactory.h

package info (click to toggle)
ausaxs 1.1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 72,592 kB
  • sloc: cpp: 49,853; ansic: 6,901; python: 730; makefile: 18
file content (31 lines) | stat: -rw-r--r-- 1,317 bytes parent folder | download
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
// SPDX-License-Identifier: LGPL-3.0-or-later
// Author: Kristian Lytje

#pragma once

#include <dataset/Dataset.h>
#include <io/ExistingFile.h>

#include <memory>

namespace ausaxs::factory {
    /**
     * @brief Factory class for creating datasets from files.
     *        The factory will automatically determine the correct constructor to use based on the file extension.
     */
    struct DatasetFactory {
        /**
         * @brief Construct a dataset from a file.
         *        The returned dataset is guaranteed to be of the form: 
         *            [x | y] if @a filename is two-dimensional,
         *            [x | y | yerr] if @a filename is three-dimensional, or
         *            [x | y | yerr | xerr] if @a filename is four-dimensional.
         *        The return type depends on the @a expected_cols parameter. 
         *        If the file contains more columns than @a expected_cols, the extra columns will be ignored, and a warning will be printed.
         * 
         * @param file The path to the file.
         * @param expected_cols The expected number of columns. Any additional columns will be ignored. If 0, all columns will be read.
         */
        static std::unique_ptr<Dataset> construct(const io::ExistingFile& file, unsigned int expected_cols = 0);
    };
}