From db1716262caad3f8472ef48e99099d478373acd7 Mon Sep 17 00:00:00 2001 From: lucapegolotti Date: Fri, 29 Apr 2016 15:28:53 +0200 Subject: [PATCH] containers_cpp: fix cpplint warnings --- containers_cpp/include/embb/containers/blocking_map.h | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------- containers_cpp/include/embb/containers/blocking_priority_queue.h | 26 ++++++++++++++------------ containers_cpp/include/embb/containers/blocking_queue.h | 9 ++++----- containers_cpp/include/embb/containers/blocking_set.h | 5 ++--- containers_cpp/include/embb/containers/blocking_stack.h | 7 +++---- containers_cpp/include/embb/containers/internal/blocking_map-inl.h | 10 ++++++---- containers_cpp/include/embb/containers/internal/blocking_priority_queue-inl.h | 9 +++++---- containers_cpp/include/embb/containers/internal/blocking_push_and_pop_container.h | 13 +++++-------- containers_cpp/include/embb/containers/internal/blocking_set-inl.h | 12 ++++++------ 9 files changed, 97 insertions(+), 99 deletions(-) diff --git a/containers_cpp/include/embb/containers/blocking_map.h b/containers_cpp/include/embb/containers/blocking_map.h index 4f6ed95..dc9801a 100755 --- a/containers_cpp/include/embb/containers/blocking_map.h +++ b/containers_cpp/include/embb/containers/blocking_map.h @@ -45,72 +45,71 @@ class BlockingMap { typedef embb::base::LockGuard<> LockGuard; private: - /** - * Internal map from the standard library. - */ - std::map internalMap; + /** + * Internal map from the standard library. + */ + std::map internalMap; - /** - * Mutex for synchronizing concurrent accesses to the structure. - */ - Mutex mutex; + /** + * Mutex for synchronizing concurrent accesses to the structure. + */ + Mutex mutex; public: - /** - * Creates an empty map. - */ - BlockingMap(); - - /** - * Inserts a new element (key,value) in the map, if no elements - * with the same key already exists. - * - * \return \c true if the inserting succeeded, - * \c false otherwise. - */ - bool Insert( - const Key& key, - /**< [IN] Constant reference to key of the element to insert*/ - const Value& value - /**< [IN] Constant reference to value of the element to insert*/ - ); - - /** - * Erases the element with the specified key, if such an element exists. - * - * \return \c true if erasing was successfull, \c false otherwise. - */ - bool Erase( - const Key& key - /**< [IN] Constant reference to the key of the element to erase*/); + /** + * Creates an empty map. + */ + BlockingMap(); + + /** + * Inserts a new element (key,value) in the map, if no elements + * with the same key already exists. + * + * \return \c true if the inserting succeeded, + * \c false otherwise. + */ + bool Insert( + const Key& key, + /**< [IN] Constant reference to key of the element to insert*/ + const Value& value + /**< [IN] Constant reference to value of the element to insert*/ + ); + + /** + * Erases the element with the specified key, if such an element exists. + * + * \return \c true if erasing was successfull, \c false otherwise. + */ + bool Erase( + const Key& key + /**< [IN] Constant reference to the key of the element to erase*/); - /* - * Checks if the map contains an element with the specified key. - * - * \return \c true if the the map contains the element, \c false - * otherwise - */ - bool Contains( - const Key& key - /**< [IN] Constant reference to key of the element - to search for*/); + /* + * Checks if the map contains an element with the specified key. + * + * \return \c true if the the map contains the element, \c false + * otherwise + */ + bool Contains( + const Key& key + /**< [IN] Constant reference to key of the element + to search for*/); - /** + /** * Accesses the element with the specified key, if such an element exists. * If it does not exists, creates an element with the specified key. * * \return Reference to the value with the specified key. */ - Value& operator[]( - const Key& key - /**< [IN] Constant reference to key of the element to access*/); - + Value& operator[]( + const Key& key + /**< [IN] Constant reference to key of the element to access*/); }; -} -} +} // namespace containers +} // namespace embb #include -#endif // EMBB_CONTAINERS_BLOCKING_MAP_H_ +#endif // EMBB_CONTAINERS_BLOCKING_MAP_H_ diff --git a/containers_cpp/include/embb/containers/blocking_priority_queue.h b/containers_cpp/include/embb/containers/blocking_priority_queue.h index a6f1a95..d462ca3 100755 --- a/containers_cpp/include/embb/containers/blocking_priority_queue.h +++ b/containers_cpp/include/embb/containers/blocking_priority_queue.h @@ -23,16 +23,18 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ - + #ifndef EMBB_CONTAINERS_BLOCKING_PRIORITY_QUEUE_H_ #define EMBB_CONTAINERS_BLOCKING_PRIORITY_QUEUE_H_ - -#include + #include - +#include +#include +#include + namespace embb { namespace containers { - + /** * Blocking priority queue. * @@ -48,15 +50,15 @@ namespace containers { * which determines what element will be * dequeued next. */ -template< typename Type, - class Container = std::vector, +template< typename Type, + class Container = std::vector, class Compare = std::less> class BlockingPriorityQueue : public BlockingPushAndPopContainer { private: /** * Internal priority_queue from the standard library. */ - std::priority_queue internalQueue; + std::priority_queue internalQueue; /** * Wrapper for the push method in the standard priority_queue. @@ -86,15 +88,15 @@ class BlockingPriorityQueue : public BlockingPushAndPopContainer { void Enqueue( const Type& element /**< [IN] Constant reference to element to enqueue*/); - + void Dequeue( Type& element /**< [IN] Reference to dequeued element*/); }; - -} // namespace containers + +} // namespace containers } // namespace embb #include -#endif // EMBB_CONTAINERS_BLOCKING_PRIORITY_QUEUE \ No newline at end of file +#endif // EMBB_CONTAINERS_BLOCKING_PRIORITY_QUEUE_H_ diff --git a/containers_cpp/include/embb/containers/blocking_queue.h b/containers_cpp/include/embb/containers/blocking_queue.h index 6beb436..7e50da0 100755 --- a/containers_cpp/include/embb/containers/blocking_queue.h +++ b/containers_cpp/include/embb/containers/blocking_queue.h @@ -27,8 +27,8 @@ #ifndef EMBB_CONTAINERS_BLOCKING_QUEUE_H_ #define EMBB_CONTAINERS_BLOCKING_QUEUE_H_ -#include #include +#include namespace embb { namespace containers { @@ -58,7 +58,7 @@ class BlockingQueue : public BlockingPushAndPopContainer { * in the super class. */ void SpecializedPush(const Type& element); - + /** * Wrapper for pop_front method in the standard library queue. * Implements the corresponding pure virtual method @@ -90,12 +90,11 @@ class BlockingQueue : public BlockingPushAndPopContainer { void Dequeue( Type& element /**< [IN, OUT] Reference to dequeued element*/); - }; - + } // namespace containers } // namespace embb #include -#endif // EMBB_CONTAINERS_BLOCKING_QUEUE_H_ \ No newline at end of file +#endif // EMBB_CONTAINERS_BLOCKING_QUEUE_H_ diff --git a/containers_cpp/include/embb/containers/blocking_set.h b/containers_cpp/include/embb/containers/blocking_set.h index cdf8c5e..34d5122 100755 --- a/containers_cpp/include/embb/containers/blocking_set.h +++ b/containers_cpp/include/embb/containers/blocking_set.h @@ -92,11 +92,10 @@ class BlockingSet { bool Contains( const Type& element /**< [IN] Reference to the element to search for. */); - }; -} -} +} // namespace containers +} // namespace embb #include diff --git a/containers_cpp/include/embb/containers/blocking_stack.h b/containers_cpp/include/embb/containers/blocking_stack.h index c644cd4..6861458 100755 --- a/containers_cpp/include/embb/containers/blocking_stack.h +++ b/containers_cpp/include/embb/containers/blocking_stack.h @@ -27,8 +27,8 @@ #ifndef EMBB_CONTAINERS_BLOCKING_STACK_H_ #define EMBB_CONTAINERS_BLOCKING_STACK_H_ -#include #include +#include namespace embb { namespace containers { @@ -86,12 +86,11 @@ class BlockingStack : public BlockingPushAndPopContainer { void Pop( Type& element /**< [IN, OUT] Reference to popped element*/); - }; - + } // namespace containers } // namespace embb #include -#endif // EMBB_CONTAINERS_BLOCKING_STACK_H_ \ No newline at end of file +#endif // EMBB_CONTAINERS_BLOCKING_STACK_H_ diff --git a/containers_cpp/include/embb/containers/internal/blocking_map-inl.h b/containers_cpp/include/embb/containers/internal/blocking_map-inl.h index b64d4b9..ba7350c 100755 --- a/containers_cpp/include/embb/containers/internal/blocking_map-inl.h +++ b/containers_cpp/include/embb/containers/internal/blocking_map-inl.h @@ -25,7 +25,9 @@ */ #ifndef EMBB_CONTAINERS_INTERNAL_BLOCKING_MAP_INL_H_ -#define EMBB_CONTAINERS_INTERNAL_BLOCKING_SET_INL_H_ +#define EMBB_CONTAINERS_INTERNAL_BLOCKING_MAP_INL_H_ + +#include namespace embb { namespace containers { @@ -58,7 +60,7 @@ V& BlockingMap::operator[](const K& key) { return internalMap[key]; } -} -} +} // namespace containers +} // namespace embb -#endif // EMBB_CONTAINERS_INTERNAL_BLOCKING_MAP_INL_H_ \ No newline at end of file +#endif // EMBB_CONTAINERS_INTERNAL_BLOCKING_MAP_INL_H_ diff --git a/containers_cpp/include/embb/containers/internal/blocking_priority_queue-inl.h b/containers_cpp/include/embb/containers/internal/blocking_priority_queue-inl.h index 7f4d682..b6f6ec2 100755 --- a/containers_cpp/include/embb/containers/internal/blocking_priority_queue-inl.h +++ b/containers_cpp/include/embb/containers/internal/blocking_priority_queue-inl.h @@ -31,7 +31,8 @@ namespace embb { namespace containers { template -void BlockingPriorityQueue::SpecializedPush(const T& element) { +void BlockingPriorityQueue::SpecializedPush( + const T& element) { internalQueue.push(element); } @@ -56,7 +57,7 @@ bool BlockingPriorityQueue::IsEmpty() { return internalQueue.empty(); } -} -} +} // namespace containers +} // namespace embb -#endif // EMBB_CONTAINERS_INTERNAL_BLOCKING_PRIORITY_QUEUE_INL_H_ \ No newline at end of file +#endif // EMBB_CONTAINERS_INTERNAL_BLOCKING_PRIORITY_QUEUE_INL_H_ diff --git a/containers_cpp/include/embb/containers/internal/blocking_push_and_pop_container.h b/containers_cpp/include/embb/containers/internal/blocking_push_and_pop_container.h index ab9c6da..2437877 100755 --- a/containers_cpp/include/embb/containers/internal/blocking_push_and_pop_container.h +++ b/containers_cpp/include/embb/containers/internal/blocking_push_and_pop_container.h @@ -33,15 +33,13 @@ namespace embb { namespace containers { -// Abstract class, provides a synchronization mechanism for +// Abstract class, provides a synchronization mechanism for // data structures that support push/pop-like methods (e.g. stacks, queues) template < typename Type > class BlockingPushAndPopContainer { - typedef embb::base::Mutex Mutex; protected: - Mutex mutex; embb::base::ConditionVariable condition; @@ -60,7 +58,7 @@ class BlockingPushAndPopContainer { condition.NotifyOne(); } - void BlockingPop( Type & element) { + void BlockingPop(Type & element) { embb::base::UniqueLock lock(mutex); while (IsEmpty()) { @@ -69,10 +67,9 @@ class BlockingPushAndPopContainer { SpecializedPop(element); } - }; -} -} +} // namespace containers +} // namespace embb -#endif // EMBB_CONTAINERS_BLOCKING_PUSH_AND_POP_CONTAINER_ \ No newline at end of file +#endif // EMBB_CONTAINERS_BLOCKING_PUSH_AND_POP_CONTAINER_H_ diff --git a/containers_cpp/include/embb/containers/internal/blocking_set-inl.h b/containers_cpp/include/embb/containers/internal/blocking_set-inl.h index aa8843a..c4bbfae 100755 --- a/containers_cpp/include/embb/containers/internal/blocking_set-inl.h +++ b/containers_cpp/include/embb/containers/internal/blocking_set-inl.h @@ -35,24 +35,24 @@ BlockingSet::BlockingSet() : internalSet() {} template -bool BlockingSet::Insert(const T& element){ +bool BlockingSet::Insert(const T& element) { LockGuard lock(mutex); return internalSet.insert(element).second; } template -bool BlockingSet::Erase(const T& element){ +bool BlockingSet::Erase(const T& element) { LockGuard lock(mutex); return internalSet.erase(element) > 0; } template -bool BlockingSet::Contains(const T& element){ +bool BlockingSet::Contains(const T& element) { LockGuard lock(mutex); return internalSet.find(element) != internalSet.end(); } -} -} +} // namespace containers +} // namespace embb -#endif // EMBB_CONTAINERS_INTERNAL_BLOCKING_SET_INL_H_ \ No newline at end of file +#endif // EMBB_CONTAINERS_INTERNAL_BLOCKING_SET_INL_H_ -- libgit2 0.26.0