Use modern construct 'using' instead of typedef.
[platform/core/uifw/dali-core.git] / dali / devel-api / common / owner-container.h
index 3ac0df2..c6be817 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_OWNER_CONTAINER_H__
-#define __DALI_OWNER_CONTAINER_H__
+#ifndef DALI_OWNER_CONTAINER_H
+#define DALI_OWNER_CONTAINER_H
 
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -42,10 +42,9 @@ template< class T >
 class OwnerContainer : public Dali::Vector< T >
 {
 public:
-
-  typedef typename Dali::Vector< T >::SizeType SizeType;
-  typedef typename Vector< T >::Iterator Iterator;
-  typedef typename Vector< T >::ConstIterator ConstIterator;
+  using SizeType      = typename Dali::Vector<T>::SizeType;
+  using Iterator      = typename Vector<T>::Iterator;
+  using ConstIterator = typename Vector<T>::ConstIterator;
 
   /**
    * Create a pointer-container.
@@ -62,6 +61,12 @@ public:
     VectorBase::Release();
   }
 
+  // Not copyable or movable
+  OwnerContainer( const OwnerContainer& ) = delete; ///< Deleted copy constructor
+  OwnerContainer( OwnerContainer&& ) = delete; ///< Deleted move constructor
+  OwnerContainer& operator=( const OwnerContainer& ) = delete; ///< Deleted copy assignment operator
+  OwnerContainer& operator=( OwnerContainer&& ) = delete; ///< Deleted move assignment operator
+
   /**
    * Test whether the container is empty.
    * @return True if the container is empty
@@ -83,6 +88,26 @@ public:
   }
 
   /**
+   * Erase an object from OwnerContainer
+   * @param object to remove
+   */
+  inline void EraseObject( T object )
+  {
+    DALI_ASSERT_DEBUG( object && "NULL object not allowed" );
+
+    Iterator iter = Vector< T >::Begin();
+    const ConstIterator endIter = Vector< T >::End();
+    for ( ; iter != endIter; ++iter )
+    {
+      if ( *iter == object )
+      {
+        Erase( iter );
+        return;
+      }
+    }
+  }
+
+  /**
    * Release the ownership of an object, without deleting it.
    * @param[in] position A dereferencable iterator to an element in mContainer.
    * @post iterators are invalidated by this method.
@@ -161,11 +186,6 @@ public:
 
 private:
 
-  // Undefined copy constructor.
-  OwnerContainer( const OwnerContainer& );
-  // Undefined assignment operator.
-  OwnerContainer& operator=( const OwnerContainer& );
-
   /**
    * @brief delete the contents of the pointer
    * Function provided to allow classes to provide a custom destructor through template specialisation
@@ -181,4 +201,4 @@ private:
 
 } // namespace Dali
 
-#endif //__DALI_OWNER_CONTAINER_H__
+#endif //DALI_OWNER_CONTAINER_H