HIPO4 C++ Library 4.4.1
Columnar I/O library for CLAS12 physics data
Loading...
Searching...
No Matches
writer.h
Go to the documentation of this file.
1//******************************************************************************
2//* ██╗ ██╗██╗██████╗ ██████╗ ██╗ ██╗ ██████╗ *
3//* ██║ ██║██║██╔══██╗██╔═══██╗ ██║ ██║ ██╔═████╗ *
4//* ███████║██║██████╔╝██║ ██║ ███████║ ██║██╔██║ *
5//* ██╔══██║██║██╔═══╝ ██║ ██║ ╚════██║ ████╔╝██║ *
6//* ██║ ██║██║██║ ╚██████╔╝ ██║██╗╚██████╔╝ *
7//* ╚═╝ ╚═╝╚═╝╚═╝ ╚═════╝ ╚═╝╚═╝ ╚═════╝ *
8//************************ Jefferson National Lab (2017) ***********************
9/*
10 * Copyright (c) 2017. Jefferson Lab (JLab). All rights reserved. Permission
11 * to use, copy, modify, and distribute this software and its documentation
12 * for educational, research, and not-for-profit purposes, without fee and
13 * without a signed licensing agreement.
14 *
15 * IN NO EVENT SHALL JLAB BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL
16 * INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING
17 * OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF JLAB HAS
18 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19 *
20 * JLAB SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE. THE HIPO DATA FORMAT SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF
23 * ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". JLAB HAS NO OBLIGATION TO
24 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
25 *
26 * This software was developed under the United States Government license.
27 * For more information contact author at gavalian@jlab.org
28 * Department of Experimental Nuclear Physics, Jefferson Lab.
29 */
30/*
31 *This sowftware was developed at Jefferson National Laboratory.
32 */
90/*
91 * File: writer.h
92 * Author: gavalian
93 *
94 * Created on April 11, 2017, 2:07 PM
95 */
96
97#ifndef HIPOWRITER_H
98#define HIPOWRITER_H
99
100
101#include <iostream>
102#include <vector>
103#include <fstream>
104#include <stdio.h>
105#include <stdlib.h>
106#include <memory>
107#include <climits>
108#include "recordbuilder.h"
109#include "reader.h"
110
111namespace hipo {
112
127
135class writer {
136
137 private:
138 std::ofstream outputStream;
139 hipo::recordbuilder recordBuilder;
140 hipo::dictionary writerDictionary;
141 std::vector<hipo::recordInfo_t> writerRecordInfo;
142 std::map<std::string,std::string> userConfig;
143
144 std::map<int,hipo::recordbuilder> extendedBuilder;
145
146 void writeIndexTable();
147 int verbose = 0;
148
149 public:
150
152 virtual ~writer(){};
153
154 void addEvent(hipo::event &hevent);
155 void addEvent(std::vector<char> &vec, int size = -1);
156 void addUserConfig(std::string key, std::string value){ userConfig[key] = value;}
157 void addUserConfig(const char *key, const char *value){ userConfig[std::string(key)] = std::string(value);}
158 void writeRecord(recordbuilder &builder);
159 void open(const char *filename);
160 void close();
161 void showSummary();
163 hipo::dictionary &getDictionary(){ return writerDictionary;}
164 void setUserIntegerOne(long userIntOne);
165 void setUserIntegerTwo(long userIntTwo);
166 void flush();
167 void setVerbose(int level){ verbose = level;}
168};
169
170};
171#endif /* HIPOFILE_H */
Collection of schema definitions, typically read from a HIPO file header.
Definition dictionary.h:157
Definition event.h:62
Definition recordbuilder.h:30
READER index class is used to construct entire events sequence from all records, and provides ability...
Definition writer.h:135
void addUserConfig(const char *key, const char *value)
Definition writer.h:157
void open(const char *filename)
Open a File for writing, it includes the dictionary in the file.
Definition writer.cpp:41
void writeRecord(recordbuilder &builder)
Definition writer.cpp:154
void flush()
Definition writer.cpp:242
writer()
Definition writer.h:151
virtual ~writer()
Definition writer.h:152
void setUserIntegerTwo(long userIntTwo)
Definition writer.cpp:235
void setUserIntegerOne(long userIntOne)
Definition writer.cpp:228
void addDictionary(hipo::dictionary &dict)
Definition writer.cpp:119
void addEvent(hipo::event &hevent)
Definition writer.cpp:126
void addUserConfig(std::string key, std::string value)
Definition writer.h:156
void setVerbose(int level)
Definition writer.h:167
void showSummary()
Definition writer.cpp:174
void close()
Definition writer.cpp:212
hipo::dictionary & getDictionary()
Definition writer.h:163
HIPO namespace is used for the classes that read/write files and records.
Definition bank.cpp:45
Definition writer.h:113
int userHeaderLength
Definition writer.h:120
int userIntegerTwo
Definition writer.h:125
int userIntegerOne
Definition writer.h:124
int magicNumber
Definition writer.h:121
long trailerPosition
Definition writer.h:123
int bitInfoVersion
Definition writer.h:119
int indexArrayLength
Definition writer.h:118
int uniqueid
Definition writer.h:114
int recordCount
Definition writer.h:117
long userRegister
Definition writer.h:122
int filenumber
Definition writer.h:115
int headerLength
Definition writer.h:116