aboutsummaryrefslogtreecommitdiff
path: root/Src/replicant/Wasabi/ServiceManager.h
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/replicant/Wasabi/ServiceManager.h
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/replicant/Wasabi/ServiceManager.h')
-rw-r--r--Src/replicant/Wasabi/ServiceManager.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/Src/replicant/Wasabi/ServiceManager.h b/Src/replicant/Wasabi/ServiceManager.h
new file mode 100644
index 00000000..efcf70df
--- /dev/null
+++ b/Src/replicant/Wasabi/ServiceManager.h
@@ -0,0 +1,52 @@
+#pragma once
+#include "foundation/guid.h"
+#include "service/api_service.h"
+#include "nu/AutoLock.h"
+#include "foundation/guid.h"
+#include <vector>
+#include <map>
+#include "service/ifc_servicefactory.h"
+#include "component/ifc_component_sync.h"
+#ifdef _WIN32
+#include <Windows.h>
+#else
+#include <semaphore.h>
+#endif
+
+class ServiceManager : public api_service, public ifc_component_sync
+{
+public:
+ ServiceManager();
+ ~ServiceManager();
+ int WASABICALL Dispatchable_QueryInterface(GUID interface_guid, void **object);
+
+ int WASABICALL Service_Register(ifc_serviceFactory *svc);
+ int WASABICALL Service_Unregister(ifc_serviceFactory *svc);
+ size_t WASABICALL Service_GetServiceCount(GUID svc_type);
+ ifc_serviceFactory *WASABICALL Service_EnumService(GUID svc_type, size_t n);
+ ifc_serviceFactory *WASABICALL Service_EnumService(size_t n);
+ ifc_serviceFactory *WASABICALL Service_GetServiceByGUID(GUID guid);
+ void WASABICALL Service_ComponentDone();
+
+private:
+ int WASABICALL ComponentSync_Wait(size_t count);
+ int GetServiceIndex(GUID key);
+
+private:
+ nu::LockGuard serviceGuard;
+ typedef std::map<GUID, ifc_serviceFactory*> ServiceMap;
+ ServiceMap services;
+ std::vector<GUID> services_indexer;
+
+ typedef std::vector<ifc_serviceFactory*> ServiceList;
+ std::map<GUID, ServiceList*> services_by_type;
+
+
+#ifdef _WIN32
+ HANDLE component_wait;
+#else
+ sem_t component_wait;
+#endif
+};
+
+extern ServiceManager service_manager;