[beast/devel: 14/17] BSE: provide ServerImpl
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast/devel: 14/17] BSE: provide ServerImpl
- Date: Wed, 1 May 2013 12:31:08 +0000 (UTC)
commit 89339335a3f9c7bf49d455cb24c9559f06887ab2
Author: Tim Janik <timj gnu org>
Date: Thu Mar 28 16:07:38 2013 +0000
BSE: provide ServerImpl
bse/bseserver.cc | 35 +++++++++++++++++++++++++++++++++++
bse/bseserver.hh | 25 ++++++++++++++++++++++---
2 files changed, 57 insertions(+), 3 deletions(-)
---
diff --git a/bse/bseserver.cc b/bse/bseserver.cc
index 52e65aa..ac983b8 100644
--- a/bse/bseserver.cc
+++ b/bse/bseserver.cc
@@ -1021,3 +1021,38 @@ engine_shutdown (BseServer *server)
// FIXME: need to be able to completely unintialize engine here
bse_gconfig_unlock ();
}
+
+
+namespace Bse {
+
+ServerImpl::ServerImpl ()
+{}
+
+ServerImpl::~ServerImpl ()
+{}
+
+TestObjectIface*
+ServerImpl::get_test_object ()
+{
+ if (!test_object_)
+ test_object_ = std::make_shared<TestObjectImpl>();
+ return &*test_object_;
+}
+
+ServerImpl&
+ServerImpl::instance()
+{
+ static Rapicorn::Atomic<ServerImpl*> instance_ = NULL;
+ if (LIKELY (instance_ != NULL))
+ return *instance_;
+ static Mutex instance_mutex;
+ ScopedLock<Mutex> locker (instance_mutex);
+ if (!instance_)
+ {
+ static uint64 instance_space[sizeof (*instance_) / sizeof (uint64)];
+ instance_ = new (instance_space) ServerImpl();
+ }
+ return *instance_;
+}
+
+} // Bse
diff --git a/bse/bseserver.hh b/bse/bseserver.hh
index 6674aa3..3fb4e07 100644
--- a/bse/bseserver.hh
+++ b/bse/bseserver.hh
@@ -1,10 +1,13 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_SERVER_H__
#define __BSE_SERVER_H__
-#include <bse/bsesuper.hh>
-#include <bse/bsepcmdevice.hh>
-#include <bse/bsemididevice.hh>
+#include <bse/bsesuper.hh>
+#include <bse/bsepcmdevice.hh>
+#include <bse/bsemididevice.hh>
+#include <bse/testobject.hh>
+
G_BEGIN_DECLS
+
/* --- BSE type macros --- */
#define BSE_TYPE_SERVER (BSE_TYPE_ID (BseServer))
#define BSE_SERVER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_SERVER, BseServer))
@@ -103,4 +106,20 @@ void bse_server_queue_kill_wire (BseServer *server,
SfiComWire *wire);
void bse_server_notify_gconfig (BseServer *server);
G_END_DECLS
+
+
+namespace Bse {
+
+class ServerImpl : public ServerIface {
+ TestObjectImplP test_object_;
+protected:
+ explicit ServerImpl ();
+ virtual ~ServerImpl ();
+public:
+ virtual TestObjectIface* get_test_object ();
+ static ServerImpl& instance ();
+};
+
+} // Bse
+
#endif /* __BSE_SERVER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]