ATLAS Offline Software
OutputStream.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //
6 // Distributed under the Boost Software License, Version 1.0.
7 // (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9 
10 // Please feel free to contact me (krumnack@iastate.edu) for bug
11 // reports, feature suggestions, praise and complaints.
12 
13 
14 //
15 // includes
16 //
17 
18 #include <EventLoop/OutputStream.h>
19 
20 #include <EventLoop/Algorithm.h>
21 #include <RootCoreUtils/Assert.h>
23 
24 //
25 // method implementations
26 //
27 
29 
30 namespace EL
31 {
32  const std::string OutputStream::optType = "EventLoop_OutputStreamType";
33  const std::string OutputStream::optMergeCmd = "EventLoop_MergeCmd";
34  const std::string OutputStream::optContainerSuffix = "EventLoop_DSSuffix";
35 
36  void OutputStream ::
37  testInvariant () const
38  {
39  RCU_INVARIANT (this);
40  RCU_INVARIANT (!m_label.empty());
41  }
42 
43 
44 
47  : m_label ("out"), m_output (0)
48  {
49  RCU_NEW_INVARIANT (this);
50  }
51 
52 
53 
55  OutputStream (const std::string& val_label)
56  : m_label (val_label), m_output (0)
57  {
58  RCU_REQUIRE_SOFT (!val_label.empty());
59 
60  RCU_NEW_INVARIANT (this);
61  }
62 
63 
64 
66  OutputStream (const std::string& val_label, const std::string& val_type)
67  : m_label (val_label), m_output (0)
68  {
69  RCU_REQUIRE_SOFT (!val_label.empty());
70 
71  m_options.setString(optType, val_type);
72 
73  RCU_NEW_INVARIANT (this);
74  }
75 
76 
77 
79  OutputStream (const OutputStream& that)
80  : TObject (that), m_label (that.m_label),
81  m_options (that.m_options), m_output (0)
82  {
83  RCU_READ_INVARIANT (&that);
84 
85  if (that.m_output != 0)
86  {
87  m_output = dynamic_cast<SH::DiskOutput*>(that.m_output->Clone ());
88  RCU_ASSERT (m_output != 0);
89  }
90  }
91 
92 
93 
96  {
97  RCU_DESTROY_INVARIANT (this);
98 
99  delete m_output;
100  }
101 
102 
103 
106  {
107  // no invariant used
108  that.swap (*this);
109  return *this;
110  }
111 
112 
113 
114  void OutputStream ::
115  swap (OutputStream& that)
116  {
117  RCU_CHANGE_INVARIANT (this);
118  RCU_CHANGE_INVARIANT (&that);
119 
120  m_label.swap (that.m_label);
121  m_options.swap (that.m_options);
122 
123  SH::DiskOutput *tmp_output = m_output;
124  m_output = that.m_output;
125  that.m_output = tmp_output;
126  }
127 
128 
129 
130  const std::string& OutputStream ::
131  label () const
132  {
133  RCU_READ_INVARIANT (this);
134  return m_label;
135  }
136 
137 
138 
139  void OutputStream ::
140  label (const std::string& val_label)
141  {
142  RCU_CHANGE_INVARIANT (this);
143  RCU_REQUIRE_SOFT (!val_label.empty());
144  m_label = val_label;
145  }
146 
147 
148 
150  options ()
151  {
152  RCU_READ_INVARIANT (this);
153  return &m_options;
154  }
155 
156 
157 
159  options () const
160  {
161  RCU_READ_INVARIANT (this);
162  return &m_options;
163  }
164 
165 
166 
168  output() const
169  {
170  RCU_READ_INVARIANT (this);
171  return m_output;
172  }
173 
174 
175 
176  void OutputStream ::
177  output (SH::DiskOutput *output_swallow)
178  {
179  RCU_CHANGE_INVARIANT (this);
180  delete m_output;
181  m_output = output_swallow;
182  }
183 }
EL::OutputStream::m_output
SH::DiskOutput * m_output
Definition: OutputStream.h:135
SH::MetaObject
A class that manages meta-data to be associated with an object.
Definition: MetaObject.h:56
EL::OutputStream
Definition: OutputStream.h:34
EL::OutputStream::m_label
std::string m_label
description: members directly corresponding to accessors
Definition: OutputStream.h:131
OutputStream.h
EL::OutputStream::label
const std::string & label() const
description: the label for this output dataset.
EL::OutputStream::swap
void swap(OutputStream &that)
effects: standard swap function guarantee: no-fail
Assert.h
EL::OutputStream::optMergeCmd
static const std::string optMergeCmd
Definition: OutputStream.h:121
EL::OutputStream::output
const SH::DiskOutput * output() const
description: the output disk, if we don't use the default one.
SH::MetaObject::swap
void swap(MetaObject &that)
standard swap
SH::DiskOutput
a class/interface representing an output location for files
Definition: DiskOutput.h:46
EL::OutputStream::operator=
OutputStream & operator=(OutputStream that)
effects: standard assignment operator guarantee: strong failures: out of memory II
EL::OutputStream::m_options
SH::MetaObject m_options
Definition: OutputStream.h:133
RCU_REQUIRE_SOFT
#define RCU_REQUIRE_SOFT(x)
Definition: Assert.h:153
Algorithm.h
ClassImp
ClassImp(EL::OutputStream) namespace EL
Definition: OutputStream.cxx:28
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition: AlgorithmWorkerData.h:24
EL::OutputStream::testInvariant
void testInvariant() const
effects: test the invariant of this object guarantee: no-fail
RCU_INVARIANT
#define RCU_INVARIANT(x)
Definition: Assert.h:201
INav4MomDumper_jobOptions.OutputStream
OutputStream
Definition: INav4MomDumper_jobOptions.py:20
DiskOutput.h
EL::OutputStream::optType
static const std::string optType
Definition: OutputStream.h:120
EL::OutputStream::OutputStream
OutputStream()
effects: standard default constructor guarantee: strong failures: low level errors I
EL::OutputStream::~OutputStream
~OutputStream()
effects: standard destructor guarantee: no-fail
EL::OutputStream::optContainerSuffix
static const std::string optContainerSuffix
Definition: OutputStream.h:122
RCU_DESTROY_INVARIANT
#define RCU_DESTROY_INVARIANT(x)
Definition: Assert.h:235
RCU_CHANGE_INVARIANT
#define RCU_CHANGE_INVARIANT(x)
Definition: Assert.h:231
EL::OutputStream::options
SH::MetaObject * options()
description: the list of options to the job guarantee: no-fail postcondition: result !...
RCU_ASSERT
#define RCU_ASSERT(x)
Definition: Assert.h:222
RCU_READ_INVARIANT
#define RCU_READ_INVARIANT(x)
Definition: Assert.h:229
RCU_NEW_INVARIANT
#define RCU_NEW_INVARIANT(x)
Definition: Assert.h:233