From 597ca5ad96ad77941067a226ed1ce18407a2f27f Mon Sep 17 00:00:00 2001 From: Sangwan Kwon Date: Thu, 20 Feb 2020 13:33:06 +0900 Subject: [PATCH] policy: Draft bluetooth virtual table Signed-off-by: Sangwan Kwon --- policy/bluetooth.md | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 policy/bluetooth.md diff --git a/policy/bluetooth.md b/policy/bluetooth.md new file mode 100644 index 0000000..15fa684 --- /dev/null +++ b/policy/bluetooth.md @@ -0,0 +1,63 @@ +# Bluetooth Policy Virtual Table + +| Table | Column | Type | Value | +|---|---|---|---| +| bluetooth | state | int | 0 = off , 1 = on | +| | desktop_connectivity | int | 0 = off , 1 = on | +| | tethering | int | 0 = off , 1 = on | +| | pairing | int | 0 = off , 1 = on | + +## Get bluetooth policies +```sql + SELECT * FROM bluetooth + SELECT state FROM bluetooth + SELECT desktop_connectivity FROM bluetooth + SELECT pairing FROM bluetooth + SELECT tethering FROM bluetooth +``` + +## Set bluetooth policies +```sql + UPDATE bluetooth SET state = 1 # on + UPDATE bluetooth SET desktop_connectivity = 0 # off + UPDATE bluetooth SET pairing = 1 # on + UPDATE bluetooth SET tethering = 0 # off + UPDATE bluetooth SET state = 1, pairing = 0 +``` + +# Query Builder +## Schema +```cpp + struct Bluetooth { + int state; + int desktopConnectivity; + int pairing; + int tethering; + + DECLARE_COLUMN(State, "state", &Bluetooth::state); + DECLARE_COLUMN(DesktopConnectivity, "desktop_connectivity", &Bluetooth::DesktopConnectivity); + DECLARE_COLUMN(Pairing, "pairing", &Bluetooth::pairing); + DECLARE_COLUMN(Tethering, "tethering", &Bluetooth::tethering); + }; + + DECLARE_TABLE(bluetoothTable, "bluetooth", Bluetooth::State, + Bluetooth::DesktopConnectivity, + Bluetooth::Pairing, + Bluetooth::Tethering); +``` + +## Generate type-safed query + +```cpp +// SELECT * FROM bluetooth + bluetoothTable.selectAll(); + +// SELECT state FROM bluetooth + bluetoothTable.selectAll(Bluetooth::State); + +// UPDATE bluetooth SET state = 1 + bluetoothTable.update(Bluetooth::State = 1); + +// UPDATE bluetooth SET state = 1, pairing = 0 + bluetoothTable.update(Bluetooth::State = 1, Bluetooth::Pairing = 0); +``` -- 2.7.4