casacore
Sequence.h
Go to the documentation of this file.
1 //# Sequence.h: provides sequences
2 //# Copyright (C) 1993,1994,1995,1999,2001
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_SEQUENCE_H
29 #define CASA_SEQUENCE_H
30 
31 #include <casacore/casa/aips.h>
32 #include <casacore/casa/OS/Mutex.h>
33 
34 namespace casacore { //# NAMESPACE CASACORE - BEGIN
35 
36 // <summary> virtual templated base class for sequences </summary>
37 // <use visibility=export>
38 // <reviewed reviewer="Friso Olnon" date="1995/03/17" tests="" demos="">
39 // </reviewed>
40 
41 // <synopsis>
42 // The virtual base class for sequences in the library.
43 // It is templated to allow users to derive sequences of any type,
44 // e.g. libg++'s Integers.
45 // </synopsis>
46 
47 template<class t> class Sequence {
48 public:
49  virtual ~Sequence(){};
50 
51  // Force derived classes to provide this function, to return the
52  // next value in the sequence.
53  virtual t getNext () = 0;
54 };
55 
56 
57 // <summary> uInt sequence for general use </summary>
58 // <use visibility=export>
59 // <reviewed reviewer="Friso Olnon" date="1995/03/17" tests="" demos="">
60 // </reviewed>
61 
62 // <synopsis>
63 // This class provides a <src>uInt</src> based sequence for general use.
64 // </synopsis>
65 
66 class uIntSequence : public Sequence<uInt> {
67 
68 public:
69  // Get the next <src>uInt</src> value in the sequence (thread-safe).
70  // <group>
72  { return SgetNext(); }
73  static uInt SgetNext();
74  // </group>
75 
76 private:
77 #if defined(USE_THREADS)
78  static std::atomic<uInt> next;
79 #else
80  static uInt next;
81 #endif
82 };
83 
84 
85 } //# NAMESPACE CASACORE - END
86 
87 #ifndef CASACORE_NO_AUTO_TEMPLATES
88 #include <casacore/casa/Utilities/Sequence.tcc>
89 #endif //# CASACORE_NO_AUTO_TEMPLATES
90 #endif
casacore::uIntSequence::getNext
uInt getNext()
Get the next uInt value in the sequence (thread-safe).
Definition: Sequence.h:71
casacore::uIntSequence::SgetNext
static uInt SgetNext()
casacore::uInt
unsigned int uInt
Definition: aipstype.h:51
casacore::Sequence::~Sequence
virtual ~Sequence()
Definition: Sequence.h:49
casacore
this file contains all the compiler specific defines
Definition: mainpage.dox:28
casacore::uIntSequence::next
static std::atomic< uInt > next
Definition: Sequence.h:78
casacore::Sequence
Definition: Sequence.h:47
casacore::Sequence::getNext
virtual t getNext()=0
Force derived classes to provide this function, to return the next value in the sequence.
casacore::uIntSequence
uInt sequence for general use
Definition: Sequence.h:66