casacore
Loading...
Searching...
No Matches
BaseSinkSource.h
Go to the documentation of this file.
1// # BaseSinkSource.h: Shared base class for ByteSink and ByteSource
2// # Copyright (C) 1996,1999,2001
3// # Associated Universities, Inc. Washington DC, USA.
4// #
5// # This library is free software; you can redistribute it and/or modify it
6// # under the terms of the GNU Library General Public License as published by
7// # the Free Software Foundation; either version 2 of the License, or (at your
8// # option) any later version.
9// #
10// # This library is distributed in the hope that it will be useful, but WITHOUT
11// # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12// # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13// # License for more details.
14// #
15// # You should have received a copy of the GNU Library General Public License
16// # along with this library; if not, write to the Free Software Foundation,
17// # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18// #
19// # Correspondence concerning AIPS++ should be addressed as follows:
20// # Internet email: casa-feedback@nrao.edu.
21// # Postal address: AIPS++ Project Office
22// # National Radio Astronomy Observatory
23// # 520 Edgemont Road
24// # Charlottesville, VA 22903-2475 USA
25
26#ifndef CASA_BASESINKSOURCE_H
27#define CASA_BASESINKSOURCE_H
28
29#include <casacore/casa/aips.h>
30#include <casacore/casa/IO/TypeIO.h>
31#include <casacore/casa/IO/ByteIO.h>
32#include <memory>
33
34namespace casacore { // # NAMESPACE CASACORE - BEGIN
35
36// <summary>Shared base class for ByteSink and ByteSource.</summary>
37
38// <use visibility=export>
39
40// <prerequisite>
41// <li> <linkto class=TypeIO>TypeIO</linkto> class and derived classes
42// </prerequisite>
43
44// <reviewed reviewer="Friso Olnon" date="1996/11/06" tests="tByteSink" demos="">
45// </reviewed>
46
47// <synopsis>
48// This class provides the common functionality for the classes
49// <linkto class=ByteSink>ByteSink</linkto> and
50// <linkto class=ByteSource>ByteSource</linkto>.
51// <p>
52// The object is constructed using a typed byte stream. This stream
53// is an instance of a class derived from class
54// <linkto class=TypeIO>TypeIO</linkto>. This makes it possible to
55// store the data in any format (e.g. CanonicalIO or RawIO).
56// Class <linkto class=CanonicalIO>CanonicalIO</linkto> makes it
57// possible to store the data in a canonical (machine-independent) format,
58// so it can be read on any machine and operating system. The canonical
59// format is big-endian IEEE, where a (unsigned) long is stored as 8 bytes.
60// This means that on common 32-bit big-endian machines like SUN and HP
61// only longs have to be converted and that CanonicalIO is as fast as RawIO.
62// Class <linkto class=RawIO>RawIO</linkto> stores the data in native
63// format, so the IO-process is faster on especially little-endian
64// machines (PC, DEC-alpha). Note that RawIO can also be used to read
65// bytes and interprete or convert them thereafter (e.g. using the
66// conversion functions in the <linkto class=Conversion>Conversion</linkto>
67// Conversion framework.
68// <p>
69// In its turn TypeIO uses an instance of a class derived from class
70// <linkto class=ByteIO>ByteIO</linkto>. This makes it possible to
71// use any output stream (e.g. file, memory).
72// </synopsis>
73
74// <motivation>
75// The design of the ByteSink and ByteSource classes resembles the design of
76// the iostream classes in the standard library. A shared base class is needed
77// to allow multiple inheritance needed for class ByteSinkSource.
78// </motivation>
79
81 public:
82 // This functions returns the shared pointer to itsTypeIO.
83 const std::shared_ptr<TypeIO>& typeIO() const { return itsTypeIO; }
84
85 // This function sets the position on the given offset.
86 // The seek option defines from which position the seek is done.
87 // <group>
90 // </group>
91
92 // Is the SinkSource readable?
94
95 // Is the SinkSource writable?
97
98 // Is the SinkSource seekable?
100
101 // Is the BaseSinkSource unusable?
102 Bool isNull() const;
103
104 protected:
106
107 // Construct using the given TypeIO.
108 // The constructor does not copy the object, but only keeps a pointer to it.
109 BaseSinkSource(const std::shared_ptr<TypeIO>& typeIO);
110
111 // The copy constructor uses reference semantics
113
114 // The assignment operator uses reference semantics
116
118
119 // This variable keeps a pointer to a TypeIO.
120 std::shared_ptr<TypeIO> itsTypeIO;
121};
122
123} // namespace casacore
124
125#endif
Bool isSeekable() const
Is the SinkSource seekable?
BaseSinkSource & operator=(const BaseSinkSource &BaseSinkSource)
The assignment operator uses reference semantics.
Bool isWritable() const
Is the SinkSource writable?
const std::shared_ptr< TypeIO > & typeIO() const
This functions returns the shared pointer to itsTypeIO.
BaseSinkSource(const BaseSinkSource &BaseSinkSource)
The copy constructor uses reference semantics.
Bool isReadable() const
Is the SinkSource readable?
BaseSinkSource(const std::shared_ptr< TypeIO > &typeIO)
Construct using the given TypeIO.
Int64 seek(Int offset, ByteIO::SeekOption=ByteIO::Begin)
Int64 seek(Int64 offset, ByteIO::SeekOption=ByteIO::Begin)
This function sets the position on the given offset.
std::shared_ptr< TypeIO > itsTypeIO
This variable keeps a pointer to a TypeIO.
Bool isNull() const
Is the BaseSinkSource unusable?
SeekOption
Define the possible seek options.
Definition ByteIO.h:77
@ Begin
Seek from beginning of file.
Definition ByteIO.h:79
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
int offset(int, int) const
compute a linear offset from array indicies
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size).
Definition aipsxtype.h:36
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40