diff options
author | Tim Mayberry <mojofunk@gmail.com> | 2013-08-09 22:03:39 +1000 |
---|---|---|
committer | Tim Mayberry <mojofunk@gmail.com> | 2013-08-13 20:15:47 +1000 |
commit | 29193c76ccb2cdead8ee31b753945b6080994956 (patch) | |
tree | 113372dbbb49ad77037b5f50a6683eab6c3296bb | |
parent | de4b24b162a2fccd6049d14eb092276fd2d4f849 (diff) |
Add PBD::init and PBD::cleanup
A bit of refactoring to move initialization of libpbd into libpbd
rather than rely on "client" code(ui,libardour,tests etc) to do it
-rw-r--r-- | libs/pbd/pbd.cc | 59 | ||||
-rw-r--r-- | libs/pbd/pbd/pbd.h | 30 | ||||
-rw-r--r-- | libs/pbd/wscript | 1 |
3 files changed, 90 insertions, 0 deletions
diff --git a/libs/pbd/pbd.cc b/libs/pbd/pbd.cc new file mode 100644 index 0000000000..58c8440a0f --- /dev/null +++ b/libs/pbd/pbd.cc @@ -0,0 +1,59 @@ +/* + Copyright (C) 2011 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include <iostream> +#include <cstdlib> + +#include <glibmm/thread.h> + +#include "pbd/pbd.h" +#include "pbd/debug.h" +#include "pbd/id.h" +#include "pbd/enumwriter.h" + +#include "i18n.h" + +namespace { + +static bool libpbd_initialized = false; + +} + +bool +PBD::init () +{ + if (libpbd_initialized) { + return true; + } + + if (!Glib::thread_supported()) { + Glib::thread_init(); + } + + PBD::ID::init (); + + libpbd_initialized = true; + return true; +} + +void +PBD::cleanup () +{ + EnumWriter::destroy (); +} diff --git a/libs/pbd/pbd/pbd.h b/libs/pbd/pbd/pbd.h new file mode 100644 index 0000000000..5b3745f0ed --- /dev/null +++ b/libs/pbd/pbd/pbd.h @@ -0,0 +1,30 @@ +/* + Copyright (C) 2011 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __libpbd_pbd_h__ +#define __libpbd_pbd_h__ + +namespace PBD { + + bool init (); + void cleanup (); + +} // namespace PBD + +#endif diff --git a/libs/pbd/wscript b/libs/pbd/wscript index 0655e1ca48..ffbe0e0d19 100644 --- a/libs/pbd/wscript +++ b/libs/pbd/wscript @@ -56,6 +56,7 @@ libpbd_sources = [ 'openuri.cc', 'pathexpand.cc', 'pathscanner.cc', + 'pbd.cc', 'pool.cc', 'property_list.cc', 'pthread_utils.cc', |