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> class Sequence {
47public:
48 virtual ~Sequence(){};
49
50 // Force derived classes to provide this function, to return the
51 // next value in the sequence.
52 virtual t getNext () = 0;
53};
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
67public:
68 // Get the next <src>uInt</src> value in the sequence (thread-safe).
69 // <group>
71 { return SgetNext(); }
72 static uInt SgetNext();
73 // </group>
74
75private:
76#if defined(USE_THREADS)
77 static std::atomic<uInt> next;
78#else
79 static uInt next;
80#endif
81};
82
83
84} //# NAMESPACE CASACORE - END
85
86#ifndef CASACORE_NO_AUTO_TEMPLATES
87#include <casacore/casa/Utilities/Sequence.tcc>
88#endif //# CASACORE_NO_AUTO_TEMPLATES
89#endif
virtual ~Sequence()
Definition Sequence.h:48
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:70
static std::atomic< uInt > next
Definition Sequence.h:77
static uInt SgetNext()
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49