XT-Audio
XtPlatform.hpp
Go to the documentation of this file.
1 #ifndef XT_API_PLATFORM_HPP
2 #define XT_API_PLATFORM_HPP
3 
6 #include <xt/cpp/Core.hpp>
7 #include <xt/cpp/Error.hpp>
8 #include <xt/api/Enums.hpp>
9 #include <xt/api/XtService.hpp>
10 
11 #include <vector>
12 #include <memory>
15 namespace Xt {
16 
17 using namespace Detail;
18 
19 class Platform final
20 {
22  friend class Audio;
24  XtPlatform* const _p;
25  Platform(XtPlatform* p): _p(p) { }
26 public:
27  ~Platform();
28  std::vector<System> GetSystems();
29  System SetupToSystem(Setup setup) const;
30  std::unique_ptr<Service> GetService(System system);
31 };
32 
33 inline
35 { Detail::HandleDestroy(XtPlatformDestroy, _p); }
36 
37 inline std::vector<System>
39 {
40  int32_t size = 0;
41  Detail::HandleAssert(XtPlatformGetSystems, _p, nullptr, &size);
42  std::vector<System> result(static_cast<size_t>(size));
43  auto coreSystems = reinterpret_cast<XtSystem*>(result.data());
44  Detail::HandleAssert(XtPlatformGetSystems, _p, coreSystems, &size);
45  return result;
46 }
47 
48 inline System
50 {
51  auto coreSetup = static_cast<XtSetup>(setup);
52  auto result = Detail::HandleAssert(XtPlatformSetupToSystem(_p, coreSetup));
53  return static_cast<System>(result);
54 }
55 
56 inline std::unique_ptr<Service>
58 {
59  auto coreSystem = static_cast<XtSystem>(system);
60  XtService const* service = Detail::HandleAssert(XtPlatformGetService(_p, coreSystem));
61  if(!service) return std::unique_ptr<Service>();
62  return std::unique_ptr<Service>(new Service(service));
63 }
64 
65 } // namespace Xt
66 #endif // XT_API_PLATFORM_HPP
std::vector< System > GetSystems()
Definition: XtPlatform.hpp:38
System SetupToSystem(Setup setup) const
Definition: XtPlatform.hpp:49
Definition: XtAudio.hpp:21
std::unique_ptr< Service > GetService(System system)
Definition: XtPlatform.hpp:57
Definition: XtPlatform.hpp:19
Definition: Callbacks.hpp:10
Setup
Definition: Enums.hpp:8
System
Definition: Enums.hpp:11
~Platform()
Definition: XtPlatform.hpp:34