casacore
Loading...
Searching...
No Matches
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: 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_SEQUENCE_H
27#define CASA_SEQUENCE_H
28
29#include <casacore/casa/aips.h>
30
31#include <atomic>
32
33namespace casacore { // # NAMESPACE CASACORE - BEGIN
34
35// <summary> virtual templated base class for sequences </summary>
36// <use visibility=export>
37// <reviewed reviewer="Friso Olnon" date="1995/03/17" tests="" demos="">
38// </reviewed>
39
40// <synopsis>
41// The virtual base class for sequences in the library.
42// It is templated to allow users to derive sequences of any type,
43// e.g. libg++'s Integers.
44// </synopsis>
45
46template <class t>
47class 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// <summary> uInt sequence for general use </summary>
57// <use visibility=export>
58// <reviewed reviewer="Friso Olnon" date="1995/03/17" tests="" demos="">
59// </reviewed>
60
61// <synopsis>
62// This class provides a <src>uInt</src> based sequence for general use.
63// </synopsis>
64
65class uIntSequence : public Sequence<uInt> {
66 public:
67 // Get the next <src>uInt</src> value in the sequence (thread-safe).
68 // <group>
69 uInt getNext() { return SgetNext(); }
70 static uInt SgetNext();
71 // </group>
72
73 private:
74#if defined(USE_THREADS)
75 static std::atomic<uInt> next;
76#else
77 static uInt next;
78#endif
79};
80
81} // namespace casacore
82
83#ifndef CASACORE_NO_AUTO_TEMPLATES
84#include <casacore/casa/Utilities/Sequence.tcc>
85#endif // # CASACORE_NO_AUTO_TEMPLATES
86#endif
virtual ~Sequence()
Definition Sequence.h:49
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:65
uInt getNext()
Get the next uInt value in the sequence (thread-safe).
Definition Sequence.h:69
static std::atomic< uInt > next
Definition Sequence.h:75
static uInt SgetNext()
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49