3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* Copyright (C) 2005 Christian Schoenebeck * |
* Copyright (C) 2005, 2006 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
9 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
24 |
#ifndef __LS_OPTIONAL_H__ |
#ifndef __LS_OPTIONAL_H__ |
25 |
#define __LS_OPTIONAL_H__ |
#define __LS_OPTIONAL_H__ |
26 |
|
|
27 |
#include "LinuxSamplerException.h" |
#include "Exception.h" |
28 |
|
|
29 |
namespace LinuxSampler { |
namespace LinuxSampler { |
30 |
|
|
57 |
initialized = true; |
initialized = true; |
58 |
} |
} |
59 |
|
|
60 |
const T& get() const throw (LinuxSamplerException) { |
const T& get() const throw (Exception) { |
61 |
if (!initialized) throw LinuxSamplerException("optional variable not initialized"); |
if (!initialized) throw Exception("optional variable not initialized"); |
62 |
return data; |
return data; |
63 |
} |
} |
64 |
|
|
65 |
T& get() throw (LinuxSamplerException) { |
T& get() throw (Exception) { |
66 |
if (!initialized) throw LinuxSamplerException("optional variable not initialized"); |
if (!initialized) throw Exception("optional variable not initialized"); |
67 |
return data; |
return data; |
68 |
} |
} |
69 |
|
|
70 |
optional& operator =(const optional& arg) throw (LinuxSamplerException) { |
optional& operator =(const optional& arg) throw (Exception) { |
71 |
if (!arg.initialized) throw LinuxSamplerException("optional variable not initialized"); |
if (!arg.initialized) throw Exception("optional variable not initialized"); |
72 |
this->data = arg.data; |
this->data = arg.data; |
73 |
initialized = true; |
initialized = true; |
74 |
return *this; |
return *this; |
80 |
return *this; |
return *this; |
81 |
} |
} |
82 |
|
|
83 |
const T& operator *() const throw (LinuxSamplerException) { return get(); } |
const T& operator *() const throw (Exception) { return get(); } |
84 |
T& operator *() throw (LinuxSamplerException) { return get(); } |
T& operator *() throw (Exception) { return get(); } |
85 |
|
|
86 |
const T* operator ->() const throw (LinuxSamplerException) { |
const T* operator ->() const throw (Exception) { |
87 |
if (!initialized) throw LinuxSamplerException("optional variable not initialized"); |
if (!initialized) throw Exception("optional variable not initialized"); |
88 |
return &data; |
return &data; |
89 |
} |
} |
90 |
|
|
91 |
T* operator ->() throw (LinuxSamplerException) { |
T* operator ->() throw (Exception) { |
92 |
if (!initialized) throw LinuxSamplerException("optional variable not initialized"); |
if (!initialized) throw Exception("optional variable not initialized"); |
93 |
return &data; |
return &data; |
94 |
} |
} |
95 |
|
|