STIR 6.4.0
InputStreamWithRecordsFromUPENNbin.inl
Go to the documentation of this file.
1
8/*
9 * Copyright (C) 2020-2022 University of Pennsylvania
10 This file is part of STIR.
11
12 SPDX-License-Identifier: Apache-2.0
13
14 See STIR/LICENSE.txt for details
15*/
16
17#include "liboption.h"
18#include "stir/error.h"
19
20START_NAMESPACE_STIR
21
22Succeeded
23InputStreamWithRecordsFromUPENNbin::create_output_file(std::string ofilename)
24{
25 olistCodec = new list::EventCodec(eventFormat);
26
27 if (!ofilename.empty())
28 {
29 const std::ios_base::openmode writeonly = std::ios_base::out | std::ios_base::binary;
30
31 if (!outputListFile.open(ofilename.c_str(), writeonly))
32 {
33 error("Cannot create file " + ofilename);
34 }
35 outputList = &outputListFile;
36 }
37
38 if (!list::encodeHeader(*outputList, listHeader))
39 {
40 error("cannot write header to output list");
41 }
42 out = new list::OutputBuffer(*outputList, eventSize);
43 has_output = true;
44
45 if (keep_delayed == 1 && has_output)
46 {
47 error("You cannot keep delayed events and pass output.");
48 }
49 return Succeeded::yes;
50}
51
52END_NAMESPACE_STIR
Declaration of stir::error()