Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JIO::JBinaryFileReader< T, true > Class Template Reference

Template specialisation of JBinaryFileReader for serialisable data types. More...

#include <JBinaryFileReader.hh>

Inheritance diagram for JIO::JBinaryFileReader< T, true >:
JLANG::JAccessibleObjectIterator< T > JLANG::JAccessibleBinaryInputStream JIO::JStreamReader JIO::JReaderObjectIterator< T > JLANG::JObjectIterator< T > JLANG::JAccessible JLANG::JAccessibleInputStream JIO::JReader JLANG::JAbstractObjectIterator< T > JLANG::JThrow< JAccessible > JLANG::JAccessible JLANG::JBinaryInput JLANG::JAbstractObjectStatus JLANG::JObjectIterator< T > JLANG::JThrow< JAccessible >

Public Types

typedef JObjectIterator< T >::pointer_type pointer_type
 

Public Member Functions

 JBinaryFileReader ()
 Default constructor.
 
virtual void open (const char *file_name) override
 Open file.
 
virtual bool is_open () const
 Check is file is open.
 
virtual void close ()
 Close file.
 
virtual bool getStatus () const override
 Status of reader.
 
virtual void clear () override
 Clear status of reader.
 
virtual int read (char *buffer, const int length) override
 Read byte array.
 
JReaderoperator>> (JSerialisable &object)
 Read serialisable data object.
 
JReaderoperator>> (bool &value)
 
JReaderoperator>> (char &value)
 
JReaderoperator>> (unsigned char &value)
 
JReaderoperator>> (short &value)
 
JReaderoperator>> (unsigned short &value)
 
JReaderoperator>> (int &value)
 
JReaderoperator>> (unsigned int &value)
 
JReaderoperator>> (long int &value)
 
JReaderoperator>> (unsigned long int &value)
 
JReaderoperator>> (long long int &value)
 
JReaderoperator>> (unsigned long long int &value)
 
JReaderoperator>> (float &value)
 
JReaderoperator>> (double &value)
 
JReaderoperator>> (long double &value)
 
JReaderoperator>> (JLANG::JObjectID &value)
 
JReaderload (JSerialisable &object)
 Read object.
 
template<class T >
JReaderload (T &object)
 Read object.
 
 operator bool () const
 Type conversion operator.
 
bool operator! () const
 Negated status of this object.
 
virtual bool setObject (T &object) override
 Set object.
 
virtual bool hasNext () override
 Check availability of next element.
 
virtual const pointer_typenext () override
 Get next element.
 
virtual skip_type skip (const skip_type ns)
 Skip items.
 

Static Public Member Functions

static void Throw (const bool option)
 Enable/disable throw option.
 
static int Throw (const JException_t &error, const int value=-1)
 Throw exception or return error.
 

Protected Attributes

std::istream & in
 
object
 object
 
bool has_next
 status
 

Static Protected Attributes

static bool do_throw
 throw option
 

Private Member Functions

bool setObject (T &object, JLANG::JBool< true >)
 
bool setObject (T &object, JLANG::JBool< false >)
 

Private Attributes

pointer_type ps
 

Detailed Description

template<class T>
class JIO::JBinaryFileReader< T, true >

Template specialisation of JBinaryFileReader for serialisable data types.

This class provides for an implementation of the JLANG::JAccessibleObjectIterator interface.

Definition at line 41 of file JBinaryFileReader.hh.

Member Typedef Documentation

◆ pointer_type

template<class T >
JObjectIterator<T>::pointer_type JLANG::JAbstractObjectIterator< T >::pointer_type
inherited

Definition at line 39 of file JAbstractObjectIterator.hh.

Constructor & Destructor Documentation

◆ JBinaryFileReader()

template<class T >
JIO::JBinaryFileReader< T, true >::JBinaryFileReader ( )
inline

Default constructor.

Definition at line 51 of file JBinaryFileReader.hh.

51 :
53 JStreamReader (static_cast<std::istream&> (*this)),
54 JReaderObjectIterator<T>(static_cast<JStreamReader&>(*this))
55 {}
JReaderObjectIterator(JReader &reader)
Constructor.
JStreamReader(std::istream &__in)
Constructor.
Definition JStreamIO.hh:33

Member Function Documentation

◆ open()

virtual void JLANG::JAccessibleBinaryInputStream::open ( const char * file_name)
inlineoverridevirtualinherited

Open file.

Parameters
file_namefile name

Reimplemented from JLANG::JAccessibleInputStream.

Definition at line 52 of file JAccessibleBinaryStream.hh.

53 {
54 std::ifstream::open(file_name, std::ios::binary);
55 }

◆ is_open()

virtual bool JLANG::JAccessibleInputStream::is_open ( ) const
inlinevirtualinherited

Check is file is open.

Returns
true if open; else false

Implements JLANG::JAccessible.

Definition at line 53 of file JAccessibleStream.hh.

54 {
55 return std::ifstream::is_open();
56 }

◆ close()

virtual void JLANG::JAccessibleInputStream::close ( )
inlinevirtualinherited

Close file.

Implements JLANG::JAccessible.

Definition at line 77 of file JAccessibleStream.hh.

78 {
79 std::ifstream::close();
80 }

◆ Throw() [1/2]

static void JLANG::JThrow< JAccessible >::Throw ( const bool option)
inlinestaticinherited

Enable/disable throw option.

Parameters
optiontrue enable; false disable

Definition at line 37 of file JThrow.hh.

38 {
39 do_throw = option;
40 }

◆ Throw() [2/2]

static int JLANG::JThrow< JAccessible >::Throw ( const JException_t & error,
const int value = -1 )
inlinestaticinherited

Throw exception or return error.

Parameters
errorexception
valuereturn code
Returns
return code

Definition at line 51 of file JThrow.hh.

52 {
53 using namespace std;
54
55 if (do_throw) {
56 throw error;
57 }
58
59 cerr << error.what() << endl;
60
61 return value;
62 }

◆ getStatus()

virtual bool JIO::JStreamReader::getStatus ( ) const
inlineoverridevirtualinherited

Status of reader.

Returns
status of this reader

Implements JLANG::JAbstractObjectStatus.

Definition at line 43 of file JStreamIO.hh.

44 {
45 return (bool) in;
46 }
std::istream & in
Definition JStreamIO.hh:73

◆ clear()

virtual void JIO::JStreamReader::clear ( )
inlineoverridevirtualinherited

Clear status of reader.

Reimplemented from JIO::JReader.

Definition at line 52 of file JStreamIO.hh.

53 {
54 in.clear();
55 }

◆ read()

virtual int JIO::JStreamReader::read ( char * buffer,
const int length )
inlineoverridevirtualinherited

Read byte array.

Parameters
bufferpointer to byte array
lengthnumber of bytes
Returns
number of bytes read

Implements JLANG::JBinaryInput.

Definition at line 65 of file JStreamIO.hh.

66 {
67 in.read(buffer, length);
68
69 return in.gcount();
70 }

◆ operator>>() [1/16]

JReader & JIO::JReader::operator>> ( JSerialisable & object)
inlineinherited

Read serialisable data object.

Parameters
objectserialisable data object
Returns
JReader

Definition at line 81 of file JSerialisable.hh.

82 {
83 return object.read(*this);
84 }

◆ operator>>() [2/16]

JReader & JIO::JReader::operator>> ( bool & value)
inlineinherited

Definition at line 87 of file JSerialisable.hh.

87{ read((char*) &value, sizeof(bool)); return *this; }
virtual int read(char *buffer, const int length)=0
Read byte array.

◆ operator>>() [3/16]

JReader & JIO::JReader::operator>> ( char & value)
inlineinherited

Definition at line 88 of file JSerialisable.hh.

88{ read((char*) &value, sizeof(char)); return *this; }

◆ operator>>() [4/16]

JReader & JIO::JReader::operator>> ( unsigned char & value)
inlineinherited

Definition at line 89 of file JSerialisable.hh.

89{ read((char*) &value, sizeof(unsigned char)); return *this; }

◆ operator>>() [5/16]

JReader & JIO::JReader::operator>> ( short & value)
inlineinherited

Definition at line 90 of file JSerialisable.hh.

90{ read((char*) &value, sizeof(short)); return *this; }

◆ operator>>() [6/16]

JReader & JIO::JReader::operator>> ( unsigned short & value)
inlineinherited

Definition at line 91 of file JSerialisable.hh.

91{ read((char*) &value, sizeof(unsigned short)); return *this; }

◆ operator>>() [7/16]

JReader & JIO::JReader::operator>> ( int & value)
inlineinherited

Definition at line 92 of file JSerialisable.hh.

92{ read((char*) &value, sizeof(int)); return *this; }

◆ operator>>() [8/16]

JReader & JIO::JReader::operator>> ( unsigned int & value)
inlineinherited

Definition at line 93 of file JSerialisable.hh.

93{ read((char*) &value, sizeof(unsigned int)); return *this; }

◆ operator>>() [9/16]

JReader & JIO::JReader::operator>> ( long int & value)
inlineinherited

Definition at line 94 of file JSerialisable.hh.

94{ read((char*) &value, sizeof(long int)); return *this; }

◆ operator>>() [10/16]

JReader & JIO::JReader::operator>> ( unsigned long int & value)
inlineinherited

Definition at line 95 of file JSerialisable.hh.

95{ read((char*) &value, sizeof(unsigned long int)); return *this; }

◆ operator>>() [11/16]

JReader & JIO::JReader::operator>> ( long long int & value)
inlineinherited

Definition at line 96 of file JSerialisable.hh.

96{ read((char*) &value, sizeof(long long int)); return *this; }

◆ operator>>() [12/16]

JReader & JIO::JReader::operator>> ( unsigned long long int & value)
inlineinherited

Definition at line 97 of file JSerialisable.hh.

97{ read((char*) &value, sizeof(unsigned long long int)); return *this; }

◆ operator>>() [13/16]

JReader & JIO::JReader::operator>> ( float & value)
inlineinherited

Definition at line 98 of file JSerialisable.hh.

98{ read((char*) &value, sizeof(float)); return *this; }

◆ operator>>() [14/16]

JReader & JIO::JReader::operator>> ( double & value)
inlineinherited

Definition at line 99 of file JSerialisable.hh.

99{ read((char*) &value, sizeof(double)); return *this; }

◆ operator>>() [15/16]

JReader & JIO::JReader::operator>> ( long double & value)
inlineinherited

Definition at line 100 of file JSerialisable.hh.

100{ read((char*) &value, sizeof(long double)); return *this; }

◆ operator>>() [16/16]

JReader & JIO::JReader::operator>> ( JLANG::JObjectID & value)
inlineinherited

Definition at line 101 of file JSerialisable.hh.

101{ return (*this) >> value.getID(); }
int getID() const
Get identifier.
Definition JObjectID.hh:50

◆ load() [1/2]

JReader & JIO::JReader::load ( JSerialisable & object)
inlineinherited

Read object.

Parameters
objectobject
Returns
this reader

Definition at line 110 of file JSerialisable.hh.

111 {
112 return object.read(*this);
113 }

◆ load() [2/2]

template<class T >
JReader & JIO::JReader::load ( T & object)
inlineinherited

Read object.

Parameters
objectobject
Returns
this reader

Definition at line 123 of file JSerialisable.hh.

124 {
125 return *this >> object;
126 }

◆ operator bool()

JLANG::JAbstractObjectStatus::operator bool ( ) const
inlineinherited

Type conversion operator.

Returns
status of this object

Definition at line 33 of file JAbstractObjectStatus.hh.

34 {
35 return this->getStatus();
36 }
virtual bool getStatus() const =0
Get status of object.

◆ operator!()

bool JLANG::JAbstractObjectStatus::operator! ( ) const
inlineinherited

Negated status of this object.

Returns
negated status of this object

Definition at line 44 of file JAbstractObjectStatus.hh.

45 {
46 return !(this->getStatus());
47 }

◆ setObject() [1/3]

template<class T >
virtual bool JIO::JReaderObjectIterator< T >::setObject ( T & object)
inlineoverridevirtualinherited

Set object.

Parameters
objectreference to object to be set
Returns
true if set; else false

Implements JLANG::JAbstractObjectIterator< T >.

Reimplemented in JSUPPORT::JDAQFileReader< T, true >.

Definition at line 48 of file JReaderObjectIterator.hh.

49 {
51 }
virtual bool setObject(T &object) override
Set object.
Auxiliary template class for type bool.
Definition JBool.hh:21
Template class test for polymorphism.

◆ setObject() [2/3]

template<class T >
bool JIO::JReaderObjectIterator< T >::setObject ( T & object,
JLANG::JBool< true >  )
inlineprivateinherited

Definition at line 54 of file JReaderObjectIterator.hh.

54{ return (bool) object.read(in); }

◆ setObject() [3/3]

template<class T >
bool JIO::JReaderObjectIterator< T >::setObject ( T & object,
JLANG::JBool< false >  )
inlineprivateinherited

Definition at line 55 of file JReaderObjectIterator.hh.

55{ return (bool) (in >> object); }

◆ hasNext()

template<class T >
virtual bool JLANG::JAbstractObjectIterator< T >::hasNext ( )
inlineoverridevirtualinherited

Check availability of next element.

Returns
true if the iteration has more elements; else false

Implements JLANG::JObjectIterator< T >.

Definition at line 56 of file JAbstractObjectIterator.hh.

57 {
58 if (!has_next) {
59 has_next = this->setObject(object);
60 }
61
62 return has_next;
63 }
virtual bool setObject(T &object)=0
Set object.

◆ next()

template<class T >
virtual const pointer_type & JLANG::JAbstractObjectIterator< T >::next ( )
inlineoverridevirtualinherited

Get next element.

Returns
pointer to element

Implements JLANG::JObjectIterator< T >.

Definition at line 71 of file JAbstractObjectIterator.hh.

72 {
73 if (has_next)
74 ps.reset(&this->object);
75 else
76 ps.reset(NULL);
77
78 has_next = false;
79
80 return ps;
81 }
virtual void reset() override
Reset pointer.
Definition JPointer.hh:84

◆ skip()

template<class T >
virtual skip_type JLANG::JObjectIterator< T >::skip ( const skip_type ns)
inlinevirtualinherited

Skip items.

Parameters
nsnumber of items to skip
Returns
number of items skipped

Reimplemented in JLANG::JAbstractObjectReader< T >, JLANG::JAbstractObjectReader< const event_type >, JLANG::JAbstractObjectReader< Evt >, JLANG::JAbstractObjectReader< JDAQSummaryslice >, JLANG::JAbstractObjectReader< JHead_t >, JLANG::JAbstractObjectReader< JTail_t >, JLANG::JAbstractObjectReader< JTypeList< JDAQEvent, JNullType > >, JLANG::JAbstractObjectReader< KM3NETDAQ::JDAQEvent >, JLANG::JPipe< T >, JLANG::JPipe< JHead_t >, JLANG::JPipe< JTail_t >, JLANG::JSTDObjectIterator< T >, JROOT::JRootFileReader< T, false >, JROOT::JTreeReaderObjectIterator< T >, JSUPPORT::JMultipleFileScanner< T >, JSUPPORT::JMultipleFileScanner< Evt >, JSUPPORT::JMultipleFileScanner< JDAQSummaryslice >, JSUPPORT::JMultipleFileScanner< JHead_t >, JSUPPORT::JMultipleFileScanner< JTail_t >, JSUPPORT::JMultipleFileScanner< JTypeList< JDAQEvent, JNullType > >, JSUPPORT::JMultipleFileScanner< JTypeList< JHead_t, JTail_t > >, JSUPPORT::JMultipleFileScanner< KM3NETDAQ::JDAQEvent >, JSUPPORT::JMultipleFileScanner<>, JSUPPORT::JSingleFileScanner< T >, JSUPPORT::JSingleFileScanner< JHead_t >, JSUPPORT::JSingleFileScanner< JTail_t >, JSUPPORT::JSingleFileScanner< JTypeList< JHead_t, JTail_t > >, and JSUPPORT::JSingleFileScanner<>.

Definition at line 90 of file JObjectIterator.hh.

91 {
92 skip_type i = 0;
93
94 for ( ; i != ns && hasNext(); ++i) {
95 next();
96 }
97
98 return i;
99 }
virtual bool hasNext()=0
Check availability of next element.
virtual const pointer_type & next()=0
Get next element.
unsigned int skip_type
Type definition for number of objects to skip.

Member Data Documentation

◆ do_throw

bool JLANG::JThrow< JAccessible >::do_throw
staticprotectedinherited

throw option

Set default throw option to true.

Definition at line 28 of file JThrow.hh.

◆ in

std::istream& JIO::JStreamReader::in
protectedinherited

Definition at line 73 of file JStreamIO.hh.

◆ object

template<class T >
T JLANG::JAbstractObjectIterator< T >::object
protectedinherited

object

Definition at line 34 of file JAbstractObjectIterator.hh.

◆ has_next

template<class T >
bool JLANG::JAbstractObjectIterator< T >::has_next
protectedinherited

status

Definition at line 35 of file JAbstractObjectIterator.hh.

◆ ps

template<class T >
pointer_type JLANG::JAbstractObjectIterator< T >::ps
privateinherited

Definition at line 84 of file JAbstractObjectIterator.hh.


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