1 #ifndef NPSTAT_NTUPLERECORDTYPES_HH_
2 #define NPSTAT_NTUPLERECORDTYPES_HH_
17 #include "geners/AbsRecord.hh"
18 #include "geners/AbsReference.hh"
19 #include "geners/binaryIO.hh"
21 #include "npstat/stat/NtupleRecordTypesFwd.hh"
25 template<
class Ntuple>
30 : gs::AbsRecord(obj.classId(),
"npstat::NtupleHeader",
31 obj.name_.c_str(), obj.category_.c_str()),
36 inline bool writeData(std::ostream& os)
const
38 obj_.classId().write(os);
39 obj_.fillBuffer_.classId().write(os);
40 gs::write_pod_vector(os, obj_.columnNames());
41 gs::write_pod(os, obj_.title());
42 const unsigned long rowsPerBuffer = obj_.rowsPerBuffer();
43 gs::write_pod(os, rowsPerBuffer);
44 gs::write_pod(os, obj_.writesByColumn());
55 template<
class Ntuple>
60 : gs::AbsRecord(obj.classId(),
"npstat::NtupleFooter",
61 obj.name_.c_str(), obj.category_.c_str()),
66 inline bool writeData(std::ostream& os)
const
68 unsigned long nrows = obj_.nRows();
69 gs::write_pod(os, nrows);
70 gs::write_pod(os, obj_.headerSaved_);
71 gs::write_pod_vector(os, obj_.idlist_);
72 const unsigned char writeColumnWise = obj_.writesByColumn();
73 gs::write_pod(os, writeColumnWise);
75 gs::write_pod_vector(os, obj_.columnOffsets_);
86 template<
class Ntuple>
91 : gs::AbsRecord(obj.fillBuffer_.classId(),
"npstat::NtupleBuffer",
92 obj.name_.c_str(), obj.category_.c_str()),
97 inline bool writeData(std::ostream& os)
const
98 {
return obj_.fillBuffer_.write(os);}
106 template<
class Ntuple>
113 const unsigned long long itemId)
114 : gs::AbsReference(obj.ar_, obj.bufferClass_,
115 "npstat::NtupleBuffer", itemId), obj_(obj) {}
119 inline void restore(
const unsigned long number,
Buffer* buf)
const
121 const unsigned long long itemId = id(number);
122 if (itemId == 0ULL)
throw std::out_of_range(
123 "In npstat::NtupleBufferReference::restore: "
124 "buffer number out of range");
125 Buffer::restore(obj_.bufferClass_,
126 this->positionInputStream(itemId), buf);
134 template<
class Ntuple>
139 const unsigned long long itemId,
140 const unsigned long column,
141 const long long offset)
142 : gs::AbsReference(obj.ar_, obj.bufferClass_,
143 "npstat::NtupleBuffer", itemId),
144 obj_(obj), offset_(offset), col_(column) {}
148 inline bool fillItems(
typename Ntuple::value_type* buf,
149 const unsigned long lenBuf)
const
151 const unsigned long long itemId = id(0);
157 obj_.bufferClass_, this->positionInputStream(itemId),
158 col_, offset_, buf, lenBuf);
176 gs::AbsArchive& ar,
const gs::ClassId& classId,
177 const char* name,
const char* category)
178 : gs::AbsReference(ar, classId,
"npstat::NtupleFooter",
183 inline bool fillItems(
unsigned long* nrows,
184 unsigned long long* headerId,
185 std::vector<unsigned long long>* idlist,
186 std::vector<long long>* columnOffsets,
187 unsigned long long* recordOffset,
188 const unsigned long number)
const
190 const unsigned long long itemId = id(number);
194 std::istream& s = this->positionInputStream(itemId);
195 *recordOffset = archive().catalogEntry(itemId)->offset();
196 gs::read_pod(s, nrows);
197 gs::read_pod(s, headerId);
198 gs::read_pod_vector(s, idlist);
199 unsigned char writeColumnWise =
false;
200 gs::read_pod(s, &writeColumnWise);
202 gs::read_pod_vector(s, columnOffsets);
204 columnOffsets->clear();
Definition: NtupleBuffer.hh:25
Definition: NtupleRecordTypes.hh:88
Definition: NtupleRecordTypes.hh:108
Definition: NtupleRecordTypes.hh:136
Definition: AbsArrayProjector.hh:14