casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
VLATapeIO.h
Go to the documentation of this file.
00001 //# <VLATapeIO.h>: this defines <VLATapeIO>, which ...
00002 //# Copyright (C) 1997,1999,2002
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //#
00027 //# $Id$
00028 //#! ========================================================================
00029 //#!                Attention!  Programmers read this!
00030 //#!
00031 //#! This file is a template to guide you in creating a header file
00032 //#! for your new class.   By following this template, you will create
00033 //#! a permanent reference document for your class, suitable for both
00034 //#! the novice client programmer, the seasoned veteran, and anyone in 
00035 //#! between.  It is essential that you write the documentation portions 
00036 //#! of this file with as much care as you do the source code.
00037 //#!
00038 //#! If you are unfamilar with the AIPS++ header style please refer to
00039 //#! template-class-h.
00040 //#!
00041 //#!                         Replacement Tokens
00042 //#!                         ------------------
00043 //#!
00044 //#! These are character strings enclosed in angle brackets, on a commented
00045 //#! line.  Two are found on the first line of this file:
00046 //#!
00047 //#!   <ClassFileName.h> <ClassName>
00048 //#!
00049 //#! You should remove the angle brackets, and replace the characters within
00050 //#! the brackets with names specific to your class.  Mimic the capitalization
00051 //#! and punctuation of the original.  For example, you would change
00052 //#!
00053 //#!   <ClassFileName.h>  to   LatticeIter.h
00054 //#!   <ClassName>        to   LatticeIterator
00055 //#!
00056 //#! Another replacement token will be found in the "include guard" just
00057 //#! a few lines below.
00058 //#!
00059 //#!  #define <AIPS_CLASSFILENAME_H>  to  #define AIPS_LATTICEITER_H
00060 //#!
00061 
00062 #ifndef NRAO_VLATAPEIO_H
00063 #define NRAO_VLATAPEIO_H
00064 
00065 //# Forward Declarations
00066 
00067 // <summary>
00068 // This class this defines VLATapeIO
00069 // </summary>
00070 
00071 // <use visibility=local>   or   <use visibility=export>
00072 
00073 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00074 // </reviewed>
00075 
00076 // <prerequisite>
00077 //   <li> SomeClass
00078 //   <li> SomeOtherClass
00079 //   <li> some concept
00080 // </prerequisite>
00081 //
00082 // <etymology>
00083 // </etymology>
00084 //
00085 // <synopsis>
00086 // </synopsis>
00087 //
00088 // <example>
00089 // </example>
00090 //
00091 // <motivation>
00092 // </motivation>
00093 //
00094 // <templating arg=T>
00095 //    <li>
00096 //    <li>
00097 // </templating>
00098 //
00099 // <thrown>
00100 //    <li>
00101 //    <li>
00102 // </thrown>
00103 //
00104 // <todo asof="yyyy/mm/dd">
00105 //   <li> add this feature
00106 //   <li> fix this bug
00107 //   <li> start discussion of this possible extension
00108 // </todo>
00109 
00110 
00111 
00112 #include <casa/aips.h>
00113 #include <casa/BasicSL/String.h>
00114 #include <sys/types.h>
00115 #include <sys/stat.h>
00116 #include <fcntl.h>
00117 
00118 #include <casa/namespace.h>
00119 // kludge for tapes until we do something specific.
00120 //  It''s pretty much a thin vaneer that sits on top of rmt.
00121 
00122 Int rmtopen(Char *, Int, Int);
00123 Int rmtread(Int, Char *, uInt);
00124 Int rmtwrite(Int, Char *, uInt);
00125 Int rmtaccess(Char *, uInt);
00126 Int rmtclose(Int);
00127 
00128 class VLATapeIO {
00129    public :
00130       VLATapeIO() : tapeId(-1){}
00131       VLATapeIO(const String &a) : inOut(O_RDONLY), tPosition(0){
00132                                 tapeId = open((Char *)(a.chars()), inOut, tPosition);
00133                                 }
00134       VLATapeIO(const String &a, Int rwFlag, Int tpos) : inOut(rwFlag),
00135                                                       tPosition(tpos){
00136                               tapeId = open((Char *)(a.chars()), inOut, tPosition);
00137                               }
00138      ~VLATapeIO(){if(tapeId != -1)rmtclose(tapeId);}
00139       Int  open(const String &a, Int b, Int c){
00140                 tapeId = rmtopen((Char *)(a.chars()), b, c);
00141                 return tapeId;}
00142       Int  read(Char *buf, uInt nsize){return rmtread(tapeId, buf, nsize);}
00143       //Int  write(Char *buf, uInt nsize){return rmtwrite(tapeId, buf, nsize);}
00144       Int  access(const Char *a, uInt b){return rmtaccess((Char *)a, b);}
00145       Int close(){return rmtclose(tapeId);}
00146    private :
00147       Int inOut;
00148       Int tapeId;
00149       Int tPosition;
00150 };
00151 #endif