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
89
90class ByteSinkSource: public ByteSink, public ByteSource
91{
92public:
93 // Default constructor.
94 // This creates an invalid object, but is present for convenience.
96
97 // Construct from given TypeIO object.
98 // The constructor does not copy the object, but only keeps a pointer to it.
99 ByteSinkSource (const std::shared_ptr<TypeIO>& typeIO);
100
101 // The copy constructor uses reference semantics
102 ByteSinkSource (const ByteSinkSource& sinkSource);
103
104 // The assignment operator uses reference semantics
106
108};
109
110
111
112} //# NAMESPACE CASACORE - END
113
114#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.
this file contains all the compiler specific defines
Definition mainpage.dox:28