casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ByteSinkSource.h
Go to the documentation of this file.
1 //# ByteSinkSource.h: Class for read/write access to data in a given format
2 //# Copyright (C) 1996,1999
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_BYTESINKSOURCE_H
29 #define CASA_BYTESINKSOURCE_H
30 
31 #include <casacore/casa/aips.h>
34 
35 namespace casacore { //# NAMESPACE CASACORE - BEGIN
36 
37 class TypeIO;
38 
39 // <summary>Class for read/write access to data in a given format.</summary>
40 
41 // <use visibility=export>
42 
43 // <reviewed reviewer="Friso Olnon" date="1996/11/06" tests="tByteSinkSource" demos="">
44 // </reviewed>
45 
46 // <prerequisite>
47 // <li> <linkto class=ByteSink>ByteSink</linkto> class
48 // <li> <linkto class=ByteSource>ByteSource</linkto> class
49 // <li> <linkto class=TypeIO>TypeIO</linkto> class and derived classes
50 // </prerequisite>
51 
52 // <etymology>
53 // This class combines ByteSink and ByteSource.
54 // </etymology>
55 
56 // <synopsis>
57 // ByteSinkSource provides read/write access to a typed byte stream in the
58 // Casacore IO framework. It is derived from the classes <src>ByteSink</src>
59 // and <src>ByteSource</src>, so it combines their functionality.
60 // <p>
61 // The object is constructed using a typed byte stream. This stream
62 // is an instance of a class derived from class
63 // <linkto class=TypeIO>TypeIO</linkto>. This makes it possible to
64 // store the data in any format (e.g. CanonicalIO or RawIO).
65 // <br> In its turn TypeIO uses an instance of a class derived from class
66 // <linkto class=ByteIO>ByteIO</linkto>. This makes it possible to
67 // use any output stream (e.g. file, memory).
68 // </synopsis>
69 
70 // <example>
71 // <srcblock>
72 // main
73 // {
74 // Bool valb = True;
75 // RegularFileIO regularFileIO ("test.dat", ByteIO::New);
76 // CanonicalIO canonicalIO(&regularFileIO);
77 // ByteSinkSource sinkSource(&canonicalIO);
78 // sinkSource << valb; // Write a boolean
79 // sinkSource.seek (0); // Reset to begin of IO stream
80 // sinkSource >> valb; // Read a boolean
81 // cout << valb << endl; // Print the boolean
82 // }
83 // </srcblock>
84 // </example>
85 
86 // <motivation>
87 // This class makes it transparant to do IO with different devices and
88 // in different ways.
89 // </motivation>
90 
91 
92 class ByteSinkSource: public ByteSink, public ByteSource
93 {
94 public:
95  // Default constructor.
96  // This creates an invalid object, but is present for convenience.
98 
99  // Construct from given TypeIO object. The constructor does not copy the
100  // object, but only keeps a pointer to it. If takeOver is true the this
101  // class will delete the supplied pointer. Otherwise the caller is
102  // responsible for this.
103  ByteSinkSource (TypeIO* typeIO, Bool takeOver=False);
104 
105  // The copy constructor uses reference semantics
106  ByteSinkSource (const ByteSinkSource& sinkSource);
107 
108  // The assignment operator uses reference semantics
109  ByteSinkSource& operator= (const ByteSinkSource& sinkSource);
110 
111  ~ByteSinkSource();
112 };
113 
114 
115 
116 } //# NAMESPACE CASACORE - END
117 
118 #endif
Class for write-only access to data in a given format.
Definition: ByteSink.h:95
Class for read-only access to data in a given format.
Definition: ByteSource.h:91
TypeIO & typeIO()
This functions returns a reference to itsTypeIO.
Class for read/write access to data in a given format.
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
const Bool False
Definition: aipstype.h:44
ByteSinkSource & operator=(const ByteSinkSource &sinkSource)
The assignment operator uses reference semantics.
ByteSinkSource()
Default constructor.