2ec6360b159112eab55a6a4fe4d64f6c0d6b5ddd
[platform/framework/native/appfw.git] / inc / FBaseColAllElementsDeleter.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file                FBaseColAllElementsDeleter.h
19  * @brief               This is the header file for the %AllElementsDeleter struct.
20  *
21  * This header file contains the declarations of the %AllElementsDeleter struct.
22  */
23
24 #ifndef _FBASE_COL_ALL_ELEMENTS_DELETER_H_
25 #define _FBASE_COL_ALL_ELEMENTS_DELETER_H_
26
27 namespace Tizen { namespace Base { namespace Collection
28 {
29 /**
30  * @struct      AllElementsDeleter
31  * @brief       This function object provides a resource clean-up function for collection.
32  *
33  * The %AllElementsDeleter struct provides a resource clean-up function for collection. This can be used with unique_ptr as a custom deleter.
34  *
35  * @since 2.0
36  */
37 struct AllElementsDeleter
38 {
39         /**
40          * Deletes every element of the collection and the collection itself.
41          *
42          * @since 2.0
43          *
44          * @param[in] c         The collection to clean up
45          * @remarks             The collection should be destructible and support the RemoveAll(bool) method.
46          *                      IList, IMap, and IMultiMap support this concept.
47          */
48         template< typename Collection >
49         void operator ()(Collection* c)
50         {
51                 c->RemoveAll(true);
52                 delete c;
53         }
54 };
55 }}}
56
57 #endif // _FBASE_COL_ALL_ELEMENTS_DELETER_H_