casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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: aips2-request@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 //# $Id$
27 
28 #ifndef CASA_BASESINKSOURCE_H
29 #define CASA_BASESINKSOURCE_H
30 
31 #include <casacore/casa/aips.h>
35 
36 namespace casacore { //# NAMESPACE CASACORE - BEGIN
37 
38 // <summary>Shared base class for ByteSink and ByteSource.</summary>
39 
40 // <use visibility=export>
41 
42 // <prerequisite>
43 // <li> <linkto class=TypeIO>TypeIO</linkto> class and derived classes
44 // </prerequisite>
45 
46 // <reviewed reviewer="Friso Olnon" date="1996/11/06" tests="tByteSink" demos="">
47 // </reviewed>
48 
49 // <synopsis>
50 // This class provides the common functionality for the classes
51 // <linkto class=ByteSink>ByteSink</linkto> and
52 // <linkto class=ByteSource>ByteSource</linkto>.
53 // <p>
54 // The object is constructed using a typed byte stream. This stream
55 // is an instance of a class derived from class
56 // <linkto class=TypeIO>TypeIO</linkto>. This makes it possible to
57 // store the data in any format (e.g. CanonicalIO or RawIO).
58 // Class <linkto class=CanonicalIO>CanonicalIO</linkto> makes it
59 // possible to store the data in a canonical (machine-independent) format,
60 // so it can be read on any machine and operating system. The canonical
61 // format is big-endian IEEE, where a (unsigned) long is stored as 8 bytes.
62 // This means that on common 32-bit big-endian machines like SUN and HP
63 // only longs have to be converted and that CanonicalIO is as fast as RawIO.
64 // Class <linkto class=RawIO>RawIO</linkto> stores the data in native
65 // format, so the IO-process is faster on especially little-endian
66 // machines (PC, DEC-alpha). Note that RawIO can also be used to read
67 // bytes and interprete or convert them thereafter (e.g. using the
68 // conversion functions in the <linkto class=Conversion>Conversion</linkto>
69 // Conversion framework.
70 // <p>
71 // In its turn TypeIO uses an instance of a class derived from class
72 // <linkto class=ByteIO>ByteIO</linkto>. This makes it possible to
73 // use any output stream (e.g. file, memory).
74 // </synopsis>
75 
76 // <motivation>
77 // The design of the ByteSink and ByteSource classes resembles the design of
78 // the iostream classes in the standard library. A shared base class is needed
79 // to allow multiple inheritance needed for class ByteSinkSource.
80 // </motivation>
81 
82 
84 {
85 public:
86  // This functions returns a reference to itsTypeIO.
87  // <group>
88  TypeIO& typeIO();
89  const TypeIO& typeIO() const;
90  // </group>
91 
92  // This function sets the position on the given offset.
93  // The seek option defines from which position the seek is done.
94  // <group>
97  // </group>
98 
99  // Is the SinkSource readable?
100  Bool isReadable() const;
101 
102  // Is the SinkSource writable?
103  Bool isWritable() const;
104 
105  // Is the SinkSource seekable?
106  Bool isSeekable() const;
107 
108  // Is the BaseSinkSource unusable?
109  Bool isNull() const;
110 
111 protected:
112  BaseSinkSource();
113 
114  // Construct using the given TypeIO. If takeOver is true the this class
115  // will delete the supplied pointer. Otherwise the caller is responsible
116  // for this.
117  BaseSinkSource (TypeIO* typeIO, Bool takeOver=False);
118 
119  // The copy constructor uses reference semantics
121 
122  // The assignment operator uses reference semantics
123  BaseSinkSource& operator= (const BaseSinkSource& BaseSinkSource);
124 
125  virtual ~BaseSinkSource();
126 
127 
128  // This variable keeps a pointer to a TypeIO.
130 };
131 
132 
133 
134 } //# NAMESPACE CASACORE - END
135 
136 #endif
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition: aipsxtype.h:38
int Int
Definition: aipstype.h:50
CountedPtr< TypeIO > itsTypeIO
This variable keeps a pointer to a TypeIO.
Bool isWritable() const
Is the SinkSource writable?
SeekOption
Define the possible seek options.
Definition: ByteIO.h:82
Int64 seek(Int64 offset, ByteIO::SeekOption=ByteIO::Begin)
This function sets the position on the given offset.
Bool isReadable() const
Is the SinkSource readable?
TypeIO & typeIO()
This functions returns a reference to itsTypeIO.
Bool isSeekable() const
Is the SinkSource seekable?
Shared base class for ByteSink and ByteSource.
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
Abstract base class for IO of data in a type-dependent format.
Definition: TypeIO.h:79
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Seek from beginning of file.
Definition: ByteIO.h:84
const Bool False
Definition: aipstype.h:44
Bool isNull() const
Is the BaseSinkSource unusable?
BaseSinkSource & operator=(const BaseSinkSource &BaseSinkSource)
The assignment operator uses reference semantics.
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42