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