1 #ifndef AUDIOGRAPHER_THROWING_H
2 #define AUDIOGRAPHER_THROWING_H
4 #ifndef DEFAULT_THROW_LEVEL
5 #define DEFAULT_THROW_LEVEL ThrowStrict
11 /** Compile time defined throw level.
12 * Throw levels less than ThrowStrict should be used with caution.
13 * Not throwing could mean getting a segfault.
14 * However, if you want ultra-optimized code and/or don't care about handling
15 * error situations, feel free to use whatever you want.
19 ThrowNone, ///< Not allowed to throw
20 ThrowObject, ///< Object level stuff, ctors, initalizers etc.
21 ThrowProcess, ///< Process cycle level stuff
22 ThrowStrict, ///< Stricter checks than ThrowProcess, less than ThrowSample
23 ThrowSample ///< Sample level stuff
26 /** Class that allows optimizing out error checking during compile time.
27 * Usage: to take all advantage of this class you should wrap all
28 * throwing statemets like this:
30 * if (throw_level (SomeThrowLevel) && other_optional_conditionals) {
31 * throw Exception (...);
35 * The order of the conditionals in the if-clause is important.
36 * The checks specified in \a other_optional_conditionals are only
37 * optimized out if \a throw_level() is placed before it with a
38 * logical and (short-circuiting).
40 template<ThrowLevel L = DEFAULT_THROW_LEVEL>
45 bool throw_level (ThrowLevel level) { return L >= level; }
51 #endif // AUDIOGRAPHER_THROWING_H