HIPO  4.3.0
High Performance Output data format for experimental physics
datastream.cpp
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  * File: datastream.cpp
32  * Author: gavalian
33  *
34  * Created on May 5, 2020, 9:24 PM
35  */
36 
41 #include "datastream.h"
42 
43 #include <cstdlib>
44 
45 namespace hipo {
52 
53  }
54 
55  /*datastreamXrootd::datastreamXrootd(const char *address){
56 
57  }*/
62  #ifdef __XROOTD__
63  if(cli!=NULL) delete cli;
64  #endif
65  }
66 
67 
68  void datastreamXrootd::open(const char *filename){
69 #ifdef __XROOTD__
70  printf("[datastream::xrootd] >>> open : %s\n" + filename);
71  XrdClient *cli = new new XrdClient(filename);
72  cli->Open(open_mode,open_opts);
73 #endif
74  }
75 
77  #ifdef __XROOTD__
78  XrdClientStatInfo stats;
79  cli->Stat(&stats);
80  return stats.size();
81  #endif
82  #ifndef __XROOTD__
83  return 0;
84  #endif
85  }
86 
87  long datastreamXrootd::position(){ return streamPosition;}
88  long datastreamXrootd::position(long pos){ streamPosition = pos; return streamPosition;}
89  int datastreamXrootd::read(char *s, int size){
90  #ifdef __XROOTD__
91  cli->Read(s,streamPosition,size);
92  return size;
93  #endif
94  #ifndef __XROOTD__
95  return 0;
96  #endif
97  }
98 }
~datastreamXrootd()
Destructor; closes the remote connection.
Definition: datastream.cpp:61
void open(const char *filename)
Open a remote file via XRootD.
Definition: datastream.cpp:68
datastreamXrootd()
Default constructor.
Definition: datastream.cpp:51
int read(char *s, int size)
Read bytes from the remote file.
Definition: datastream.cpp:89
Abstract and concrete data stream implementations for file I/O.
Definition: bank.cpp:47