rolmodl
C++ API for the Simple Directmedia Library 2 (SDL2)
Base.hpp
1 #pragma once
2 
3 #include <exception>
4 #include <optional>
5 
6 #include <SDL.h>
7 
8 #include "Geom.hpp"
9 
10 namespace rolmodl {
11  namespace sys {
12  enum class Id;
13 
14  const char* name() noexcept;
15  Id id() noexcept;
16 
17  unsigned int ram() noexcept;
18  unsigned int logicalCores() noexcept;
19 
20  namespace cpu {
21  unsigned int l1Size() noexcept;
22 
23  bool has3DNow() noexcept;
24  bool hasAVX() noexcept;
25  bool hasAVX2() noexcept;
26  bool hasAltiVec() noexcept;
27  bool hasMMX() noexcept;
28  bool hasRDTSC() noexcept;
29  bool hasSSE() noexcept;
30  bool hasSSE2() noexcept;
31  bool hasSSE3() noexcept;
32  bool hasSSE41() noexcept;
33  bool hasSSE42() noexcept;
34  }
35 
36  namespace pwr {
37  enum class State;
38  struct Status;
39  Status status() noexcept;
40  }
41  namespace clipboard {
42  bool hasText() noexcept;
43  // SDLString getText();
44  void setText(const char* x);
45  }
46  namespace screensaver {
47  void enable() noexcept;
48  void disable() noexcept;
49  bool enabled() noexcept;
50  }
51  namespace driver {
52  unsigned int count();
53  const char* name(const unsigned int i);
55  }
56 
57  namespace display::unsafe {
58  // Display byIndex(unsigned int i);
59  unsigned int count();
60  const char* name(const unsigned int i);
61  geom::RectWH bounds(const unsigned int i);
62  geom::RectWH usableBounds(const unsigned int i);
63  }
64  struct Display;
65 
66  namespace display::mode::unsafe {
67  unsigned int countForDisplayN(unsigned int n);
68 
69  // DisplayMode desktopForDisplayN(unsigned int n);
70  // DisplayMode currentForDisplayN(unsigned int n);
71  // DisplayMode forDisplayNByIndexI(unsigned int n, unsigned int i);
72  // DisplayMode closestForDisplayN(unsigned int n, const DisplayMode ideal);
73  }
74  struct DisplayMode;
75  }
76 
77  struct RGB;
78  struct RGBA;
79 
80  struct sdlexception;
81  namespace detail {
82  int throwOnErr(const int code);
83  }
84  class SDLString;
85 }
rolmodl::detail::throwOnErr
int throwOnErr(const int code)
Throw a rolmodl::sdlexception if code < 0.
Definition: Base.cpp:370
rolmodl::sys::cpu::l1Size
unsigned int l1Size() noexcept
Get the CPU L1 cache line size in bytes.
Definition: Base.cpp:81
exception
rolmodl::sys::name
const char * name() noexcept
Human-readable OS name. Use rolmodl::sys::id() for OS identification purposes instead of this method.
Definition: Base.cpp:9
rolmodl::sys::logicalCores
unsigned int logicalCores() noexcept
Get the number of available logical CPU cores.
Definition: Base.cpp:76
Geom.hpp
rolmodl::sys::screensaver::enable
void enable() noexcept
Enable system screensaver.
Definition: Base.cpp:177
rolmodl::sys::ram
unsigned int ram() noexcept
Get the amount of system RAM in MB.
Definition: Base.cpp:73
rolmodl::sys::display::unsafe::bounds
geom::RectWH bounds(const unsigned int i)
Get the resolution of the ith display. Unsafe because there is no bounds checking on the index.
Definition: Base.cpp:227
rolmodl::sys::display::unsafe::usableBounds
geom::RectWH usableBounds(const unsigned int i)
Get the bounds of the usable space of the ith display. Excludes system decorations such as the menu b...
Definition: Base.cpp:236
rolmodl::sys::pwr::State
State
Indicates battery status a.k.a. the system power state.
Definition: Base.hpp:138
rolmodl
Main namespace.
Definition: Base.cpp:7
rolmodl::sys::clipboard::hasText
bool hasText() noexcept
Query whether thhe clipboard has text contents.
Definition: Base.cpp:161
std::experimental::filesystem::status
T status(T... args)
rolmodl::sys::display::mode::unsafe::countForDisplayN
unsigned int countForDisplayN(unsigned int n)
Get the amount of display modes available for the nth display.
Definition: Base.cpp:284
std::count
T count(T... args)
rolmodl::sys::Id
Id
OS type enum.
Definition: Base.hpp:28
optional
rolmodl::sys::driver::current
std::optional< const char * > current() noexcept
Query the current video driver name.
Definition: Base.cpp:201