Mercurial > hg > sv-dependency-builds
annotate src/portaudio/bindings/cpp/include/portaudiocpp/AutoSystem.hxx @ 23:619f715526df sv_v2.1
Update Vamp plugin SDK to 2.5
author | Chris Cannam |
---|---|
date | Thu, 09 May 2013 10:52:46 +0100 |
parents | e13257ea84a4 |
children |
rev | line source |
---|---|
Chris@4 | 1 #ifndef INCLUDED_PORTAUDIO_AUTOSYSTEM_HXX |
Chris@4 | 2 #define INCLUDED_PORTAUDIO_AUTOSYSTEM_HXX |
Chris@4 | 3 |
Chris@4 | 4 // --------------------------------------------------------------------------------------- |
Chris@4 | 5 |
Chris@4 | 6 #include "portaudiocpp/System.hxx" |
Chris@4 | 7 |
Chris@4 | 8 // --------------------------------------------------------------------------------------- |
Chris@4 | 9 |
Chris@4 | 10 namespace portaudio |
Chris@4 | 11 { |
Chris@4 | 12 |
Chris@4 | 13 |
Chris@4 | 14 ////// |
Chris@4 | 15 /// @brief A RAII idiom class to ensure automatic clean-up when an exception is |
Chris@4 | 16 /// raised. |
Chris@4 | 17 /// |
Chris@4 | 18 /// A simple helper class which uses the 'Resource Acquisition is Initialization' |
Chris@4 | 19 /// idiom (RAII). Use this class to initialize/terminate the System rather than |
Chris@4 | 20 /// using System directly. AutoSystem must be created on stack and must be valid |
Chris@4 | 21 /// throughout the time you wish to use PortAudioCpp. Your 'main' function might be |
Chris@4 | 22 /// a good place for it. |
Chris@4 | 23 /// |
Chris@4 | 24 /// To avoid having to type portaudio::System::instance().xyz() all the time, it's usually |
Chris@4 | 25 /// a good idea to make a reference to the System which can be accessed directly. |
Chris@4 | 26 /// @verbatim |
Chris@4 | 27 /// portaudio::AutoSys autoSys; |
Chris@4 | 28 /// portaudio::System &sys = portaudio::System::instance(); |
Chris@4 | 29 /// @endverbatim |
Chris@4 | 30 ////// |
Chris@4 | 31 class AutoSystem |
Chris@4 | 32 { |
Chris@4 | 33 public: |
Chris@4 | 34 AutoSystem(bool initialize = true) |
Chris@4 | 35 { |
Chris@4 | 36 if (initialize) |
Chris@4 | 37 System::initialize(); |
Chris@4 | 38 } |
Chris@4 | 39 |
Chris@4 | 40 ~AutoSystem() |
Chris@4 | 41 { |
Chris@4 | 42 if (System::exists()) |
Chris@4 | 43 System::terminate(); |
Chris@4 | 44 } |
Chris@4 | 45 |
Chris@4 | 46 void initialize() |
Chris@4 | 47 { |
Chris@4 | 48 System::initialize(); |
Chris@4 | 49 } |
Chris@4 | 50 |
Chris@4 | 51 void terminate() |
Chris@4 | 52 { |
Chris@4 | 53 System::terminate(); |
Chris@4 | 54 } |
Chris@4 | 55 }; |
Chris@4 | 56 |
Chris@4 | 57 |
Chris@4 | 58 } // namespace portaudio |
Chris@4 | 59 |
Chris@4 | 60 // --------------------------------------------------------------------------------------- |
Chris@4 | 61 |
Chris@4 | 62 #endif // INCLUDED_PORTAUDIO_AUTOSYSTEM_HXX |