diff options
author | Kozoriz <kozorizandriy@gmail.com> | 2016-04-26 12:41:54 +0300 |
---|---|---|
committer | Kozoriz <kozorizandriy@gmail.com> | 2016-04-26 15:50:21 +0300 |
commit | 4ecdb2a83871784f34430ed09d5ef6a2c0855506 (patch) | |
tree | dc36b449e5d32ac3e493e16865cf9d88d9991817 /src/components/utils/include | |
parent | cf58bb97d09c536dce3b492d1517da0b837bc8eb (diff) | |
download | sdl_core-4ecdb2a83871784f34430ed09d5ef6a2c0855506.tar.gz |
Format all code in project
Formated all code in appMain, components, plugins to correct coding-style
Used clang-format-3.6
Used 2 commands :
find src/appMain/ -name "*.h" -o -name "*.cc" -o -name "*.hpp" -o -name "*.cpp" | xargs clang-format-3.6 -i -style=file
find src/components/ -name "*.h" -o -name "*.cc" -o -name "*.hpp" -o -name "*.cpp" | xargs clang-format-3.6 -i -style=file
find src/plugins/ -name "*.h" -o -name "*.cc" -o -name "*.hpp" -o -name "*.cpp" | xargs clang-format-3.6 -i -style=file
Diffstat (limited to 'src/components/utils/include')
19 files changed, 239 insertions, 230 deletions
diff --git a/src/components/utils/include/utils/appenders_loader.h b/src/components/utils/include/utils/appenders_loader.h index 03d3217994..65556e6862 100644 --- a/src/components/utils/include/utils/appenders_loader.h +++ b/src/components/utils/include/utils/appenders_loader.h @@ -40,6 +40,7 @@ class AppendersLoader { AppendersLoader(); ~AppendersLoader(); bool Loaded() const; + private: void* handle_; }; diff --git a/src/components/utils/include/utils/back_trace.h b/src/components/utils/include/utils/back_trace.h index f2410e36bc..180714e5a6 100644 --- a/src/components/utils/include/utils/back_trace.h +++ b/src/components/utils/include/utils/back_trace.h @@ -68,8 +68,8 @@ class Backtrace { std::vector<void*> backtrace_; }; -std::ostream& operator<< (std::ostream& os, const Backtrace& bt); +std::ostream& operator<<(std::ostream& os, const Backtrace& bt); -} // namespace utils +} // namespace utils -#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_BACK_TRACE_H_ +#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_BACK_TRACE_H_ diff --git a/src/components/utils/include/utils/bitstream.h b/src/components/utils/include/utils/bitstream.h index 6b9d6337ef..13eacc6cb1 100644 --- a/src/components/utils/include/utils/bitstream.h +++ b/src/components/utils/include/utils/bitstream.h @@ -57,12 +57,21 @@ class BitStream { // Mark stream as badly-formed. // Should be called by Extract* family of procedures if they decide // that stream is invalid - void MarkBad() { bad_ = true; } + void MarkBad() { + bad_ = true; + } // Predicates to check whether there were errors while parsing // Stream is good when it is created - bool IsGood() { return !bad_; } - bool IsBad() { return bad_; } - operator bool() { return IsGood(); } + bool IsGood() { + return !bad_; + } + bool IsBad() { + return bad_; + } + operator bool() { + return IsGood(); + } + private: // These two functions are used for internal stream checks only // Stream parser procedures must not define their logic depending on @@ -78,13 +87,13 @@ class BitStream { // Extract single value, amount of bits read from stream depends on T size // If there is not enough data in the stream, stream is marked bad - template<typename T> + template <typename T> void Extract(T& val); // Read single value, amount of bits read from stream is signaled by |bits| // parameter. T must be wide enough to hold this amount of bits. // If there is not enough data in the stream, stream is marked bad - template<typename T> + template <typename T> void ExtractBits(T& val, size_t bits); // Extract |length| bytes from the stream. Stream read position @@ -94,10 +103,11 @@ class BitStream { private: const uint8_t* bytes_; - const size_t bytes_count_; + const size_t bytes_count_; size_t byte_offset_; size_t bit_offset_; bool bad_; + private: friend void Extract(BitStream*, uint8_t*); friend void Extract(BitStream*, uint8_t*, size_t); @@ -105,7 +115,6 @@ class BitStream { friend void Extract(BitStream*, uint32_t*, size_t); friend void Extract(BitStream*, std::string*, size_t); friend void Extract(BitStream*, std::vector<uint8_t>*, size_t); - }; // Extract single byte from stream @@ -133,16 +142,15 @@ void Extract(BitStream* bs, std::string* str, size_t length); // vector |data|. If stream is too short it is marked bad. void Extract(BitStream* bs, std::vector<uint8_t>* data, size_t length); - // Template member definitions -template<typename T> +template <typename T> void BitStream::Extract(T& val) { // Slow but simple implementation // It's a space for bit stream reading optimization ExtractBits(val, sizeof(val) * CHAR_BIT); } -template<typename T> +template <typename T> void BitStream::ExtractBits(T& val, size_t bits) { DCHECK(sizeof(val) * CHAR_BIT >= bits); if (IsGood()) { @@ -164,7 +172,6 @@ void BitStream::ExtractBits(T& val, size_t bits) { } } -} // namespace utils - +} // namespace utils -#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_BITSTREAM_H_ +#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_BITSTREAM_H_ diff --git a/src/components/utils/include/utils/convert_utils.h b/src/components/utils/include/utils/convert_utils.h index b3e849d6bd..0609164a60 100644 --- a/src/components/utils/include/utils/convert_utils.h +++ b/src/components/utils/include/utils/convert_utils.h @@ -60,7 +60,6 @@ unsigned long long int ConvertUInt64ToLongLongUInt(const uint64_t value); */ uint64_t ConvertLongLongUIntToUInt64(const unsigned long long int value); - /** * Convert one number value to another type value */ diff --git a/src/components/utils/include/utils/file_system.h b/src/components/utils/include/utils/file_system.h index 0757a17110..5862241c9c 100644 --- a/src/components/utils/include/utils/file_system.h +++ b/src/components/utils/include/utils/file_system.h @@ -41,7 +41,6 @@ namespace file_system { - /** * @brief Get available disc space. * @@ -165,7 +164,8 @@ bool DeleteFile(const std::string& name); * @brief Removes directory. * * @param name path to directory. - * @param is_recursively true if you need delete directory recursively, otherwise false. + * @param is_recursively true if you need delete directory recursively, + *otherwise false. * @return returns true if the directory is successfully deleted. */ bool RemoveDirectory(const std::string& directory_name, @@ -220,8 +220,7 @@ bool WriteBinaryFile(const std::string& name, * @param result read data * @return returns true if the operation is successfully. */ -bool ReadBinaryFile(const std::string& name, - std::vector<uint8_t>& result); +bool ReadBinaryFile(const std::string& name, std::vector<uint8_t>& result); bool ReadFile(const std::string& name, std::string& result); @@ -255,8 +254,7 @@ uint64_t GetFileModificationTime(const std::string& path); * @param dst Destination file path * @return if result success return true */ -bool CopyFile(const std::string& src, - const std::string& dst); +bool CopyFile(const std::string& src, const std::string& dst); /** * @brief Move file from source to destination @@ -265,8 +263,7 @@ bool CopyFile(const std::string& src, * @param dst Destination file path * @return if result success return true */ -bool MoveFile(const std::string& src, - const std::string& dst); +bool MoveFile(const std::string& src, const std::string& dst); void remove_directory_content(const std::string& directory_name); diff --git a/src/components/utils/include/utils/helpers.h b/src/components/utils/include/utils/helpers.h index f16acfc90a..17d4af27a1 100644 --- a/src/components/utils/include/utils/helpers.h +++ b/src/components/utils/include/utils/helpers.h @@ -31,12 +31,13 @@ */ #ifndef SRC_COMPONENTS_UTILS_INCLUDE_UTILS_HELPERS_H #define SRC_COMPONENTS_UTILS_INCLUDE_UTILS_HELPERS_H -#include<algorithm> +#include <algorithm> /** * These helpers allows to simplify compare strategy between some objects. * Suppose user has some enum with value E with some numbers of possible values * enum E {V1, V2, V3, V5}; - * So we want to know if some user-input value is belong to one of the enum's subset. + * So we want to know if some user-input value is belong to one of the enum's + *subset. * Usually user has to do next routine * * E input_value = V3; @@ -56,71 +57,72 @@ */ namespace helpers { - template<typename T> - bool EQ (T what, T to) { - return what == to; - } - - template<typename T> - bool NEQ (T what, T to) { - return !EQ<T>(what, to); - } +template <typename T> +bool EQ(T what, T to) { + return what == to; +} - template<class U = bool> - bool ALL (U what, U to) { - return what && to; - } +template <typename T> +bool NEQ(T what, T to) { + return !EQ<T>(what, to); +} - template<class U = bool> - bool ONE (U what, U to) { - return what || to; - } +template <class U = bool> +bool ALL(U what, U to) { + return what && to; +} - template <typename T, - bool (*CompareType)(T ,T), - bool (*CmpStrategy)(bool ,bool)> - bool Compare (T what, T to) { - return CompareType(what, to); - } +template <class U = bool> +bool ONE(U what, U to) { + return what || to; +} - template <typename T, - bool (*CompareType)(T ,T), - bool (*CmpStrategy)(bool, bool)> - bool Compare(T what, T to, T to1) { - return CmpStrategy(Compare<T, CompareType, CmpStrategy>(what, to), - Compare<T, CompareType, CmpStrategy>(what, to1)); - } +template <typename T, + bool (*CompareType)(T, T), + bool (*CmpStrategy)(bool, bool)> +bool Compare(T what, T to) { + return CompareType(what, to); +} - template <typename T, - bool (*CompareType)(T ,T), - bool (*CmpStrategy)(bool, bool)> - bool Compare(T what, T to, T to1, T to2) { - return CmpStrategy(Compare<T, CompareType, CmpStrategy>(what, to, to1), - Compare<T, CompareType, CmpStrategy>(what, to2)); - } +template <typename T, + bool (*CompareType)(T, T), + bool (*CmpStrategy)(bool, bool)> +bool Compare(T what, T to, T to1) { + return CmpStrategy(Compare<T, CompareType, CmpStrategy>(what, to), + Compare<T, CompareType, CmpStrategy>(what, to1)); +} - template <typename T, - bool (*CompareType)(T ,T), - bool (*CmpStrategy)(bool, bool)> - bool Compare(T what, T to, T to1, T to2, T to3) { - return CmpStrategy(Compare<T, CompareType, CmpStrategy>(what, to, to1, to2), - Compare<T, CompareType, CmpStrategy>(what, to3)); - } +template <typename T, + bool (*CompareType)(T, T), + bool (*CmpStrategy)(bool, bool)> +bool Compare(T what, T to, T to1, T to2) { + return CmpStrategy(Compare<T, CompareType, CmpStrategy>(what, to, to1), + Compare<T, CompareType, CmpStrategy>(what, to2)); +} - template <typename T, - bool (*CompareType)(T ,T), - bool (*CmpStrategy)(bool, bool)> - bool Compare(T what, T to, T to1, T to2, T to3, T to4) { - return CmpStrategy(Compare<T, CompareType, CmpStrategy>(what, to, to1, to2, to3), - Compare<T, CompareType, CmpStrategy>(what, to4)); - } +template <typename T, + bool (*CompareType)(T, T), + bool (*CmpStrategy)(bool, bool)> +bool Compare(T what, T to, T to1, T to2, T to3) { + return CmpStrategy(Compare<T, CompareType, CmpStrategy>(what, to, to1, to2), + Compare<T, CompareType, CmpStrategy>(what, to3)); +} +template <typename T, + bool (*CompareType)(T, T), + bool (*CmpStrategy)(bool, bool)> +bool Compare(T what, T to, T to1, T to2, T to3, T to4) { + return CmpStrategy( + Compare<T, CompareType, CmpStrategy>(what, to, to1, to2, to3), + Compare<T, CompareType, CmpStrategy>(what, to4)); +} - template<typename Container> - bool in_range(const Container& container, const typename Container::value_type& value) { - return - std::find(container.begin(), container.end(), value) != container.end(); - } +template <typename Container> +bool in_range(const Container& container, + const typename Container::value_type& value) { + return std::find(container.begin(), container.end(), value) != + container.end(); +} } -#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_HELPERS_H +#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_HELPERS_H diff --git a/src/components/utils/include/utils/log_message_loop_thread.h b/src/components/utils/include/utils/log_message_loop_thread.h index 80816877b6..deea1a07c0 100644 --- a/src/components/utils/include/utils/log_message_loop_thread.h +++ b/src/components/utils/include/utils/log_message_loop_thread.h @@ -53,21 +53,20 @@ typedef struct { typedef std::queue<LogMessage> LogMessageQueue; -typedef threads::MessageLoopThread<LogMessageQueue> LogMessageLoopThreadTemplate; +typedef threads::MessageLoopThread<LogMessageQueue> + LogMessageLoopThreadTemplate; class LogMessageHandler : public LogMessageLoopThreadTemplate::Handler { public: virtual void Handle(const LogMessage message) OVERRIDE; }; -class LogMessageLoopThread : - public LogMessageLoopThreadTemplate { - +class LogMessageLoopThread : public LogMessageLoopThreadTemplate { public: LogMessageLoopThread(); - ~LogMessageLoopThread(); + ~LogMessageLoopThread(); -DISALLOW_COPY_AND_ASSIGN(LogMessageLoopThread); + DISALLOW_COPY_AND_ASSIGN(LogMessageLoopThread); }; } // namespace logger diff --git a/src/components/utils/include/utils/qdb_wrapper/sql_database.h b/src/components/utils/include/utils/qdb_wrapper/sql_database.h index 54c89f678c..ba5c8a722a 100644 --- a/src/components/utils/include/utils/qdb_wrapper/sql_database.h +++ b/src/components/utils/include/utils/qdb_wrapper/sql_database.h @@ -90,6 +90,7 @@ class SQLDatabase { * Call backup for opened DB */ bool Backup(); + protected: /** * Gets connection to the SQLite database diff --git a/src/components/utils/include/utils/qdb_wrapper/sql_error.h b/src/components/utils/include/utils/qdb_wrapper/sql_error.h index 79706cc0ef..25fd558308 100644 --- a/src/components/utils/include/utils/qdb_wrapper/sql_error.h +++ b/src/components/utils/include/utils/qdb_wrapper/sql_error.h @@ -39,8 +39,8 @@ namespace utils { namespace dbms { typedef enum Error { - OK = 0, /* Successful result */ - ERROR /* Error */ + OK = 0, /* Successful result */ + ERROR /* Error */ } Error; /** diff --git a/src/components/utils/include/utils/qdb_wrapper/sql_query.h b/src/components/utils/include/utils/qdb_wrapper/sql_query.h index 34fbfc61c7..f1da6ccad9 100644 --- a/src/components/utils/include/utils/qdb_wrapper/sql_query.h +++ b/src/components/utils/include/utils/qdb_wrapper/sql_query.h @@ -238,7 +238,7 @@ class SQLQuery { /** * The result of query */ - qdb_result_t *result_; + qdb_result_t* result_; /** * The current row in result for select diff --git a/src/components/utils/include/utils/resource_usage.h b/src/components/utils/include/utils/resource_usage.h index ff90b2c22f..4dd8a7eafd 100644 --- a/src/components/utils/include/utils/resource_usage.h +++ b/src/components/utils/include/utils/resource_usage.h @@ -44,8 +44,8 @@ #include "utils/logger.h" -#define MAX_COMM_LEN 128 -#define MAX_CMDLINE_LEN 128 +#define MAX_COMM_LEN 128 +#define MAX_CMDLINE_LEN 128 namespace utils { @@ -56,7 +56,7 @@ struct ResourseUsage { }; class Resources { - public: + public: typedef uint32_t MemInfo; #if defined(__QNXNTO__) typedef procfs_info PidStats; @@ -108,19 +108,18 @@ class Resources { unsigned long long delayacct_blkio_ticks; unsigned long guest_time; long int cguest_time; - }; + }; #else #endif - public: - /* - * @brief Returns current resource usage of process - * @return Raw pointer on ResourseUsage if success, otherwise return NULL - */ + public: + /* + * @brief Returns current resource usage of process + * @return Raw pointer on ResourseUsage if success, otherwise return NULL + */ static ResourseUsage* getCurrentResourseUsage(); -private: - + private: #ifdef BUILD_TESTS friend class ResourceUsagePrivateTest; FRIEND_TEST(ResourceUsagePrivateTest, ReadStatFileTest); @@ -134,7 +133,8 @@ private: /* * @brief reads /proc/PID/stat file on linux * do not work on QNX ( return false, output wan't be changed ) - * @param output - storage for result string ( there will be separated content of /proc/PID/stat ) + * @param output - storage for result string ( there will be separated content + * of /proc/PID/stat ) * @return true on succes false onb fail */ static bool ReadStatFile(std::string& output); @@ -171,9 +171,6 @@ private: */ static const char* proc; }; - } - - #endif /* SRC_COMPONENTS_UTILS_INCLUDE_UTILS_RESOURCE_USAGE_H_ */ diff --git a/src/components/utils/include/utils/signals.h b/src/components/utils/include/utils/signals.h index b8b71b95e3..48120d53cd 100644 --- a/src/components/utils/include/utils/signals.h +++ b/src/components/utils/include/utils/signals.h @@ -34,7 +34,7 @@ #define SRC_COMPONENTS_UTILS_INCLUDE_UTILS_SIGNALS_H_ #ifdef __QNXNTO__ -typedef void (*sighandler_t) (int); +typedef void (*sighandler_t)(int); #else #include <signal.h> #endif diff --git a/src/components/utils/include/utils/singleton.h b/src/components/utils/include/utils/singleton.h index fff7294d1c..b73780ee1d 100644 --- a/src/components/utils/include/utils/singleton.h +++ b/src/components/utils/include/utils/singleton.h @@ -43,15 +43,13 @@ namespace deleters { class DummyDeleter { public: - void grab(void* pointer) { - } + void grab(void* pointer) {} }; -template<typename T> +template <typename T> class Deleter { public: - Deleter() : pointer_(0) { - } + Deleter() : pointer_(0) {} ~Deleter() { if (pointer_) { delete pointer_; @@ -60,69 +58,68 @@ class Deleter { void grab(T* pointer) { pointer_ = pointer; } + private: T* pointer_; }; } // namespace deleters -template<typename T, class Deleter = deleters::DummyDeleter> +template <typename T, class Deleter = deleters::DummyDeleter> class Singleton { -/** - * @brief Singleton template - * Singleton classes must derive from this template specialized with class itself: - * - * class MySingleton : public Singleton<MySingleton> {...}; - * - * All such classes must declare instance() method as friend - * by adding FRIEND_BASE_SINGLETON_CLASS macro from macro.h to class definition: - * - * FRIEND_BASE_SINGLETON_CLASS(MySingleton); - * - * Instance of this class (if created) can be deleted by Deleter destructor - * which is called after main() (or from exit()) - * This requires T destructor to be accessible for Deleter (e.g. public) - * Deleter template parameter can be specified with any class - * with public default constructor, destructor and method - * void grab(T*); - * However, default Deleter specification does nothing - * - * Also instance can be deleted explicitly by calling destroy() method - * - * Both instance() and destroy() methods are thread safe - * but not thread safety between simultaneous calls - * of instance() and destroy() is cared about - */ + /** + * @brief Singleton template + * Singleton classes must derive from this template specialized with class + *itself: + * + * class MySingleton : public Singleton<MySingleton> {...}; + * + * All such classes must declare instance() method as friend + * by adding FRIEND_BASE_SINGLETON_CLASS macro from macro.h to class + *definition: + * + * FRIEND_BASE_SINGLETON_CLASS(MySingleton); + * + * Instance of this class (if created) can be deleted by Deleter destructor + * which is called after main() (or from exit()) + * This requires T destructor to be accessible for Deleter (e.g. public) + * Deleter template parameter can be specified with any class + * with public default constructor, destructor and method + * void grab(T*); + * However, default Deleter specification does nothing + * + * Also instance can be deleted explicitly by calling destroy() method + * + * Both instance() and destroy() methods are thread safe + * but not thread safety between simultaneous calls + * of instance() and destroy() is cared about + */ public: -/** - * @brief Returns the singleton of class - */ + /** + * @brief Returns the singleton of class + */ static T* instance(); -/** - * @brief Destroys the singleton (if it had been created) - */ + /** + * @brief Destroys the singleton (if it had been created) + */ static void destroy(); -/** - * @brief Checks whether the singleton exists - */ + /** + * @brief Checks whether the singleton exists + */ static bool exists(); private: - static T** instance_pointer(); static Deleter* deleter(); static sync_primitives::Lock lock_; }; - -template<typename T, class Deleter> +template <typename T, class Deleter> sync_primitives::Lock Singleton<T, Deleter>::lock_; - -template<typename T, class Deleter> +template <typename T, class Deleter> T* Singleton<T, Deleter>::instance() { - T* local_instance; atomic_pointer_assign(local_instance, *instance_pointer()); memory_barrier(); @@ -142,9 +139,8 @@ T* Singleton<T, Deleter>::instance() { return local_instance; } -template<typename T, class Deleter> +template <typename T, class Deleter> void Singleton<T, Deleter>::destroy() { - T* local_instance; atomic_pointer_assign(local_instance, *instance_pointer()); memory_barrier(); @@ -162,18 +158,18 @@ void Singleton<T, Deleter>::destroy() { } } -template<typename T, class Deleter> +template <typename T, class Deleter> bool Singleton<T, Deleter>::exists() { return *instance_pointer() != 0; } -template<typename T, class Deleter> +template <typename T, class Deleter> T** Singleton<T, Deleter>::instance_pointer() { static T* instance = 0; return &instance; } -template<typename T, class Deleter> +template <typename T, class Deleter> Deleter* Singleton<T, Deleter>::deleter() { static Deleter deleter; return &deleter; diff --git a/src/components/utils/include/utils/sqlite_wrapper/sql_error.h b/src/components/utils/include/utils/sqlite_wrapper/sql_error.h index 70e73820f8..8a53e12169 100644 --- a/src/components/utils/include/utils/sqlite_wrapper/sql_error.h +++ b/src/components/utils/include/utils/sqlite_wrapper/sql_error.h @@ -39,37 +39,37 @@ namespace utils { namespace dbms { typedef enum Error { - OK = 0, /* Successful result */ - ERROR, /* SQL error or missing database */ - INTERNAL, /* Internal logic error in SQLite */ - PERM, /* Access permission denied */ - ABORT, /* Callback routine requested an abort */ - BUSY, /* The database file is locked */ - LOCKED, /* A table in the database is locked */ - NOMEM, /* A malloc() failed */ - READONLY, /* Attempt to write a readonly database */ - INTERRUPT, /* Operation terminated by sqlite3_interrupt()*/ - IOERR, /* Some kind of disk I/O error occurred */ - CORRUPT, /* The database disk image is malformed */ - NOTFOUND, /* Unknown opcode in sqlite3_file_control() */ - FULL, /* Insertion failed because database is full */ - CANTOPEN, /* Unable to open the database file */ - PROTOCOL, /* Database lock protocol error */ - EMPTY, /* Database is empty */ - SCHEMA, /* The database schema changed */ - TOOBIG, /* String or BLOB exceeds size limit */ - CONSTRAINT, /* Abort due to constraint violation */ - MISMATCH, /* Data type mismatch */ - MISUSE, /* Library used incorrectly */ - NOLFS, /* Uses OS features not supported on host */ - AUTH, /* Authorization denied */ - FORMAT, /* Auxiliary database format error */ - RANGE, /* 2nd parameter to sqlite3_bind out of range */ - NOTADB, /* File opened that is not a database file */ - NOTICE, /* Notifications from sqlite3_log() */ - WARNING, /* Warnings from sqlite3_log() */ - ROW = 100, /* sqlite3_step() has another row ready */ - DONE = 101 /* sqlite3_step() has finished executing */ + OK = 0, /* Successful result */ + ERROR, /* SQL error or missing database */ + INTERNAL, /* Internal logic error in SQLite */ + PERM, /* Access permission denied */ + ABORT, /* Callback routine requested an abort */ + BUSY, /* The database file is locked */ + LOCKED, /* A table in the database is locked */ + NOMEM, /* A malloc() failed */ + READONLY, /* Attempt to write a readonly database */ + INTERRUPT, /* Operation terminated by sqlite3_interrupt()*/ + IOERR, /* Some kind of disk I/O error occurred */ + CORRUPT, /* The database disk image is malformed */ + NOTFOUND, /* Unknown opcode in sqlite3_file_control() */ + FULL, /* Insertion failed because database is full */ + CANTOPEN, /* Unable to open the database file */ + PROTOCOL, /* Database lock protocol error */ + EMPTY, /* Database is empty */ + SCHEMA, /* The database schema changed */ + TOOBIG, /* String or BLOB exceeds size limit */ + CONSTRAINT, /* Abort due to constraint violation */ + MISMATCH, /* Data type mismatch */ + MISUSE, /* Library used incorrectly */ + NOLFS, /* Uses OS features not supported on host */ + AUTH, /* Authorization denied */ + FORMAT, /* Auxiliary database format error */ + RANGE, /* 2nd parameter to sqlite3_bind out of range */ + NOTADB, /* File opened that is not a database file */ + NOTICE, /* Notifications from sqlite3_log() */ + WARNING, /* Warnings from sqlite3_log() */ + ROW = 100, /* sqlite3_step() has another row ready */ + DONE = 101 /* sqlite3_step() has finished executing */ } Error; /** diff --git a/src/components/utils/include/utils/stl_utils.h b/src/components/utils/include/utils/stl_utils.h index 70fbadbd5e..4a4e3d2fe8 100644 --- a/src/components/utils/include/utils/stl_utils.h +++ b/src/components/utils/include/utils/stl_utils.h @@ -40,45 +40,48 @@ namespace utils { * Utility class that automatically deletes STL collection of * freestore objects */ -template<class T> +template <class T> class StlCollectionDeleter { public: typedef T Collection; - StlCollectionDeleter(T* collection) - : collection_(collection) { + StlCollectionDeleter(T* collection) : collection_(collection) { DCHECK(collection_); } ~StlCollectionDeleter() { - for (typename Collection::iterator i = collection_->begin(), end = - collection_->end(); i != end; ++i) { + for (typename Collection::iterator i = collection_->begin(), + end = collection_->end(); + i != end; + ++i) { delete *i; *i = NULL; } } + private: Collection* collection_; }; -template<class T> +template <class T> class StlMapDeleter { public: typedef T Collection; - StlMapDeleter(T* collection) - : collection_(collection) { + StlMapDeleter(T* collection) : collection_(collection) { DCHECK(collection_); } ~StlMapDeleter() { - for (typename Collection::iterator i = collection_->begin(), end = - collection_->end(); i != end; ++i) { + for (typename Collection::iterator i = collection_->begin(), + end = collection_->end(); + i != end; + ++i) { delete i->second; i->second = NULL; } - } + private: Collection* collection_; }; } // namespace utils -#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_STL_UTILS_H_ +#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_STL_UTILS_H_ diff --git a/src/components/utils/include/utils/threads/pulse_thread_delegate.h b/src/components/utils/include/utils/threads/pulse_thread_delegate.h index 207b64caaf..623e12b261 100644 --- a/src/components/utils/include/utils/threads/pulse_thread_delegate.h +++ b/src/components/utils/include/utils/threads/pulse_thread_delegate.h @@ -42,9 +42,11 @@ namespace threads { /** * @brief This ThreadDelegate derivative is designed * to implement threads waiting for QNX Pulse messages - * When constucted, an instance of this class creates QNX channel and connects to it + * When constucted, an instance of this class creates QNX channel and connects + * to it * In exitThreadMain() channel is disconnected and destroyed - * In threadMain() endless loop event is armed via pure virtual method ArmEvent() + * In threadMain() endless loop event is armed via pure virtual method + * ArmEvent() * and thread blocks on MsgReceivePulse() waiting for Pulse * When Pulse comes, OnPulse() pure virtual method is invoked * Subclassed must implement ArmEvent() for events of interest @@ -52,39 +54,42 @@ namespace threads { */ class PulseThreadDelegate : public ThreadDelegate { public: -/** - * @brief default constructor - */ + /** + * @brief default constructor + */ PulseThreadDelegate(); virtual void threadMain(); virtual void exitThreadMain(); protected: -/** - * @brief This method is to be implemented to arm events of interest - * @param event pointer to structure sigevent - * @return If this method returns true, thread is blocked on MsgReceivePulse() waiting for Pulse - */ + /** + * @brief This method is to be implemented to arm events of interest + * @param event pointer to structure sigevent + * @return If this method returns true, thread is blocked on + * MsgReceivePulse() waiting for Pulse + */ virtual bool ArmEvent(struct sigevent* event) = 0; -/** - * @brief This method is invoked from threadMain() when Pulse comes - */ + /** + * @brief This method is invoked from threadMain() when Pulse comes + */ virtual void OnPulse() = 0; /** * This method is to be initialize child class * @return If this method returns false, thread will be stopped */ - virtual bool Init() { return true; } + virtual bool Init() { + return true; + } -/** - * Finalizes thread - * Can free resources - */ + /** + * Finalizes thread + * Can free resources + */ virtual void Finalize() {} private: - enum {PULSE_CODE = _PULSE_CODE_MINAVAIL + 1}; + enum { PULSE_CODE = _PULSE_CODE_MINAVAIL + 1 }; volatile bool run_; int chid_; diff --git a/src/components/utils/include/utils/threads/thread_manager.h b/src/components/utils/include/utils/threads/thread_manager.h index d72abb428f..3f53c902c4 100644 --- a/src/components/utils/include/utils/threads/thread_manager.h +++ b/src/components/utils/include/utils/threads/thread_manager.h @@ -51,7 +51,7 @@ #include "utils/threads/thread_delegate.h" namespace threads { - class Thread; +class Thread; /* * This class is here currently to remember names associated to threads. @@ -69,12 +69,13 @@ class ThreadManager : public utils::Singleton<ThreadManager> { }; ThreadManager() {} MessageQueue<ThreadDesc> threads_to_terminate; + private: DISALLOW_COPY_AND_ASSIGN(ThreadManager); FRIEND_BASE_SINGLETON_CLASS(ThreadManager); }; -} // namespace threads +} // namespace threads -#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_THREADS_THREAD_MANAGER_H_ +#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_THREADS_THREAD_MANAGER_H_ diff --git a/src/components/utils/include/utils/threads/thread_validator.h b/src/components/utils/include/utils/threads/thread_validator.h index dc2d138e2e..2e7dac02ab 100644 --- a/src/components/utils/include/utils/threads/thread_validator.h +++ b/src/components/utils/include/utils/threads/thread_validator.h @@ -68,11 +68,11 @@ class SingleThreadSimpleValidator { // of classes being checked for absence of concurrent access void AssertRunningOnCreationThread() const; PlatformThreadHandle creation_thread_id() const; + private: const PlatformThreadHandle creation_thread_id_; }; - /* * This is bit more sophisticated debug helper which allows * objects being checked to be transferred between threads. @@ -97,10 +97,11 @@ class SingleThreadValidator { // of classes being checked for absence of unintended concurrent // access void AssertRunningOnValidThread() const; + private: mutable PlatformThreadHandle owning_thread_id_; }; -} // namespace threads +} // namespace threads -#endif // SRC_COMPONENTS_UTILS_INCLUDE_THREADS_THREAD_VALIDATOR_H_ +#endif // SRC_COMPONENTS_UTILS_INCLUDE_THREADS_THREAD_VALIDATOR_H_ diff --git a/src/components/utils/include/utils/timer.h b/src/components/utils/include/utils/timer.h index 69b2d08a4d..837e7ed598 100644 --- a/src/components/utils/include/utils/timer.h +++ b/src/components/utils/include/utils/timer.h @@ -65,7 +65,7 @@ class Timer { * Stops timer if it's running */ ~Timer(); - + /** * @brief Starts timer with specified timeout * @param timeout Timer timeout |