33 if (buf.
null())
return buf;
64 if (!fInfoName.empty())
81 if (Write_Check() !=
do_Ok)
return false;
83 if (Write_Buffer(buf) !=
do_Ok)
return false;
85 return Write_Complete() ==
do_Ok;
94 fFileName(url.GetFullName()),
98 fLoop(url.HasOption(
"loop")),
99 fReduce(url.GetOptionDouble(
"reduce",1.))
107 DOUT3(
"Destroy file input %p",
this);
118 EOUT(
"File interface object already assigned");
127 if (fFileName.find_first_of(
"*?") != std::string::npos) {
128 fFilesList = fIO->fmatch(fFileName.c_str());
134 fFilesList.SetAutoDestroy(
true);
136 return fFilesList.NumChilds() > 0;
143 if (fFileName.empty())
return false;
145 if (!fFilesList.null()) {
146 EOUT(
"Files list already exists");
152 return InitFilesList();
157 fCurrentName.clear();
158 if (fFilesList.NumChilds() == 0) {
159 if (!fLoop || !InitFilesList())
return false;
161 const char* nextname = fFilesList.GetChild(0).GetName();
162 if (nextname!=0) fCurrentName = nextname;
163 fFilesList.GetChild(0).Destroy();
164 return !fCurrentName.empty();
169 cmd.
SetStr(
"InputFileName", fFileName);
170 cmd.
SetStr(
"InputCurrFileName", fCurrentName);
179 fFileName(url.GetFullName()),
203 EOUT(
"File interface object already assigned");
217 std::string mask = ProduceFileName(
"*");
223 for (
unsigned cnt=0; cnt < lst.
NumChilds(); cnt++) {
229 fname.erase(fname.length()-fFileExtens.length(), fFileExtens.length());
230 size_t pos = fname.length() - 1;
231 while ((fname[pos]>=
'0') && (fname[pos] <=
'9')) pos--;
232 fname.erase(0, pos+1);
234 while ((fname.length()>1) && fname[0]==
'0') fname.erase(0, 1);
238 if (number>maxnumber) maxnumber = number;
244 if (fCurrentFileNumber <= maxnumber) {
245 fCurrentFileNumber = maxnumber + 1;
246 ShowInfo(0,
dabc::format(
"start with file number %d", fCurrentFileNumber));
254 std::string fname = fFileName;
256 size_t len = fname.length();
257 size_t pos = fname.rfind(fFileExtens);
259 if (pos == (len-fFileExtens.length())) {
260 fname.insert(pos, suffix);
263 fname += fFileExtens;
272 fCurrentFileName = ProduceFileName(
dabc::format(
"_%04d", fCurrentFileNumber++));
273 fCurrentFileSize = 0;
279 if (fSizeLimitMB > 0)
280 return (fCurrentFileSize + sz)/1024./1024. > fSizeLimitMB;
288 fCurrentFileSize += sz;
289 fTotalFileSize += sz;
291 fTotalNumEvents += numev;
297 std::string info = fCurrentFileName;
298 size_t pos = info.rfind(
"/");
299 if (pos!=std::string::npos) info.erase(0, pos);
305 info.append(
dabc::format(
" (%3.1f %s)", 100./(fSizeLimitMB*1024.*1024.)*fCurrentFileSize,
"%"));
307 if (fTotalNumEvents > 0) {
308 if (fTotalNumEvents<1000000)
311 info.append(
dabc::format(
" %8.3e ev", 1.*fTotalNumEvents));
313 if (fTotalNumBufs<1000000)
316 info.append(
dabc::format(
" %8.3e bufs", 1.*fTotalNumBufs));
324 cmd.
SetStr(
"OutputFileName", fFileName);
325 cmd.
SetDouble(
"OutputFileEvents", fTotalNumEvents);
326 cmd.
SetDouble(
"OutputFileSize", fTotalFileSize);
328 cmd.
SetStr(
"OutputCurrFileName", fCurrentFileName);
329 cmd.
SetDouble(
"OutputCurrFileSize", fCurrentFileSize);
Reference on memory from memory pool.
static Buffer CreateBuffer(BufferSize_t sz)
This static method create independent buffer for any other memory pools Therefore it can be used in s...
Represents command with its arguments.
bool SetStr(const std::string &name, const char *value)
bool SetDouble(const std::string &name, double v)
Interface for implementing any kind of data output.
DataOutput(const dabc::Url &url)
void ShowInfo(int lvl, const std::string &info)
bool WriteBuffer(Buffer &buf)
Write buffer to the output.
virtual bool Write_Init()
This is generic virtual method to initialize output before real work is started.
void SetInfoParName(const std::string &name)
Methods set parameter name, which could be used for debug output.
Defines and implements basic POSIX file interface.
bool CheckBufferForNextFile(unsigned sz)
Return true if new file should be started.
void AccountBuffer(unsigned sz, int numev=0)
std::string ProduceFileName(const std::string &suffix)
virtual bool Write_Init()
This is generic virtual method to initialize output before real work is started.
void SetIO(dabc::FileInterface *io)
virtual std::string ProvideInfo()
Method can be used to get debug info about output.
void ProduceNewFileName()
virtual bool Write_Stat(dabc::Command cmd)
Fill different statistic parameters into provided command.
FileOutput(const dabc::Url &url, const std::string &ext="")
Special info parameter class.
Parameter FindPar(const std::string &parname)
Base class for most of the DABC classes.
bool SetValue(const RecordField &v)
Set parameter value.
void FireModified()
Can be called by user to signal framework that parameter was modified.
Reference on the arbitrary object
void Release()
Releases reference on the object.
const char * GetName() const
Return name of referenced object, if object not assigned, returns "---".
unsigned NumChilds() const
Return number of childs in referenced object.
bool null() const
Returns true if reference contains nullptr.
void Destroy()
Release reference and starts destroyment of referenced object.
Reference GetChild(unsigned n) const
Return reference on child n.
Uniform Resource Locator interpreter.
Reference on dabc::Worker
std::string format(const char *fmt,...)
std::string size_to_str(unsigned long sz, int prec=1, int select=0)
Convert size to string of form like 4.2 GB or 3.7 MB.
bool str_to_int(const char *val, int *res)
Convert string to integer value.