PODIO v00-16-03
An Event-Data-Model Toolkit for High Energy Physics Experiments
Loading...
Searching...
No Matches
podio::ASCIIWriter Class Reference

#include <ASCIIWriter.h>

Public Member Functions

 ASCIIWriter (const std::string &filename, EventStore *store)
 
 ~ASCIIWriter ()
 
 ASCIIWriter (const ASCIIWriter &)=delete
 
ASCIIWriteroperator= (const ASCIIWriter &)=delete
 
template<typename T >
bool registerForWrite (const std::string &name)
 
void writeEvent ()
 
void finish ()
 

Detailed Description

Definition at line 34 of file ASCIIWriter.h.

Constructor & Destructor Documentation

◆ ASCIIWriter() [1/2]

podio::ASCIIWriter::ASCIIWriter ( const std::string &  filename,
EventStore store 
)

Definition at line 8 of file ASCIIWriter.cc.

8 :
9 m_filename(filename), m_store(store), m_file(new std::ofstream) {
10
11 m_file->open(filename, std::ofstream::binary);
12}

◆ ~ASCIIWriter()

podio::ASCIIWriter::~ASCIIWriter ( )

Definition at line 14 of file ASCIIWriter.cc.

14 {
15 delete m_file;
16}

◆ ASCIIWriter() [2/2]

podio::ASCIIWriter::ASCIIWriter ( const ASCIIWriter )
delete

Member Function Documentation

◆ finish()

void podio::ASCIIWriter::finish ( )

Definition at line 35 of file ASCIIWriter.cc.

35 {
36
37 m_file->close();
38}

◆ operator=()

ASCIIWriter & podio::ASCIIWriter::operator= ( const ASCIIWriter )
delete

◆ registerForWrite()

template<typename T >
bool podio::ASCIIWriter::registerForWrite ( const std::string &  name)

Definition at line 64 of file ASCIIWriter.h.

64 {
65 const T* tmp_coll(nullptr);
66 if (!m_store->get(name, tmp_coll)) {
67 std::cerr << "no such collection to write, throw exception." << std::endl;
68 return false;
69 }
70 T* coll = const_cast<T*>(tmp_coll);
71
72 m_storedCollections.emplace_back(coll);
73 m_collectionNames.emplace_back(name);
74 m_map[name] = new ColWriter<T>;
75 return true;
76}
bool get(const std::string &name, const T *&collection)
access a collection by name. returns true if successful
Definition: EventStore.h:143

◆ writeEvent()

void podio::ASCIIWriter::writeEvent ( )

Definition at line 18 of file ASCIIWriter.cc.

18 {
19
20 unsigned i = 0;
21 for (auto& coll : m_storedCollections) {
22 coll->prepareForWrite();
23
24 const std::string& name = m_collectionNames[i++];
25 std::cout << " writing collection " << name << std::endl;
26
27 *m_file << name << " ";
28
29 ColWriterBase* wrt = m_map[name];
30
31 wrt->writeCollection(coll, *m_file);
32 }
33}

The documentation for this class was generated from the following files: