casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Sequence.h
Go to the documentation of this file.
00001 //# Sequence.h: provides sequences
00002 //# Copyright (C) 1993,1994,1995,1999,2001
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 //# $Id: Sequence.h 21051 2011-04-20 11:46:29Z gervandiepen $
00027 
00028 #ifndef CASA_SEQUENCE_H
00029 #define CASA_SEQUENCE_H
00030 
00031 #include <casa/aips.h>
00032 #include <casa/OS/Mutex.h>
00033 
00034 namespace casa { //# NAMESPACE CASA - BEGIN
00035 
00036 // <summary> virtual templated base class for sequences </summary>
00037 // <use visibility=export>
00038 // <reviewed reviewer="Friso Olnon" date="1995/03/17" tests="" demos="">
00039 // </reviewed>
00040 
00041 // <synopsis>
00042 // The virtual base class for sequences in the library.
00043 // It is templated to allow users to derive sequences of any type,
00044 // e.g. libg++'s Integers.
00045 // </synopsis>
00046 
00047 template<class t> class Sequence {
00048 public:
00049     virtual ~Sequence(){};
00050 
00051     // Force derived classes to provide this function, to return the
00052     // next value in the sequence.
00053     virtual t getNext () = 0;
00054 };
00055 
00056 
00057 // <summary> uInt sequence for general use </summary>
00058 // <use visibility=export>
00059 // <reviewed reviewer="Friso Olnon" date="1995/03/17" tests="" demos="">
00060 // </reviewed>
00061 
00062 // <synopsis>
00063 // This class provides a <src>uInt</src> based sequence for general use.
00064 // </synopsis>
00065 
00066 class uIntSequence : public Sequence<uInt> {
00067 
00068 public:
00069     // Get the next <src>uInt</src> value in the sequence (thread-safe).
00070     // <group>
00071     uInt getNext()
00072       { return SgetNext(); }
00073     static uInt SgetNext();
00074     // </group>
00075 
00076 private:
00077     static uInt num;
00078     static Mutex theirMutex;
00079 };
00080 
00081 
00082 } //# NAMESPACE CASA - END
00083 
00084 #ifndef CASACORE_NO_AUTO_TEMPLATES
00085 #include <casa/Utilities/Sequence.tcc>
00086 #endif //# CASACORE_NO_AUTO_TEMPLATES
00087 #endif