/[svn]/linuxsampler/branches/release2_1_0/src/common/IDGenerator.h
ViewVC logotype

Contents of /linuxsampler/branches/release2_1_0/src/common/IDGenerator.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3373 - (show annotations) (download) (as text)
Sat Nov 25 17:31:53 2017 UTC (6 years, 6 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 1037 byte(s)
Created linuxsampler branch 'release2_1_0'.
1 #ifndef LS_IDGENERATOR_H
2 #define LS_IDGENERATOR_H
3
4 #include <set>
5
6 namespace LinuxSampler {
7
8 /**
9 * Generates unique numerical IDs starting from zero.
10 *
11 * @e Note: this class is not exported to the C++ API of the sampler!
12 */
13 class IDGenerator {
14 public:
15 /**
16 * Constructor.
17 *
18 * @param simpleAlgorithm - if false, all created IDs which are still in
19 * use will be remembered, if true then IDs are
20 * simply generated by incrementing an int variable
21 * by 1 until the whole int value range was used
22 */
23 IDGenerator(bool simpleAlgorithm = false);
24
25 /**
26 * Returns new unique positive ID of at least zero, a negative number if
27 * no free ID could be generated.
28 */
29 int create();
30
31 /**
32 * Free the given ID, for being re-used in future.
33 */
34 void destroy(int id);
35
36 private:
37 std::set<int> ids;
38 int previousId;
39 bool simple;
40 };
41
42 } // namespace LinuxSampler
43
44 #endif // LS_IDGENERATOR_H

  ViewVC Help
Powered by ViewVC