Apply formatting to vist 78/234378/3
authorSangwan Kwon <sangwan.kwon@samsung.com>
Wed, 27 May 2020 06:05:23 +0000 (15:05 +0900)
committerSangwan Kwon <sangwan.kwon@samsung.com>
Wed, 27 May 2020 06:05:23 +0000 (15:05 +0900)
Change-Id: Ie315e0a1a6556277dd99f5c3ac9db8000932b415
Signed-off-by: Sangwan Kwon <sangwan.kwon@samsung.com>
66 files changed:
src/vist/archive.hpp
src/vist/client/query.cpp
src/vist/client/tests/virtual-table.cpp
src/vist/client/virtual-table.cpp
src/vist/client/virtual-table.hpp
src/vist/common/tests/process.cpp
src/vist/common/tests/string.cpp
src/vist/common/tests/thread-pool.cpp
src/vist/common/thread-pool.cpp
src/vist/database/column.cpp
src/vist/database/column.hpp
src/vist/database/connection.cpp
src/vist/database/tests/database.cpp
src/vist/exception.hpp
src/vist/index-sequence.hpp
src/vist/json/array.hpp
src/vist/json/json.hpp
src/vist/json/object.hpp
src/vist/json/tests/json.cpp
src/vist/json/util.hpp
src/vist/json/value.hpp
src/vist/klass/function.hpp
src/vist/klass/functor.hpp
src/vist/klass/tests/functor.cpp
src/vist/logger.hpp
src/vist/main/cli.cpp
src/vist/main/main.cpp
src/vist/main/tests.cpp
src/vist/notification/notification.cpp
src/vist/notification/tests/notification.cpp
src/vist/policy/db-schema.hpp
src/vist/policy/policy-loader.cpp
src/vist/policy/policy-manager.cpp
src/vist/policy/policy-storage.cpp
src/vist/policy/tests/core.cpp
src/vist/process.hpp
src/vist/query-builder/crud.hpp
src/vist/query-builder/database.hpp
src/vist/query-builder/expression.hpp
src/vist/query-builder/macro.hpp
src/vist/query-builder/table.hpp
src/vist/query-builder/tests/query-builder.cpp
src/vist/query-builder/tests/schema.hpp
src/vist/query-builder/util.hpp
src/vist/result.hpp
src/vist/rmi/gateway.cpp
src/vist/rmi/impl/mainloop.cpp
src/vist/rmi/impl/server.cpp
src/vist/rmi/impl/socket.hpp
src/vist/rmi/impl/tests/connection.cpp
src/vist/rmi/impl/tests/mainloop.cpp
src/vist/rmi/impl/tests/server-client.cpp
src/vist/rmi/message.cpp
src/vist/rmi/message.hpp
src/vist/rmi/remote.hpp
src/vist/schema/bluetooth.hpp
src/vist/schema/policy.hpp
src/vist/sdk/policy-model.hpp
src/vist/sdk/policy-provider.hpp
src/vist/sdk/tests/sdk.cpp
src/vist/service/vistd.cpp
src/vist/string.hpp
src/vist/table/bluetooth.cpp
src/vist/table/policy-admin.cpp
src/vist/table/policy.cpp
src/vist/timer.hpp

index 422ec65..b823112 100644 (file)
@@ -44,11 +44,11 @@ using IsArchival = typename std::enable_if<std::is_base_of<Archival, T>::value,
 class Archive final {
 public:
        template<typename Front, typename... Rest>
-       void pack(const Front& front, const Rest&... rest);
+       void pack(const Front& front, const Rest& ... rest);
        inline void pack(void) {}
 
        template<typename Front, typename... Rest>
-       void unpack(Front& front, Rest&... rest);
+       void unpack(Front& front, Rest& ... rest);
        inline void unpack(void) {}
 
        template<typename... Ts>
@@ -56,9 +56,9 @@ public:
 
        // serialize method
        template<typename T, IsFundamental<T> = 0>
-       Archive& operator<<(const T& value);
+       Archive & operator<<(const T& value);
        template<typename T, IsArchival<T> = 0>
-       Archive& operator<<(const T& object);
+       Archive & operator<<(const T& object);
        template<typename T>
        Archive& operator<<(const std::vector<T>& values);
        template<typename K, typename V>
@@ -72,9 +72,9 @@ public:
 
        // deserialize method
        template<typename T, IsFundamental<T> = 0>
-       Archive& operator>>(T& value);
+       Archive & operator>>(T& value);
        template<typename T, IsArchival<T> = 0>
-       Archive& operator>>(T& object);
+       Archive & operator>>(T& object);
        template<typename T>
        Archive& operator>>(std::vector<T>& values);
        template<typename K, typename V>
@@ -114,14 +114,14 @@ public:
 };
 
 template<typename Front, typename... Rest>
-void Archive::pack(const Front& front, const Rest&... rest)
+void Archive::pack(const Front& front, const Rest& ... rest)
 {
        *this << front;
        this->pack(rest...);
 }
 
 template<typename Front, typename... Rest>
-void Archive::unpack(Front& front, Rest&... rest)
+void Archive::unpack(Front& front, Rest& ... rest)
 {
        *this >> front;
        this->unpack(rest...);
index 2eedef2..6f5e79b 100644 (file)
@@ -20,7 +20,7 @@
 #include <vist/rmi/remote.hpp>
 
 namespace {
-       const std::string SOCK_ADDR = "/tmp/.vist";
+const std::string SOCK_ADDR = "/tmp/.vist";
 } // anonymous namespace
 
 namespace vist {
index 03fc974..25178e2 100644 (file)
@@ -30,7 +30,7 @@ TEST(VirtualTableTests, policy_int_table)
        VirtualTable<Policy<int>> table;
        EXPECT_TRUE(table.size() > 0);
 
-       for(const auto& row : table) {
+       for (const auto& row : table) {
                Policy<int> policy = { row[&Policy<int>::name], row[&Policy<int>::value] };
 
                INFO(VIST_CLIENT) << "[Test] Policy<int> table:";
@@ -55,7 +55,7 @@ TEST(VirtualTableTests, policy_str_table)
        VirtualTable<Policy<std::string>> table;
        EXPECT_TRUE(table.size() > 0);
 
-       for(const auto& row : table) {
+       for (const auto& row : table) {
                Policy<std::string> policy = {
                        row[&Policy<std::string>::name],
                        row[&Policy<std::string>::value]
index 02c58e7..5c9e3fe 100644 (file)
@@ -31,10 +31,10 @@ using namespace vist::tsqb;
 using namespace vist::schema;
 
 Table policyInt { "policy", Column("name", &Policy<int>::name),
-                                                       Column("value", &Policy<int>::value) };
+       Column("value", &Policy<int>::value) };
 
 Table policyStr { "policy", Column("name", &Policy<std::string>::name),
-                                                       Column("value", &Policy<std::string>::value) };
+       Column("value", &Policy<std::string>::value) };
 
 Database metaDB { "db", policyInt, policyStr };
 
index 6490941..608a330 100644 (file)
@@ -38,7 +38,10 @@ public:
        template<typename Struct, typename Member>
        Member operator[](Member Struct::*) const;
 
-       inline std::size_t size() const { return data.size(); }
+       inline std::size_t size() const
+       {
+               return data.size();
+       }
 
 private:
        KeyValuePair data;
@@ -53,12 +56,27 @@ public:
        using Iter = typename std::vector<VirtualRow<T>>::iterator;
        using CIter = typename std::vector<VirtualRow<T>>::const_iterator;
 
-       inline Iter begin() { return rows.begin(); }
-       inline CIter begin() const { return rows.cbegin(); }
-       inline Iter end() { return rows.end(); }
-       inline CIter end() const { return rows.end(); }
+       inline Iter begin()
+       {
+               return rows.begin();
+       }
+       inline CIter begin() const
+       {
+               return rows.cbegin();
+       }
+       inline Iter end()
+       {
+               return rows.end();
+       }
+       inline CIter end() const
+       {
+               return rows.end();
+       }
 
-       inline std::size_t size() const { return rows.size(); }
+       inline std::size_t size() const
+       {
+               return rows.size();
+       }
 
        template<typename Struct, typename Member>
        VirtualRow<T>& filter(Member Struct::*field, const std::string& name)
index a7b79d4..f186f71 100644 (file)
@@ -33,7 +33,7 @@ TEST(ProcessTests, path_negative)
        bool raised = false;
        try {
                Process::GetIdentifier(-1);
-       } catch(...) {
+       } catch (...) {
                raised = true;
        }
 
index 6cddefa..91979d3 100644 (file)
@@ -72,7 +72,7 @@ TEST(StringTests, strip)
        try {
                strip(origin, '[', ']');
                EXPECT_TRUE(false);
-       } catch(...) {
+       } catch (...) {
                EXPECT_TRUE(true);
        }
 }
index 22396da..44aa962 100644 (file)
@@ -27,7 +27,7 @@ using namespace vist;
 TEST(ThreadPoolTests, once)
 {
        int count = 0;
-       auto task = [&count]{ count++; };
+       auto task = [&count] { count++; };
 
        ThreadPool worker(5);
        worker.submit(task);
@@ -39,7 +39,7 @@ TEST(ThreadPoolTests, once)
 TEST(ThreadPoolTests, multiple)
 {
        int count = 0;
-       auto task = [&count]{ count++; };
+       auto task = [&count] { count++; };
 
        ThreadPool worker(5);
        std::size_t repeat = 10;
index b138aca..e241f46 100644 (file)
@@ -29,12 +29,13 @@ namespace vist {
 ThreadPool::ThreadPool(std::size_t threads)
 {
        for (std::size_t i = 0; i < threads; i++) {
-          workers.emplace_back([this] {
-                       while (true) {
+               workers.emplace_back([this] {
+                       while (true)
+                       {
                                std::function<void()> task;
 
                                __BEGIN_CRITICAL__
-                               condition.wait(lock, [this]{ return stop || !tasks.empty();});
+                               condition.wait(lock, [this] { return stop || !tasks.empty();});
                                if (stop && tasks.empty()) {
                                        return;
                                }
@@ -59,7 +60,7 @@ ThreadPool::~ThreadPool()
 
        condition.notify_all();
 
-       for (std::thread &worker: workers) {
+       for (std::thread& worker : workers) {
                if (worker.joinable()) {
                        worker.join();
                }
index 45e830b..98d169a 100644 (file)
@@ -45,7 +45,7 @@ double Column::getDouble() const
 
 const char* Column::getText() const
 {
-       return reinterpret_cast<const char *>(sqlite3_column_text(statement, index));
+       return reinterpret_cast<const char*>(sqlite3_column_text(statement, index));
 }
 
 const void* Column::getBlob() const
index 49b640e..3b559a7 100644 (file)
@@ -62,12 +62,12 @@ public:
                return getDouble();
        }
 
-       operator const char*() const
+       operator const char* () const
        {
                return getText();
        }
 
-       operator const void*() const
+       operator const void* () const
        {
                return getBlob();
        }
index 43289e6..8261c61 100644 (file)
@@ -32,11 +32,11 @@ Connection::Connection(const std::string& name, const int flags, bool integrityC
 
        if (integrityCheck) {
                bool verified = false;
-               sqlite3_stmt *integrity = NULL;
-               if (::sqlite3_prepare_v2(handle, "PRAGMA integrity_check;", -1, &integrity, NULL) == SQLITE_OK ) {
+               sqlite3_stmtintegrity = NULL;
+               if (::sqlite3_prepare_v2(handle, "PRAGMA integrity_check;", -1, &integrity, NULL) == SQLITE_OK) {
                        while (::sqlite3_step(integrity) == SQLITE_ROW) {
-                               const unsigned char *result = ::sqlite3_column_text(integrity, 0);
-                               if (result && ::strcmp((const char *)result, (const char *)"ok") == 0) {
+                               const unsigned charresult = ::sqlite3_column_text(integrity, 0);
+                               if (result && ::strcmp((const char*)result, (const char*)"ok") == 0) {
                                        verified = true;
                                        break;
                                }
index f3dc613..d06537d 100644 (file)
@@ -70,8 +70,8 @@ TEST(DatabaseTests, column_bind_index1)
 
        bool raised = false;
        try {
-               const char *str = "PACKAGE";
-               void *blob = (void *)str;
+               const charstr = "PACKAGE";
+               void* blob = (void*)str;
                double user = 5001;
                sqlite3_int64 used = 1;
                std::string key = "test key";
@@ -148,8 +148,8 @@ TEST(DatabaseTests, column_bind_name2)
        std::string query = "INSERT INTO CLIENT VALUES (NULL, :PKG, :KEY, :IS_USED, :USER)";
 
        try {
-               const char *str = "PACKAGE";
-               void *blob = (void *)str;
+               const charstr = "PACKAGE";
+               void* blob = (void*)str;
                double user = 5001;
                sqlite3_int64 used = 1;
                std::string key = "test key";
@@ -202,8 +202,7 @@ TEST(DatabaseTests, no_transaction)
        try {
                database::Connection db(TEST_DB_PATH);
                int loop = 500;
-               while (loop--)
-               {
+               while (loop--) {
                        database::Statement(db, query).exec();
                }
        } catch (const vist::Exception<ErrCode>& e) {
@@ -219,8 +218,7 @@ TEST(DatabaseTests, transaction)
                database::Connection db(TEST_DB_PATH);
                db.transactionBegin();
                int loop = 500;
-               while (loop--)
-               {
+               while (loop--) {
                        database::Statement(db, query).exec();
                }
                db.transactionEnd();
@@ -237,8 +235,7 @@ TEST(DatabaseTests, transaction_RAW_STRING)
                database::Connection db(TEST_DB_PATH);
                db.exec("BEGIN TRANSACTION;");
                int loop = 500;
-               while (loop--)
-               {
+               while (loop--) {
                        database::Statement(db, query).exec();
                }
                db.exec("END TRANSACTION;");
index e443136..171dc0f 100644 (file)
@@ -67,8 +67,8 @@ public:
 
        using Self = Exception<ErrCode>;
 
-       Exception(ErrCode ec, const char *file,
-                         const char *function, unsigned int line) noexcept : ec(ec)
+       Exception(ErrCode ec, const charfile,
+                         const charfunction, unsigned int line) noexcept : ec(ec)
        {
                std::stringstream ss;
                ss << "[" << file << ":" << line << " " << function << "()]"
index 170c2c9..0ef14f2 100644 (file)
@@ -33,13 +33,17 @@ struct IndexSequence {};
 namespace {
 
 template<std::size_t N, std::size_t... S>
-struct SequenceExpansion : SequenceExpansion<N-1, N-1, S...> {};
+struct SequenceExpansion : SequenceExpansion < N - 1, N - 1, S... > {};
 
 template<std::size_t... S>
-struct SequenceExpansion<0, S...> { using Type = IndexSequence<S...>; };
+struct SequenceExpansion<0, S...> {
+       using Type = IndexSequence<S...>;
+};
 
 template<>
-struct SequenceExpansion<0> { using Type = EmptySequence; };
+struct SequenceExpansion<0> {
+       using Type = EmptySequence;
+};
 
 } // anonymous namespace
 
index 63beb1e..075df4a 100644 (file)
@@ -31,11 +31,11 @@ struct Array : public Value {
        void push(const Type& data)
        {
                auto value = std::make_shared<Value>();
-               if constexpr (std::is_same_v<Type, Array> || std::is_same_v<Type, Object>) {
+               if constexpr(std::is_same_v<Type, Array> || std::is_same_v<Type, Object>) {
                        auto real = std::make_shared<Type>();
                        *real = data;
                        value->leaf = real;
-               } else if constexpr (std::is_same_v<Type, Null>) {
+               } else if constexpr(std::is_same_v<Type, Null>) {
                        value->leaf = std::make_shared<Null>();
                } else {
                        *value = data;
index 78483ef..1c87025 100644 (file)
@@ -16,7 +16,7 @@
 /*
  * Usable JSON header-only library.
  *   - Applied design pattern: Composite pattern
- *     - Component structure: Value 
+ *     - Component structure: Value
  *     - Leaf structure: Int, String, Bool, Null
  *     - Composite structure: Array, Object
  */
@@ -26,7 +26,7 @@
  *     Json json;
  *     json["name"] = "sangwan";
  *     json["age"] = 99;
- *     
+ *
  *     // Get json value
  *     std::string name = json["name"];
  *     int age = json["age"];
@@ -70,9 +70,9 @@ struct Json {
        {
                auto value = std::make_shared<Value>();
                auto composite = std::make_shared<CompositeType>();
-               if constexpr (std::is_same_v<CompositeType, Array>)
+               if constexpr(std::is_same_v<CompositeType, Array>)
                        composite->buffer = std::move(child.buffer);
-               else if constexpr (std::is_same_v<CompositeType, Object>)
+               else if constexpr(std::is_same_v<CompositeType, Object>)
                        composite->pairs = std::move(child.pairs);
                else
                        static_assert(dependent_false<CompositeType>::value, "Only Composite type supported.");
index 54d90ef..2e3fe92 100644 (file)
@@ -61,8 +61,8 @@ struct Object : public Value {
                if (!this->exist(key))
                        throw std::runtime_error("Not exist key.");
 
-               if constexpr (std::is_same_v<CompositeType, Array> ||
-                                         std::is_same_v<CompositeType, Object>) {
+               if constexpr(std::is_same_v<CompositeType, Array> ||
+                                        std::is_same_v<CompositeType, Object>) {
                        if (auto downcast = std::dynamic_pointer_cast<CompositeType>(this->pairs[key]->leaf);
                                downcast == nullptr)
                                throw std::runtime_error(key + "Mismatched type.");
index 4aaeb20..31365f1 100644 (file)
@@ -79,7 +79,7 @@ TEST(JsonTests, int_type_mismatch)
        try {
                static_cast<std::string>(json["int"]);
                EXPECT_TRUE(false);
-       } catch(...) {
+       } catch (...) {
                EXPECT_TRUE(true);
        }
 }
@@ -110,7 +110,7 @@ TEST(JsonTests, string_type_mismatch)
        try {
                static_cast<int>(json["string"]);
                EXPECT_TRUE(false);
-       } catch(...) {
+       } catch (...) {
                EXPECT_TRUE(true);
        }
 }
@@ -262,8 +262,8 @@ TEST(JsonTests, osquery_format)
                document.push("constraints", constraints);
 
                EXPECT_EQ(document.serialize(), "{ \"constraints\": [ { \"affinity\": \"TEXT\", "
-                                                                               "\"name\": \"test_int\", "
-                                                                               "\"list\": [ { \"expr\": \"2\", \"op\": 2 } ] } ] }");
+                                 "\"name\": \"test_int\", "
+                                 "\"list\": [ { \"expr\": \"2\", \"op\": 2 } ] } ] }");
        }
 
        {
@@ -306,9 +306,9 @@ TEST(JsonTests, serialize)
        //             "string": "root value" }
        auto serialized = json.serialize();
        EXPECT_EQ(serialized, "{ \"array\": [ 3, \"array value\" ], "
-                                                 "\"object\": { \"string\": \"child value\", \"int\": 2 }, "
-                                                 "\"int\": 1, "
-                                                 "\"string\": \"root value\" }");
+                         "\"object\": { \"string\": \"child value\", \"int\": 2 }, "
+                         "\"int\": 1, "
+                         "\"string\": \"root value\" }");
 
        Json restore;
        restore.deserialize(serialized);
index 97df9a9..38c9403 100644 (file)
@@ -27,7 +27,7 @@ namespace json {
 inline std::vector<std::string> canonicalize(std::vector<std::string>& tokens)
 {
        std::vector<std::string> result;
-       auto rearrange = [&](std::vector<std::string>::iterator& iter, char first, char last) {
+       auto rearrange = [&](std::vector<std::string>::iterator & iter, char first, char last) {
                if ((*iter).find(first) == std::string::npos)
                        return false;
 
index 838adb6..9e28106 100644 (file)
@@ -55,18 +55,28 @@ struct Value {
                        throw std::invalid_argument("Dumped value cannot empty.");
 
                switch (dumped[0]) {
-                       case '{' : this->convert<Object>(); break;
-                       case '[' : this->convert<Array>(); break;
-                       case '"': this->convert<String>(); break;
-                       case 'n': this->convert<Null>(); break;
-                       case 't': // fall through
-                       case 'f' : this->convert<Bool>(); break;
-                       default : {
-                               if (dumped.find(".") == std::string::npos)
-                                       this->convert<Int>();
-                               else
-                                       this->convert<Double>();
-                       }
+               case '{' :
+                       this->convert<Object>();
+                       break;
+               case '[' :
+                       this->convert<Array>();
+                       break;
+               case '"':
+                       this->convert<String>();
+                       break;
+               case 'n':
+                       this->convert<Null>();
+                       break;
+               case 't': // fall through
+               case 'f' :
+                       this->convert<Bool>();
+                       break;
+               default : {
+                       if (dumped.find(".") == std::string::npos)
+                               this->convert<Int>();
+                       else
+                               this->convert<Double>();
+               }
                }
 
                this->leaf->deserialize(dumped);
@@ -75,16 +85,16 @@ struct Value {
        template <typename Type>
        Value& operator=(const Type& data)
        {
-               if constexpr (std::is_same_v<Type, int>)
+               if constexpr(std::is_same_v<Type, int>)
                        this->leaf = std::make_shared<Int>(data);
-               else if constexpr (std::is_same_v<Type, double>)
+               else if constexpr(std::is_same_v<Type, double>)
                        this->leaf = std::make_shared<Double>(data);
-               else if constexpr (std::is_same_v<typename std::decay<Type>::type, std::string> ||
-                                                  std::is_same_v<typename std::decay<Type>::type, char*>)
+               else if constexpr(std::is_same_v<typename std::decay<Type>::type, std::string> ||
+                                                 std::is_same_v<typename std::decay<Type>::type, char*>)
                        this->leaf = std::make_shared<String>(data);
-               else if constexpr (std::is_same_v<Type, bool>)
+               else if constexpr(std::is_same_v<Type, bool>)
                        this->leaf = std::make_shared<Bool>(data);
-               else if constexpr (std::is_same_v<Type, std::nullptr_t>)
+               else if constexpr(std::is_same_v<Type, std::nullptr_t>)
                        this->leaf = std::make_shared<Null>();
                else
                        static_assert(dependent_false<Type>::value, "Not supported type.");
@@ -195,7 +205,7 @@ struct String : public Value {
                if (dumped[0] != '"' || dumped[dumped.size() - 1] != '"')
                        throw std::invalid_argument("Wrong format.");
 
-               this->data = dumped.substr(1, dumped.size() -2);
+               this->data = dumped.substr(1, dumped.size() - 2);
        }
 
        operator std::string() override
index db6b35b..9a30891 100644 (file)
@@ -39,7 +39,7 @@ public:
        using Klass = K;
        using Return = R;
        using Parameters = std::tuple<remove_cv_ref_t<Ps>...>;
-       using Pointer = Return (Klass::*)(Ps...);
+       using Pointer = Return(Klass::*)(Ps...);
 
        auto get(void) noexcept -> const Pointer&;
 
@@ -47,7 +47,7 @@ private:
        explicit Function(Pointer pointer);
 
        template<typename RR, typename KK, typename... PPs>
-       friend Function<RR, KK, PPs...> make_function(RR (KK::* member)(PPs...));
+       friend Function<RR, KK, PPs...> make_function(RR(KK::* member)(PPs...));
 
        Pointer pointer;
 };
@@ -64,7 +64,7 @@ auto Function<R, K, Ps...>::get(void) noexcept -> const Pointer&
 }
 
 template<typename R, typename K, typename... Ps>
-Function<R, K, Ps...> make_function(R (K::* member)(Ps...))
+Function<R, K, Ps...> make_function(R(K::* member)(Ps...))
 {
        constexpr bool notVoid = !(std::is_same<R, void>::value);
        static_assert(notVoid, "Return type cannot be void.");
index 67be7b3..7a2f156 100644 (file)
@@ -34,7 +34,7 @@ namespace klass {
 
 struct AbstractFunctor {
        template<typename R, typename...Args>
-       R invoke(Args&&... args);
+       R invoke(Args&& ... args);
        inline Archive invoke(Archive& archive);
 
 protected:
@@ -53,7 +53,7 @@ public:
        explicit Functor(Klass& instance, MemFunc memFunc);
 
        template<typename... Args>
-       auto operator()(Args&&... args) -> typename MemFunc::Return;
+       auto operator()(Args&& ... args) -> typename MemFunc::Return;
        inline auto operator()(Archive& archive) -> typename MemFunc::Return;
 
 protected:
@@ -70,7 +70,7 @@ private:
 };
 
 template<typename R, typename...Args>
-R AbstractFunctor::invoke(Args&&... args)
+R AbstractFunctor::invoke(Args&& ... args)
 {
        Archive parameters;
        parameters.pack(std::forward<Args>(args)...);
@@ -94,7 +94,7 @@ Functor<R, K, Ps...>::Functor(Klass& instance, MemFunc memFunc)
 
 template<typename R, typename K, typename... Ps>
 template<typename... Args>
-auto Functor<R, K, Ps...>::operator()(Args&&... args) -> typename MemFunc::Return
+auto Functor<R, K, Ps...>::operator()(Args&& ... args) -> typename MemFunc::Return
 {
        const Invokable& invokable = this->memFunc.get();
        return invokable(this->instance, std::forward<Args>(args)...);
@@ -136,14 +136,14 @@ auto Functor<R, K, Ps...>::operator()(T& tuple,
 }
 
 template<typename R, typename K, typename... Ps>
-Functor<R, K, Ps...> make_functor(K& instance, R (K::* member)(Ps...))
+Functor<R, K, Ps...> make_functor(K& instance, R(K::* member)(Ps...))
 {
        return Functor<R, K, Ps...>(instance, make_function(member));
 }
 
 template<typename R, typename K, typename... Ps>
 std::shared_ptr<Functor<R, K, Ps...>> make_functor_ptr(K& instance,
-                                                                                                          R (K::* member)(Ps...))
+                                                                                                          R(K::* member)(Ps...))
 {
        return std::make_shared<Functor<R, K, Ps...>>(instance, make_function(member));
 }
index c425c4d..674d6e3 100644 (file)
@@ -43,7 +43,7 @@ struct Foo {
                return false;
        }
 
-//     void impossible(void) {}
+       //  void impossible(void) {}
 
        std::string name;
 };
@@ -54,7 +54,7 @@ TEST(FunctorTests, functor)
        auto fooSetName = make_functor(foo, &Foo::setName);
        auto fooGetName = make_functor(foo, &Foo::getName);
        auto fooEcho = make_functor(foo, &Foo::echo);
-//     auto fooImp = make_functor(foo, &Foo::impossible);
+       //  auto fooImp = make_functor(foo, &Foo::impossible);
 
        std::string input = "Foo name";
        bool ret = true;
index 137701e..51023a6 100644 (file)
@@ -179,7 +179,7 @@ private:
 
 #ifndef __FILENAME__
 #define __FILENAME__ \
-(::strrchr(__FILE__, '/') ? ::strrchr(__FILE__, '/') + 1 : __FILE__)
+       (::strrchr(__FILE__, '/') ? ::strrchr(__FILE__, '/') + 1 : __FILE__)
 #endif
 
 #define LOG(level, tag) vist::LogStream(LOGCAT(vist::LogLevel::level, #tag))
index e3d80a4..44bbc06 100644 (file)
@@ -27,7 +27,8 @@ using namespace vist;
 
 DEFINE_string(query, "", "Query statement to execute.");
 
-int main(int argc, char *argv[]) try {
+int main(int argc, char* argv[]) try
+{
        gflags::SetUsageMessage("ViST default admin program.");
        gflags::ParseCommandLineFlags(&argc, &argv, true);
 
@@ -46,10 +47,12 @@ int main(int argc, char *argv[]) try {
                std::cout << "Total " << rows.size() << "-rows." << std::endl;
        }
        return EXIT_SUCCESS;
-} catch(const Exception<ErrCode>& e) {
+} catch (const Exception<ErrCode>& e)
+{
        std::cout << "Failed message: " << e.what() << std::endl;
        return EXIT_FAILURE;
-} catch(const std::exception& e) {
+} catch (const std::exception& e)
+{
        std::cout << "Failed message: " << e.what() << std::endl;
        return EXIT_FAILURE;
 }
index 3ceb010..fe6cd50 100644 (file)
@@ -27,7 +27,8 @@
 
 using namespace vist;
 
-int main() try {
+int main() try
+{
 #ifdef TIZEN
        LogStream::Init(std::make_shared<Dlog>());
 #endif
@@ -35,10 +36,12 @@ int main() try {
        Vistd::Instance().Start();
 
        return EXIT_SUCCESS;
-} catch(const Exception<ErrCode>& e) {
+} catch (const Exception<ErrCode>& e)
+{
        ERROR(VIST) << "Failed while daemon is running." << e.what();
        return EXIT_FAILURE;
-} catch(const std::exception& e) {
+} catch (const std::exception& e)
+{
        ERROR(VIST) << "Failed while daemon is running." << e.what();
        return EXIT_FAILURE;
 }
index 0fcfc89..52b2386 100644 (file)
@@ -16,7 +16,8 @@
 
 #include <gtest/gtest.h>
 
-int main(int argc, char* argv[]) {
+int main(int argc, char* argv[])
+{
        testing::InitGoogleTest(&argc, argv);
        return RUN_ALL_TESTS();
 }
index e87a067..b6b001f 100644 (file)
@@ -21,7 +21,7 @@
 #include <vist/logger.hpp>
 
 namespace {
-       std::mutex mutex;
+std::mutex mutex;
 } // anonymous namespace
 
 namespace vist {
index 94f30ce..e703567 100644 (file)
@@ -27,7 +27,7 @@ TEST_F(NotificationTests, test_add_positive)
 {
        auto& notifier = Notification::instance();
 
-       auto callback = [](const Row& row) {
+       auto callback = [](const Row & row) {
                INFO(VIST) << "NotifyCallback called:";
                for (const auto& r : row)
                        INFO(VIST) << "\t" << r.first << " : " << r.second;
@@ -41,7 +41,7 @@ TEST_F(NotificationTests, test_add_negative)
 {
        auto& notifier = Notification::instance();
 
-       auto callback = [](const Row& row) {
+       auto callback = [](const Row & row) {
                INFO(VIST) << "NotifyCallback called:";
                for (const auto& r : row)
                        INFO(VIST) << "\t" << r.first << " : " << r.second;
@@ -56,7 +56,7 @@ TEST_F(NotificationTests, test_emit_positive)
        auto& notifier = Notification::instance();
 
        int called = 0;
-       auto callback = [&](const Row& row) {
+       auto callback = [&](const Row & row) {
                INFO(VIST) << "NotifyCallback called:";
                for (const auto& r : row)
                        INFO(VIST) << "\t" << r.first << " : " << r.second;
index 883d28c..869fb12 100644 (file)
@@ -54,10 +54,10 @@ struct PolicyDefinition {
 
 DECLARE_TABLE(AdminTable, "ADMIN", Admin::Name, Admin::Activated);
 DECLARE_TABLE(PolicyManagedTable, "POLICY_MANAGED", PolicyManaged::Admin,
-                                                                                                       PolicyManaged::Policy,
-                                                                                                       PolicyManaged::Value);
+                         PolicyManaged::Policy,
+                         PolicyManaged::Value);
 DECLARE_TABLE(PolicyDefinitionTable, "POLICY_DEFINITION", PolicyDefinition::Name,
-                                                                                                                 PolicyDefinition::Ivalue);
+                         PolicyDefinition::Ivalue);
 
 } // namespace schema
 } // namespace policy
index d8d5385..d6c621b 100644 (file)
@@ -38,9 +38,9 @@ PolicyProvider* PolicyLoader::load(const std::string& path)
 
 PluginLoader::PluginLoader(const std::string& path, int flag)
        : handle(::dlopen(path.c_str(), flag), [](void*)->int{return 0;})
-// Cleaning object after dlclose() makes SEGFAULT.
-// TODO: Sync dynamic loading's life-cycle with program.(PluginManager)
-//     : handle(::dlopen(path.c_str(), flag), ::dlclose)
+         // Cleaning object after dlclose() makes SEGFAULT.
+         // TODO: Sync dynamic loading's life-cycle with program.(PluginManager)
+         //  : handle(::dlopen(path.c_str(), flag), ::dlclose)
 {
        if (handle == nullptr)
                THROW(ErrCode::LogicError) << "Failed to open: " << path;
index 89315bc..7a63afb 100644 (file)
@@ -151,9 +151,9 @@ const std::shared_ptr<PolicyModel>& PolicyManager::getPolicy(const std::string&
 
        auto provider = this->policies[name];
        auto iter = std::find_if(this->providers.begin(), this->providers.end(),
-                                                        [&provider](const std::unique_ptr<PolicyProvider>& p) {
-                                                                return p->getName() == provider;
-                                                        });
+       [&provider](const std::unique_ptr<PolicyProvider>& p) {
+               return p->getName() == provider;
+       });
        if (iter == this->providers.end())
                THROW(ErrCode::RuntimeError) << "Not exist provider[" << provider
                                                                         << "] about policy: " << name;
index ac44bf9..5e52ce0 100644 (file)
@@ -144,7 +144,7 @@ void PolicyStorage::enroll(const std::string& name)
        }
 
        /// Make admin deactivated as default.
-       Admin admin = {name , 0};
+       Admin admin = {name, 0};
 
        std::string query = schema::AdminTable.insert(Admin::Name = admin.name,
                                                                                                  Admin::Activated = admin.activated);
@@ -191,13 +191,13 @@ void PolicyStorage::activate(const std::string& admin, bool state)
 
        DEBUG(VIST) << "Activate admin: " << admin;
        std::string query = schema::AdminTable.update(Admin::Activated = static_cast<int>(state))
-                                                                                 .where(Admin::Name == admin);
+                                               .where(Admin::Name == admin);
        database::Statement stmt(*this->database, query);
        if (!stmt.exec())
                THROW(ErrCode::RuntimeError) << stmt.getErrorMessage();
 
        this->admins[admin].activated = state;
-       INFO(VIST) << "Admin[" << admin << "]'s activated value is set: " << state; 
+       INFO(VIST) << "Admin[" << admin << "]'s activated value is set: " << state;
 }
 
 bool PolicyStorage::isActivated(const std::string& admin)
@@ -231,8 +231,8 @@ void PolicyStorage::update(const std::string& admin,
                THROW(ErrCode::LogicError) << "Not exist policy: " << policy;
 
        std::string query = schema::PolicyManagedTable.update(PolicyManaged::Value = value.dump())
-                                                                                                 .where(PolicyManaged::Admin == admin &&
-                                                                                                                PolicyManaged::Policy == policy);
+                                               .where(PolicyManaged::Admin == admin &&
+                                                          PolicyManaged::Policy == policy);
        database::Statement stmt(*this->database, query);
        if (!stmt.exec())
                THROW(ErrCode::RuntimeError) << stmt.getErrorMessage();
index 57e9fee..083ea95 100644 (file)
 namespace vist {
 namespace policy {
 
-TEST(PolicyCoreTests, policy_loader) {
+TEST(PolicyCoreTests, policy_loader)
+{
        auto& manager = PolicyManager::Instance();
 
        EXPECT_TRUE(manager.providers.size() > 0);
        EXPECT_TRUE(manager.policies.size() > 0);
 }
 
-TEST(PolicyCoreTests, policy_set_get_int) {
+TEST(PolicyCoreTests, policy_set_get_int)
+{
        auto& manager = PolicyManager::Instance();
        manager.enroll("testAdmin");
        manager.set("sample-int-policy", PolicyValue(5), "testAdmin");
@@ -48,7 +50,8 @@ TEST(PolicyCoreTests, policy_set_get_int) {
        manager.disenroll("testAdmin1");
 }
 
-TEST(PolicyCoreTests, policy_set_get_str) {
+TEST(PolicyCoreTests, policy_set_get_str)
+{
        auto& manager = PolicyManager::Instance();
        manager.enroll("testAdmin");
        manager.set("sample-str-policy", PolicyValue("AAA"), "testAdmin");
@@ -67,13 +70,15 @@ TEST(PolicyCoreTests, policy_set_get_str) {
        manager.disenroll("testAdmin1");
 }
 
-TEST(PolicyCoreTests, policy_get_all) {
+TEST(PolicyCoreTests, policy_get_all)
+{
        auto& manager = PolicyManager::Instance();
        auto policies = manager.getAll();
        EXPECT_TRUE(policies.size() > 0);
 }
 
-TEST(PolicyCoreTests, policy_get_policy) {
+TEST(PolicyCoreTests, policy_get_policy)
+{
        auto& manager = PolicyManager::Instance();
        const auto& policy = manager.getPolicy("sample-int-policy");
        EXPECT_EQ(policy->getName(), "sample-int-policy");
@@ -87,7 +92,8 @@ TEST(PolicyCoreTests, policy_get_policy) {
        EXPECT_TRUE(raised);
 }
 
-TEST(PolicyCoreTests, admin) {
+TEST(PolicyCoreTests, admin)
+{
        auto& manager = PolicyManager::Instance();
        manager.enroll("testAdmin");
 
@@ -109,7 +115,8 @@ TEST(PolicyCoreTests, admin) {
        manager.disenroll("testAdmin");
 }
 
-TEST(PolicyCoreTests, is_activated) {
+TEST(PolicyCoreTests, is_activated)
+{
        auto& manager = PolicyManager::Instance();
        manager.enroll("testAdmin1");
        manager.enroll("testAdmin2");
index ff7548d..65676d4 100644 (file)
@@ -64,14 +64,20 @@ struct Process {
 private:
        static std::string canonicalize(std::string&& s)
        {
-               { /// rtrim
-                       auto predicate = [](unsigned char c){ return std::isspace(c) || c == '\0'; };
+               {
+                       /// rtrim
+                       auto predicate = [](unsigned char c) {
+                               return std::isspace(c) || c == '\0';
+                       };
                        auto base = std::find_if(s.begin(), s.end(), predicate);
                        s.erase(base, s.end());
                }
 
-               { /// ltrim
-                       auto predicate = [](unsigned char c){ return c == '/'; };
+               {
+                       /// ltrim
+                       auto predicate = [](unsigned char c) {
+                               return c == '/';
+                       };
                        auto base = std::find_if(s.rbegin(), s.rend(), predicate).base();
                        s.erase(s.begin(), base);
                }
index 3895aca..e930c30 100644 (file)
@@ -30,7 +30,7 @@ template<typename T>
 class Crud {
 public:
        template<typename... ColumnTypes>
-       T& select(ColumnTypes&&... cts);
+       T& select(ColumnTypes&& ... cts);
 
        template<typename TableType>
        T& selectAll(void);
@@ -38,23 +38,23 @@ public:
        T& selectAll(void);
 
        template<typename... AssginExpressions>
-       T& update(AssginExpressions&&... expression);
+       T& update(AssginExpressions&& ... expression);
 
        template<typename... ColumnTypes>
-       T& insert(ColumnTypes&&... cts);
+       T& insert(ColumnTypes&& ... cts);
 
        template<typename... ColumnTypes>
-       T& remove(ColumnTypes&&... cts);
+       T& remove(ColumnTypes&& ... cts);
 
        template<typename Expr>
        T& where(Expr expr);
 
 private:
        template<typename L, typename R>
-       std::string processWhere(And<L,R>& expr);
+       std::string processWhere(And<L, R>& expr);
 
        template<typename L, typename R>
-       std::string processWhere(Or<L,R>& expr);
+       std::string processWhere(Or<L, R>& expr);
 
        template<typename Expr>
        std::string processWhere(const Expr& expr);
@@ -62,7 +62,7 @@ private:
 
 template<typename T>
 template<typename... ColumnTypes>
-T& Crud<T>::select(ColumnTypes&&... cts)
+T& Crud<T>::select(ColumnTypes&& ... cts)
 {
        static_cast<T*>(this)->cache.clear();
 
@@ -125,7 +125,7 @@ T& Crud<T>::selectAll(void)
 
 template<typename T>
 template<typename... AssginExpressions>
-T& Crud<T>::update(AssginExpressions&&... expression)
+T& Crud<T>::update(AssginExpressions&& ... expression)
 {
        static_cast<T*>(this)->cache.clear();
 
@@ -133,12 +133,12 @@ T& Crud<T>::update(AssginExpressions&&... expression)
        ss << "UPDATE " << static_cast<T*>(this)->name << " ";
        ss << "SET ";
 
-       auto closure = [&ss, this](const auto&... iter) {
+       auto closure = [&ss, this](const auto & ... iter) {
                (static_cast<void>( /// Make fold expression possible
-                       (ss << static_cast<T*>(this)->getColumnName(iter.l) /// Column name
-                               << " " << static_cast<std::string>(iter) << " " /// Assign operator
-                               << iter.r << ", ") /// Value
-               ), ...); /// Process fold expression
+                        (ss << static_cast<T*>(this)->getColumnName(iter.l) /// Column name
+                         << " " << static_cast<std::string>(iter) << " " /// Assign operator
+                         << iter.r << ", ") /// Value
+                ), ...); /// Process fold expression
        };
        std::apply(closure, std::tuple(expression...));
 
@@ -153,19 +153,19 @@ T& Crud<T>::update(AssginExpressions&&... expression)
 
 template<typename T>
 template<typename... ColumnTypes>
-T& Crud<T>::insert(ColumnTypes&&... expression)
+T& Crud<T>::insert(ColumnTypes&& ... expression)
 {
        static_cast<T*>(this)->cache.clear();
 
        std::string query;
-       { 
+       {
                std::stringstream ss;
                ss << "INSERT INTO " << static_cast<T*>(this)->name << " (";
 
-               auto onColumn = [&ss, this](const auto&... iter) {
+               auto onColumn = [&ss, this](const auto & ... iter) {
                        (static_cast<void>( /// Make fold expression possible
-                               (ss << static_cast<T*>(this)->getColumnName(iter.l) << ", ") /// Column name
-                       ), ...); /// Process fold expression
+                                (ss << static_cast<T*>(this)->getColumnName(iter.l) << ", ") /// Column name
+                        ), ...); /// Process fold expression
                };
                std::apply(onColumn, std::tuple(expression...));
 
@@ -179,7 +179,7 @@ T& Crud<T>::insert(ColumnTypes&&... expression)
 
        {
                std::stringstream ss;
-               auto onValue = [&ss](const auto&... iter) {
+               auto onValue = [&ss](const auto & ... iter) {
                        (static_cast<void>((ss << iter.r) << ", "), ...); /// Process fold expression
                };
                std::apply(onValue, std::tuple(expression...));
@@ -199,7 +199,7 @@ T& Crud<T>::insert(ColumnTypes&&... expression)
 
 template<typename T>
 template<typename... ColumnTypes>
-T& Crud<T>::remove(ColumnTypes&&... cts)
+T& Crud<T>::remove(ColumnTypes&& ... cts)
 {
        static_cast<T*>(this)->cache.clear();
 
@@ -227,7 +227,7 @@ T& Crud<T>::where(Expr expr)
 
 template<typename T>
 template<typename L, typename R>
-std::string Crud<T>::processWhere(And<L,R>& expr)
+std::string Crud<T>::processWhere(And<L, R>& expr)
 {
        std::stringstream ss;
        ss << this->processWhere(expr.l) << " ";
@@ -239,7 +239,7 @@ std::string Crud<T>::processWhere(And<L,R>& expr)
 
 template<typename T>
 template<typename L, typename R>
-std::string Crud<T>::processWhere(Or<L,R>& expr)
+std::string Crud<T>::processWhere(Or<L, R>& expr)
 {
        std::stringstream ss;
        ss << this->processWhere(expr.l) << " ";
index f9e5466..4ec629a 100644 (file)
@@ -50,7 +50,7 @@ public: // CRTP(Curiously Recurring Template Pattern) for CRUD
        std::vector<std::string> getTableNames(Cs&& ...columns) const noexcept;
        template<typename Table>
        std::string getTableName(Table&& table) const noexcept;
-       template<typename... Cs> 
+       template<typename... Cs>
        std::vector<std::string> getColumnNames(Cs&& ...columns) const noexcept;
        template<typename Column>
        std::string getColumnName(Column&& column) const noexcept;
@@ -78,15 +78,15 @@ std::vector<std::string> Database<Tables...>::getTableNames(Cs&& ...columns) con
 {
        std::set<std::string> names;
 
-       auto predicate = [this, &names](const auto& column) {
+       auto predicate = [this, &names](const auto & column) {
                using ColumnType = std::remove_reference_t<decltype(column)>;
                using TableType = typename ColumnType::Table;
                auto name = this->getTableName(TableType());
                if (!name.empty())
-                               names.emplace(name);
+                       names.emplace(name);
        };
 
-       auto closure = [&predicate](const auto&... iter) {
+       auto closure = [&predicate](const auto & ... iter) {
                (predicate(iter), ...);
        };
 
@@ -100,13 +100,13 @@ template<typename... Cs>
 std::vector<std::string> Database<Tables...>::getColumnNames(Cs&& ...columns) const noexcept
 {
        std::vector<std::string> names;
-       auto predicate = [this, &names](const auto& column) {
+       auto predicate = [this, &names](const auto & column) {
                auto name = this->getColumnName(column);
                if (!name.empty())
                        names.emplace_back(name);
        };
 
-       auto closure = [&predicate](const auto&... iter) {
+       auto closure = [&predicate](const auto & ... iter) {
                (predicate(iter), ...);
        };
 
@@ -120,12 +120,12 @@ template<typename Table>
 std::string Database<Tables...>::getTableName(Table&& table) const noexcept
 {
        std::string name;
-       auto predicate = [&name, &table](const auto& type) {
+       auto predicate = [&name, &table](const auto & type) {
                if (type.compare(table))
                        name = type.name;
        };
 
-       auto closure = [&predicate](const auto&... iter) {
+       auto closure = [&predicate](const auto & ... iter) {
                (predicate(iter), ...);
        };
 
@@ -143,14 +143,14 @@ std::string Database<Tables...>::getColumnName(Column&& column) const noexcept
        TableType table;
 
        std::string name;
-       auto predicate = [&name, &table, &column](const auto& iter) {
+       auto predicate = [&name, &table, &column](const auto & iter) {
                if (iter.compare(table)) {
                        auto cname = iter.getColumnName(column);
                        name = iter.name + "." + cname;
                }
        };
 
-       auto closure = [&predicate](const auto&... iter) {
+       auto closure = [&predicate](const auto & ... iter) {
                (predicate(iter), ...);
        };
 
index eb6526d..cb83a0a 100644 (file)
@@ -133,19 +133,19 @@ struct Or  : public Binary<L, R> {
        }
 };
 
-template<typename L,
-                typename R,
-                typename = typename std::enable_if_t<is_expression<L>::value &&
-                                                                                         is_expression<R>::value>>
+template < typename L,
+                  typename R,
+                  typename = typename std::enable_if_t < is_expression<L>::value &&
+                                                                                                 is_expression<R>::value >>
 And<L, R> operator&&(const L& l, const R& r)
 {
        return {l, r};
 }
 
-template<typename L,
-                typename R,
-                typename = typename std::enable_if_t<is_expression<L>::value &&
-                                                                                         is_expression<R>::value>>
+template < typename L,
+                  typename R,
+                  typename = typename std::enable_if_t < is_expression<L>::value &&
+                                                                                                 is_expression<R>::value >>
 Or<L, R> operator||(const L& l, const R& r)
 {
        return {l, r};
index 564b5b5..c09fd23 100644 (file)
@@ -16,9 +16,9 @@
 
 #pragma once
 
-#include "column.hpp" 
-#include "database.hpp" 
-#include "table.hpp" 
+#include "column.hpp"
+#include "database.hpp"
+#include "table.hpp"
 
 #define DECLARE_COLUMN(instance, name, type) \
        inline static vist::tsqb::Column instance = { name, type }
index a8ce677..be3d592 100644 (file)
@@ -77,13 +77,13 @@ template<typename... Cs>
 std::vector<std::string> Table<Columns...>::getColumnNames(Cs&& ...columns) const noexcept
 {
        std::vector<std::string> names;
-       auto predicate = [this, &names](const auto& type) {
+       auto predicate = [this, &names](const auto & type) {
                auto name = this->getColumnName(type);
                if (!name.empty())
                        names.emplace_back(name);
        };
 
-       auto closure = [&predicate](const auto&... iter) {
+       auto closure = [&predicate](const auto & ... iter) {
                (predicate(iter), ...);
        };
 
@@ -103,7 +103,7 @@ template<typename... Columns>
 std::vector<std::string> Table<Columns...>::getColumnNames(void) const noexcept
 {
        std::vector<std::string> names;
-       auto closure = [&names](const auto&... iter) {
+       auto closure = [&names](const auto & ... iter) {
                (names.push_back(iter.name), ...);
        };
 
@@ -124,12 +124,12 @@ template<typename Column>
 std::string Table<Columns...>::getColumnName(Column&& column) const noexcept
 {
        std::string name;
-       auto predicate = [&name, &column](const auto& iter) {
-               if (type::cast_compare(column.type, iter.type)) 
+       auto predicate = [&name, &column](const auto & iter) {
+               if (type::cast_compare(column.type, iter.type))
                        name = iter.name;
        };
 
-       auto closure = [&predicate](const auto&... iter) {
+       auto closure = [&predicate](const auto & ... iter) {
                (predicate(iter), ...);
        };
 
index ba40830..6155bdb 100644 (file)
@@ -59,17 +59,17 @@ struct PolicyDefinition {
 };
 
 DECLARE_TABLE(AdminTable, "admin", Admin::Id, Admin::Pkg,
-                                                                  Admin::Uid, Admin::Key, Admin::Removable);
+                         Admin::Uid, Admin::Key, Admin::Removable);
 
 DECLARE_TABLE(ManagedPolicyTable, "managed_policy", ManagedPolicy::Id,
-                                                                                                       ManagedPolicy::Aid,
-                                                                                                       ManagedPolicy::Pid,
-                                                                                                       ManagedPolicy::Value);
+                         ManagedPolicy::Aid,
+                         ManagedPolicy::Pid,
+                         ManagedPolicy::Value);
 
 DECLARE_TABLE(PolicyDefinitionTable, "policy_definition", PolicyDefinition::Id,
-                                                                                                                 PolicyDefinition::Scope,
-                                                                                                                 PolicyDefinition::Name,
-                                                                                                                 PolicyDefinition::Ivalue);
+                         PolicyDefinition::Scope,
+                         PolicyDefinition::Name,
+                         PolicyDefinition::Ivalue);
 
 DECLARE_DATABASE(DPM, "dpm", AdminTable, ManagedPolicyTable, PolicyDefinitionTable);
 
@@ -92,7 +92,7 @@ TEST(QueryBuilderTsqbTests, SELECT_ALL)
 TEST(QueryBuilderTsqbTests, SELECT_WHERE)
 {
        std::string select1 = AdminTable.select(Admin::Uid, Admin::Key)
-                                                                       .where(Admin::Id > 3);
+                                                 .where(Admin::Id > 3);
        std::string select2 = AdminTable.selectAll().where(Admin::Uid > 3);
        std::string select3 = AdminTable.selectAll().where(Admin::Uid > 3 && Admin::Pkg == "dpm");
        std::string select4 = AdminTable.selectAll().where(Admin::Uid > 3 || Admin::Pkg == "dpm");
@@ -109,9 +109,9 @@ TEST(QueryBuilderTsqbTests, UPDATE)
        std::string update1 = AdminTable.update(Admin::Id = id, Admin::Pkg = "pkg",
                                                                                        Admin::Uid = uid, Admin::Key = "key");
        std::string update2 = AdminTable.update(Admin::Key = "key")
-                                                                       .where((Admin::Uid == uid) && (Admin::Id == id));
+                                                 .where((Admin::Uid == uid) && (Admin::Id == id));
        std::string update3 = AdminTable.update(Admin::Key = "key", Admin::Pkg = "pkg")
-                                                                       .where((Admin::Uid == 0) && (Admin::Id == 1));
+                                                 .where((Admin::Uid == 0) && (Admin::Id == 1));
 
        EXPECT_EQ(update1, "UPDATE admin SET id = 1, pkg = 'pkg', uid = 0, key = 'key'");
        EXPECT_EQ(update2, "UPDATE admin SET key = 'key' WHERE uid = 0 AND id = 1");
@@ -143,24 +143,24 @@ TEST(QueryBuilderTsqbTests, INSERT)
                                                                                        Admin::Key = key);
 
        EXPECT_EQ(insert1, "INSERT INTO admin (id, pkg, uid, key) "
-                                          "VALUES (0, 'pkg', 1, 'key')");
+                         "VALUES (0, 'pkg', 1, 'key')");
        EXPECT_EQ(insert2, "INSERT INTO admin (id, pkg, key) "
-                                          "VALUES (0, 'pkg', 'key')");
+                         "VALUES (0, 'pkg', 'key')");
 }
 
 TEST(QueryBuilderTsqbTests, TYPE_SAFE)
 {
-/*
- * Below cause complie error since expression types are dismatch.
-
-       std::string type_unsafe1 = admin.selectAll().where(Admin::Uid > "dpm");
-       std::string type_unsafe2 = admin.selectAll().where(Admin::Uid == "dpm");
-       std::string type_unsafe3 = admin.selectAll().where(Admin::Pkg == 3);
-       int pkg = 3;
-       std::string type_unsafe4 = admin.selectAll().where(Admin::Pkg) < pkg);
-       std::string type_unsafe5 = admin.remove().where(Admin::Pkg) == "dpm" &&
-                                                                                                       Admin::Uid) == "dpm");
-*/
+       /*
       * Below cause complie error since expression types are dismatch.
+
+           std::string type_unsafe1 = admin.selectAll().where(Admin::Uid > "dpm");
+           std::string type_unsafe2 = admin.selectAll().where(Admin::Uid == "dpm");
+           std::string type_unsafe3 = admin.selectAll().where(Admin::Pkg == 3);
+           int pkg = 3;
+           std::string type_unsafe4 = admin.selectAll().where(Admin::Pkg) < pkg);
+           std::string type_unsafe5 = admin.remove().where(Admin::Pkg) == "dpm" &&
+                                                           Admin::Uid) == "dpm");
+       */
 }
 
 TEST(QueryBuilderTsqbTests, MULTI_SELECT)
@@ -169,11 +169,11 @@ TEST(QueryBuilderTsqbTests, MULTI_SELECT)
                                                                                  ManagedPolicy::Id, ManagedPolicy::Value);
        std::string multiSelect2 = DPM.select(Admin::Uid, Admin::Key,
                                                                                  ManagedPolicy::Id, ManagedPolicy::Value)
-                                                                 .where((Admin::Uid > 0) && (ManagedPolicy::Id == 3));
+                                                          .where((Admin::Uid > 0) && (ManagedPolicy::Id == 3));
 
        EXPECT_EQ(multiSelect1, "SELECT admin.uid, admin.key, managed_policy.id, "
-                                                       "managed_policy.value FROM admin, managed_policy");
+                         "managed_policy.value FROM admin, managed_policy");
        EXPECT_EQ(multiSelect2, "SELECT admin.uid, admin.key, managed_policy.id, "
-                                                       "managed_policy.value FROM admin, managed_policy "
-                                                       "WHERE admin.uid > 0 AND managed_policy.id = 3");
+                         "managed_policy.value FROM admin, managed_policy "
+                         "WHERE admin.uid > 0 AND managed_policy.id = 3");
 }
index 620eed3..1e273c2 100644 (file)
@@ -48,10 +48,10 @@ struct Table2 {
 
 DECLARE_TABLE(table1, "table1", Table1::Column1, Table1::Column2, Table1::Column3);
 DECLARE_TABLE(table2, "table2", Table2::Column1,
-                                                               Table2::Column2,
-                                                               Table2::Column3,
-                                                               Table2::Column4,
-                                                               Table2::Column5);
+                         Table2::Column2,
+                         Table2::Column3,
+                         Table2::Column4,
+                         Table2::Column5);
 
 DECLARE_DATABASE(database, "database", table1, table2);
 
index d1a92e2..2469899 100644 (file)
@@ -27,7 +27,9 @@ namespace util {
 
 inline std::string rtrim(std::string&& s)
 {
-       auto predicate = [](unsigned char c){ return !std::isspace(c); };
+       auto predicate = [](unsigned char c) {
+               return !std::isspace(c);
+       };
        auto base = std::find_if(s.rbegin(), s.rend(), predicate).base();
        s.erase(base, s.end());
        return s;
index b00f800..ecfa73e 100644 (file)
@@ -57,12 +57,24 @@ public:
        Result(ErrCode ec) : ec(std::move(ec)), isError(true) {}
        Result() = delete;
 
-       inline bool ok() { return !isError; }
-       inline bool err() { return isError; }
+       inline bool ok()
+       {
+               return !isError;
+       }
+       inline bool err()
+       {
+               return isError;
+       }
 
        /// TBD: Consider to return rvalue.
-       inline Value& get() { return value; }
-       inline ErrCode getErrCode() { return ec; }
+       inline Value& get()
+       {
+               return value;
+       }
+       inline ErrCode getErrCode()
+       {
+               return ec;
+       }
 
 private:
        Value value;
index cae068e..47d7617 100644 (file)
@@ -33,7 +33,7 @@ class Gateway::Impl {
 public:
        explicit Impl(Gateway& gateway, const std::string& path, Gateway::ServiceType type)
        {
-               auto dispatcher = [&gateway](auto& message) -> Message {
+               auto dispatcher = [&gateway](auto & message) -> Message {
                        std::string function = message.signature;
                        auto iter = gateway.functorMap.find(function);
                        if (iter == gateway.functorMap.end())
index da08828..1b776ae 100644 (file)
@@ -129,7 +129,8 @@ void Mainloop::wait(int timeout, Stopper stopper)
        this->dispatch(nfds);
 }
 
-void Mainloop::dispatch(int size) {
+void Mainloop::dispatch(int size)
+{
        for (int i = 0; i < size; i++) {
                auto handler = this->getHandler(this->events[i].data.fd);
                auto onEvent = handler.first;
index 0ecf60a..514e681 100644 (file)
@@ -62,8 +62,9 @@ void Server::accept(const Task& task)
                DEBUG(VIST) << "New session is accepted: fd[" << connection->getFd() << "]";
 
                /// process task per thread
-               this->worker.submit([this, connection, task]{
-                       auto onRead = [connection, task]() {
+               this->worker.submit([this, connection, task] {
+                       auto onRead = [connection, task]()
+                       {
                                Server::peer.reset(new Credentials(Credentials::Peer(connection->getFd())));
                                DEBUG(VIST) << "Read event occured: pid[" << Server::peer->pid << "]";
 
@@ -80,7 +81,8 @@ void Server::accept(const Task& task)
                                }
                        };
 
-                       auto onClose = [this, connection]() {
+                       auto onClose = [this, connection]()
+                       {
                                DEBUG(VIST) << "Connection closed. fd: " << connection->getFd();
                                this->mainloop.removeHandler(connection->getFd());
                        };
index 0fa6757..2727bb2 100644 (file)
@@ -59,7 +59,7 @@ private:
 };
 
 template<typename T>
-void Socket::send(const T *buffer, const std::size_t size) const
+void Socket::send(const Tbuffer, const std::size_t size) const
 {
        std::size_t written = 0;
        while (written < size) {
@@ -76,7 +76,7 @@ void Socket::send(const T *buffer, const std::size_t size) const
 }
 
 template<typename T>
-void Socket::recv(T *buffer, const std::size_t size) const
+void Socket::recv(Tbuffer, const std::size_t size) const
 {
        std::size_t readen = 0;
        while (readen < size) {
index 7e79624..096af60 100644 (file)
@@ -67,7 +67,9 @@ TEST(ConnectionTests, socket_communication)
        };
 
        mainloop.addHandler(socket.getFd(), std::move(onAccept));
-       auto serverThread = std::thread([&]() { mainloop.run(); });
+       auto serverThread = std::thread([&]() {
+               mainloop.run();
+       });
 
        // client-side
        Connection conn(sockPath);
index 6119ffe..b7000fb 100644 (file)
@@ -53,7 +53,9 @@ TEST(MainloopTests, single)
        };
 
        mainloop.addHandler(socket.getFd(), std::move(onAccept));
-       auto server = std::thread([&]() { mainloop.run(); });
+       auto server = std::thread([&]() {
+               mainloop.run();
+       });
 
        // Send input to server.
        Socket connected = Socket::connect(sockPath);
@@ -92,7 +94,9 @@ TEST(MainloopTests, multiflexing)
 
        /// Set timeout to stop
        mainloop.addHandler(socket.getFd(), std::move(onAccept));
-       auto server = std::thread([&]() { mainloop.run(1000); });
+       auto server = std::thread([&]() {
+               mainloop.run(1000);
+       });
 
        auto task = [&]() {
                // Send input to server.
index 2c94b13..64a35bc 100644 (file)
@@ -46,7 +46,7 @@ TEST(ServerClientTests, not_ondemand)
 {
        std::string sockPath = "@vist-test.sock";
 
-       auto task = [&](Message& message) -> Message {
+       auto task = [&](Message & message) -> Message {
                EXPECT_EQ(message.signature, requestSignature);
 
                int recv1;
@@ -67,7 +67,8 @@ TEST(ServerClientTests, not_ondemand)
                server.run();
        });
 
-       { /// Client configuration
+       {
+               /// Client configuration
                auto clientClosure = [&]() {
                        Client client(sockPath);
 
@@ -101,7 +102,7 @@ TEST(ServerClientTests, not_ondemand)
 TEST(ServerClientTests, peer_pid)
 {
        std::string sockPath = "@vist-test.sock";
-       auto task = [](Message& message) -> Message {
+       auto task = [](Message & message) -> Message {
                EXPECT_EQ(message.signature, requestSignature);
 
                auto peer = Server::GetPeerCredentials();
@@ -121,7 +122,8 @@ TEST(ServerClientTests, peer_pid)
                server.run();
        });
 
-       { /// Client configuration
+       {
+               /// Client configuration
                auto clientClosure = [&]() {
                        Client client(sockPath);
 
index 86902c6..8380c32 100644 (file)
@@ -21,7 +21,7 @@ namespace rmi {
 
 Message::Message(unsigned int type, const std::string& signature) :
        header({0, type, signature.size()}),
-       signature(signature)
+          signature(signature)
 {
        this->enclose(signature);
 }
index 6033aff..daa5146 100644 (file)
@@ -53,9 +53,9 @@ struct VIST_API Message final {
        Message& operator=(Message&&) = default;
 
        template<typename... Args>
-       void enclose(Args&&... args);
+       void enclose(Args&& ... args);
        template<typename... Args>
-       void disclose(Args&... args);
+       void disclose(Args& ... args);
 
        bool success() const noexcept;
        bool error() const noexcept;
@@ -71,14 +71,14 @@ struct VIST_API Message final {
 };
 
 template<typename... Args>
-void Message::enclose(Args&&... args)
+void Message::enclose(Args&& ... args)
 {
        this->buffer.pack(std::forward<Args>(args)...);
        header.length = this->buffer.size();
 }
 
 template<typename... Args>
-void Message::disclose(Args&... args)
+void Message::disclose(Args& ... args)
 {
        this->buffer.unpack(args...);
 }
index 58423af..718fdb3 100644 (file)
@@ -40,14 +40,14 @@ public:
        Remote& operator=(Remote&&) = default;
 
        template<typename R, typename... Args>
-       R invoke(const std::string& name, Args&&... args);
+       R invoke(const std::string& name, Args&& ... args);
 
        struct Method {
                Remote& remote;
                std::string name;
 
                template<typename R, typename... Args>
-               R invoke(Args&&... args)
+               R invoke(Args&& ... args)
                {
                        return remote.invoke<R>(name, std::forward<Args>(args)...);
                }
@@ -61,7 +61,7 @@ private:
 };
 
 template<typename R, typename... Args>
-R Remote::invoke(const std::string& method, Args&&... args)
+R Remote::invoke(const std::string& method, Args&& ... args)
 {
        Message message(Message::Type::MethodCall, method);
        message.enclose(std::forward<Args>(args)...);
index c7fda17..18ce416 100644 (file)
 namespace vist {
 namespace schema {
 
-       struct Bluetooth {
-               int state;
-               int desktopConnectivity;
-               int pairing;
-               int tethering; 
+struct Bluetooth {
+       int state;
+       int desktopConnectivity;
+       int pairing;
+       int tethering;
 
-               DECLARE_COLUMN(State, "state", &Bluetooth::state);
-               DECLARE_COLUMN(DesktopConnectivity, "desktopConnectivity", &Bluetooth::desktopConnectivity);
-               DECLARE_COLUMN(Pairing, "pairing", &Bluetooth::pairing);
-               DECLARE_COLUMN(Tethering, "tethering", &Bluetooth::tethering);
-       };
+       DECLARE_COLUMN(State, "state", &Bluetooth::state);
+       DECLARE_COLUMN(DesktopConnectivity, "desktopConnectivity", &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);
+DECLARE_TABLE(BluetoothTable, "bluetooth", Bluetooth::State,
+                         Bluetooth::DesktopConnectivity,
+                         Bluetooth::Pairing,
+                         Bluetooth::Tethering);
 
 } // namesapce schema
 } // namesapce vist
index 92eb521..54c4a3f 100644 (file)
@@ -23,7 +23,7 @@ namespace schema {
 
 template <typename T>
 struct Policy {
-       std::string     name;
+       std::string name;
        T value;
 };
 
index 7ecd69e..f6e09e6 100644 (file)
@@ -73,8 +73,14 @@ public:
 
        virtual void onChanged(const PolicyValue& value) = 0;
 
-       const std::string& getName() const noexcept { return name; }
-       PolicyValue& getInitial() noexcept { return initial; }
+       const std::string& getName() const noexcept
+       {
+               return name;
+       }
+       PolicyValue& getInitial() noexcept
+       {
+               return initial;
+       }
 
 protected:
        std::string name;
index d228681..bd31eea 100644 (file)
@@ -27,7 +27,7 @@ namespace policy {
 
 class PolicyProvider {
 public:
-       using FactoryType = PolicyProvider* (*)();
+       using FactoryType = PolicyProvider * (*)();
 
        explicit PolicyProvider(std::string name) noexcept : name(std::move(name)) {}
        virtual ~PolicyProvider() = default;
@@ -37,14 +37,20 @@ public:
                policies[policy->getName()] = policy;
        }
 
-       inline const std::string& getName() const noexcept { return name; }
+       inline const std::string& getName() const noexcept
+       {
+               return name;
+       }
        static const std::string& getFactoryName() noexcept
        {
                static std::string name = "PolicyFactory";
                return name;
        }
 
-       inline std::size_t size() const noexcept { return policies.size(); }
+       inline std::size_t size() const noexcept
+       {
+               return policies.size();
+       }
 
 private:
        std::string name;
index a21ff8d..9a0b1af 100644 (file)
@@ -22,7 +22,7 @@
 #include <exception>
 
 namespace {
-       int g_value = -1;
+int g_value = -1;
 } // anonymous namespace
 
 using namespace vist;
index afe25c9..695dc53 100644 (file)
@@ -29,7 +29,7 @@
 #include <osquery/sql.h>
 
 namespace {
-       const std::string SOCK_ADDR = "/tmp/.vist";
+const std::string SOCK_ADDR = "/tmp/.vist";
 } // anonymous namespace
 
 namespace vist {
index bfffd34..fa359d0 100644 (file)
@@ -59,7 +59,7 @@ inline std::string strip(const std::string& origin, char begin, char end)
        if (copied.size() < 2 || copied[0] != begin || copied[copied.size() - 1] != end)
                throw std::invalid_argument("Wrong format.");
 
-       return copied.substr(1, copied.size() -2);
+       return copied.substr(1, copied.size() - 2);
 }
 
 inline std::size_t count(const std::string& str, char ch)
index d180afb..25cf78f 100644 (file)
@@ -37,7 +37,8 @@ std::map<std::string, std::string> ALIAS = {
        { "state", "bluetooth" },
        { "desktopConnectivity", "bluetooth-desktop-connectivity" },
        { "pairing", "bluetooth-pairing" },
-       { "tethering", "bluetooth-tethering"} };
+       { "tethering", "bluetooth-tethering"}
+};
 
 void setPolicy(const std::string& name, int value)
 {
@@ -62,14 +63,15 @@ TableColumns BluetoothTable::columns() const
        };
 }
 
-TableRows BluetoothTable::generate(QueryContext&) try {
+TableRows BluetoothTable::generate(QueryContext&) try
+{
        INFO(VIST) << "Select query about bluetooth table.";
 
        QueryData results;
 
        Row row;
 
-       for (const auto&[schemaName, policyName]: ALIAS) {
+       for (const auto&[schemaName, policyName] : ALIAS) {
                int value = vist::policy::API::Get(policyName);
                row[schemaName] = std::to_string(value);
        }
@@ -77,17 +79,20 @@ TableRows BluetoothTable::generate(QueryContext&) try {
        results.emplace_back(std::move(row));
 
        return osquery::tableRowsFromQueryData(std::move(results));
-} catch (const vist::Exception<ErrCode>& e) {
+} catch (const vist::Exception<ErrCode>& e)
+{
        ERROR(VIST) << "Failed to query: " << e.what();
        Row r;
        return osquery::tableRowsFromQueryData({ r });
-} catch (...) {
+} catch (...)
+{
        ERROR(VIST) << "Failed to query with unknown exception.";
        Row r;
        return osquery::tableRowsFromQueryData({ r });
 }
 
-QueryData BluetoothTable::update(QueryContext&, const PluginRequest& request) try {
+QueryData BluetoothTable::update(QueryContext&, const PluginRequest& request) try
+{
        INFO(VIST) << "Update query about bluetooth table.";
        if (request.count("json_values") == 0)
                throw std::runtime_error("Wrong request format. Not found json value.");
@@ -107,11 +112,13 @@ QueryData BluetoothTable::update(QueryContext&, const PluginRequest& request) tr
        Row r;
        r["status"] = "success";
        return { r };
-} catch (const vist::Exception<ErrCode>& e) {
+} catch (const vist::Exception<ErrCode>& e)
+{
        ERROR(VIST) << "Failed to query: " << e.what();
        Row r;
        return { r };
-} catch (...) {
+} catch (...)
+{
        ERROR(VIST) << "Failed to query with unknown exception.";
        Row r;
        return { r };
index a56fb99..9edc0d0 100644 (file)
@@ -105,11 +105,13 @@ TableRows PolicyAdminTable::generate(QueryContext& context) try
        }
 
        return osquery::tableRowsFromQueryData(std::move(results));
-} catch (const vist::Exception<ErrCode>& e) {
+} catch (const vist::Exception<ErrCode>& e)
+{
        ERROR(VIST) << "Failed to query: " << e.what();
        Row r;
        return osquery::tableRowsFromQueryData({ r });
-} catch (...) {
+} catch (...)
+{
        ERROR(VIST) << "Failed to query with unknown exception.";
        Row r;
        return osquery::tableRowsFromQueryData({ r });
@@ -129,11 +131,13 @@ QueryData PolicyAdminTable::insert(QueryContext&, const PluginRequest& request)
        Row r;
        r["status"] = "success";
        return { r };
-} catch (const vist::Exception<ErrCode>& e) {
+} catch (const vist::Exception<ErrCode>& e)
+{
        ERROR(VIST) << "Failed to query: " << e.what();
        Row r;
        return { r };
-} catch (...) {
+} catch (...)
+{
        ERROR(VIST) << "Failed to query with unknown exception.";
        Row r;
        return { r };
@@ -153,11 +157,13 @@ QueryData PolicyAdminTable::delete_(QueryContext&, const PluginRequest& request)
        Row r;
        r["status"] = "success";
        return { r };
-} catch (const vist::Exception<ErrCode>& e) {
+} catch (const vist::Exception<ErrCode>& e)
+{
        ERROR(VIST) << "Failed to query: " << e.what();
        Row r;
        return { r };
-} catch (...) {
+} catch (...)
+{
        ERROR(VIST) << "Failed to query with unknown exception.";
        Row r;
        return { r };
@@ -183,11 +189,13 @@ QueryData PolicyAdminTable::update(QueryContext&, const PluginRequest& request)
        Row r;
        r["status"] = "success";
        return { r };
-} catch (const vist::Exception<ErrCode>& e) {
+} catch (const vist::Exception<ErrCode>& e)
+{
        ERROR(VIST) << "Failed to query: " << e.what();
        Row r;
        return { r };
-} catch (...) {
+} catch (...)
+{
        ERROR(VIST) << "Failed to query with unknown exception.";
        Row r;
        return { r };
index 6970d52..ca0060b 100644 (file)
@@ -81,11 +81,13 @@ TableRows PolicyTable::generate(QueryContext& context) try
        }
 
        return osquery::tableRowsFromQueryData(std::move(results));
-} catch (const vist::Exception<ErrCode>& e) {
+} catch (const vist::Exception<ErrCode>& e)
+{
        ERROR(VIST) << "Failed to query: " << e.what();
        Row r;
        return osquery::tableRowsFromQueryData({ r });
-} catch (...) {
+} catch (...)
+{
        ERROR(VIST) << "Failed to query with unknown exception.";
        Row r;
        return osquery::tableRowsFromQueryData({ r });
@@ -111,11 +113,13 @@ QueryData PolicyTable::update(QueryContext&, const PluginRequest& request) try
        Row r;
        r["status"] = "success";
        return { r };
-} catch (const vist::Exception<ErrCode>& e) {
+} catch (const vist::Exception<ErrCode>& e)
+{
        ERROR(VIST) << "Failed to query: " << e.what();
        Row r;
        return { r };
-} catch (...) {
+} catch (...)
+{
        ERROR(VIST) << "Failed to query with unknown exception.";
        Row r;
        return { r };
index 54c5641..28e16d0 100644 (file)
@@ -32,7 +32,8 @@ struct Timer {
        using Task = std::function<void()>;
 
        /// Execute task() once until predicate() is true.
-       static void ExecOnce(Task task, Predicate predicate, unsigned int seconds) {
+       static void ExecOnce(Task task, Predicate predicate, unsigned int seconds)
+       {
                auto worker = std::thread([task, predicate, seconds]() {
                        while (1) {
                                std::this_thread::sleep_for(std::chrono::seconds(seconds));