STIR 6.4.0
ROOTListmodeInputFileFormat.h
1/*
2 Copyright (C) 2015-2016 University of Leeds
3 Copyright (C) 2016 UCL
4 This file is part of STIR.
5
6 SPDX-License-Identifier: Apache-2.0
7
8 See STIR/LICENSE.txt for details
9*/
10#ifndef __stir_IO_ROOTListmodeInputFileFormat_h__
11#define __stir_IO_ROOTListmodeInputFileFormat_h__
12
16#include "stir/error.h"
17#include "stir/utilities.h"
18#include <string>
19
20START_NAMESPACE_STIR
21
27class ROOTListmodeInputFileFormat : public InputFileFormat<ListModeData>
28{
29public:
30 const std::string get_name() const override { return "ROOT"; }
31
32protected:
33 bool actual_can_read(const FileSignature& signature, std::istream& input) const override
34 {
35 return this->is_root_signature(signature.get_signature());
36 }
37
38 bool is_root_signature(const char* const signature) const
39 {
40 // checking for "interfile :"
41 const char* pos_of_colon = strchr(signature, ':');
42 if (pos_of_colon == NULL)
43 return false;
44 std::string keyword(signature, pos_of_colon - signature);
45 return (standardise_interfile_keyword(keyword) == standardise_interfile_keyword("ROOT header"));
46 }
47
48public:
49 unique_ptr<data_type> read_from_file(std::istream& input) const override
50 {
51 error("read_from_file for ROOT listmode data with istream not implemented %s:%s. Sorry", __FILE__, __LINE__);
52 return unique_ptr<data_type>();
53 }
54
55 unique_ptr<data_type> read_from_file(const std::string& filename) const override
56 {
57 return unique_ptr<data_type>(new CListModeDataROOT(filename));
58 }
59};
60
61END_NAMESPACE_STIR
62
63#endif
Declaration of class stir::CListModeDataROOT.
Declaration of class stir::InputFileFormat.
class that reads ROOT files, generated by GATE, as listmode data.
Definition CListModeDataROOT.h:107
A class to read/store the file signature.
Definition FileSignature.h:35
const char * get_signature() const
get access to the signature
Definition FileSignature.h:52
Base-class for file-formats for reading.
Definition InputFileFormat.h:40
The ROOTListmodeInputFileFormat class.
Definition ROOTListmodeInputFileFormat.h:28
unique_ptr< data_type > read_from_file(std::istream &input) const override
read data from a stream
Definition ROOTListmodeInputFileFormat.h:49
unique_ptr< data_type > read_from_file(const std::string &filename) const override
read data from a filename
Definition ROOTListmodeInputFileFormat.h:55
Declaration of stir::error()
void error(const char *const s,...)
Print error with format string a la printf and throw exception.
Definition error.cxx:42
Functions useful for manipulating Interfile keywords.
string standardise_interfile_keyword(const string &keyword)
Put a (Interfile) keyword into a standard form.
Definition interfile_keyword_functions.cxx:28
This file declares various utility functions.