casacore
Loading...
Searching...
No Matches
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: 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_BYTESINKSOURCE_H
27#define CASA_BYTESINKSOURCE_H
28
29#include <casacore/casa/aips.h>
30#include <casacore/casa/IO/ByteSink.h>
31#include <casacore/casa/IO/ByteSource.h>
32
33namespace casacore { // # NAMESPACE CASACORE - BEGIN
34
35class TypeIO;
36
37// <summary>Class for read/write access to data in a given format.</summary>
38
39// <use visibility=export>
40
41// <reviewed reviewer="Friso Olnon" date="1996/11/06" tests="tByteSinkSource" demos="">
42// </reviewed>
43
44// <prerequisite>
45// <li> <linkto class=ByteSink>ByteSink</linkto> class
46// <li> <linkto class=ByteSource>ByteSource</linkto> class
47// <li> <linkto class=TypeIO>TypeIO</linkto> class and derived classes
48// </prerequisite>
49
50// <etymology>
51// This class combines ByteSink and ByteSource.
52// </etymology>
53
54// <synopsis>
55// ByteSinkSource provides read/write access to a typed byte stream in the
56// Casacore IO framework. It is derived from the classes <src>ByteSink</src>
57// and <src>ByteSource</src>, so it combines their functionality.
58// <p>
59// The object is constructed using a typed byte stream. This stream
60// is an instance of a class derived from class
61// <linkto class=TypeIO>TypeIO</linkto>. This makes it possible to
62// store the data in any format (e.g. CanonicalIO or RawIO).
63// <br> In its turn TypeIO uses an instance of a class derived from class
64// <linkto class=ByteIO>ByteIO</linkto>. This makes it possible to
65// use any output stream (e.g. file, memory).
66// </synopsis>
67
68// <example>
69// <srcblock>
70// main
71// {
72// Bool valb = True;
73// RegularFileIO regularFileIO ("test.dat", ByteIO::New);
74// CanonicalIO canonicalIO(&regularFileIO);
75// ByteSinkSource sinkSource(&canonicalIO);
76// sinkSource << valb; // Write a boolean
77// sinkSource.seek (0); // Reset to begin of IO stream
78// sinkSource >> valb; // Read a boolean
79// cout << valb << endl; // Print the boolean
80// }
81// </srcblock>
82// </example>
83
84// <motivation>
85// This class makes it transparant to do IO with different devices and
86// in different ways.
87// </motivation>
88
89class ByteSinkSource : public ByteSink, public ByteSource {
90 public:
91 // Default constructor.
92 // This creates an invalid object, but is present for convenience.
94
95 // Construct from given TypeIO object.
96 // The constructor does not copy the object, but only keeps a pointer to it.
97 ByteSinkSource(const std::shared_ptr<TypeIO>& typeIO);
98
99 // The copy constructor uses reference semantics
100 ByteSinkSource(const ByteSinkSource& sinkSource);
101
102 // The assignment operator uses reference semantics
104
106};
107
108} // namespace casacore
109
110#endif
const std::shared_ptr< TypeIO > & typeIO() const
This functions returns the shared pointer to itsTypeIO.
ByteSinkSource(const ByteSinkSource &sinkSource)
The copy constructor uses reference semantics.
ByteSinkSource(const std::shared_ptr< TypeIO > &typeIO)
Construct from given TypeIO object.
ByteSinkSource()
Default constructor.
ByteSinkSource & operator=(const ByteSinkSource &sinkSource)
The assignment operator uses reference semantics.
ByteSink()
Default constructor.
ByteSource()
Default constructor.
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28