9dfb600b105d580a6a6fe2a3730ab4bb64ee9059
[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 #ifndef _FBASE_COL_ALL_ELEMENTS_DELETER_H_
24 #define _FBASE_COL_ALL_ELEMENTS_DELETER_H_
25
26 namespace Tizen { namespace Base { namespace Collection
27 {
28 /**
29  * @struct      AllElementsDeleter
30  * @brief       This function object provides a resource clean-up function for collection.
31  *
32  * The %AllElementsDeleter struct provides a resource clean-up function for collection. This can be used with unique_ptr as a custom deleter.
33  *
34  * @since 2.0
35  */
36 struct AllElementsDeleter
37 {
38         /**
39          * Deletes every element of the collection and the collection itself.
40          *
41          * @since 2.0
42          *
43          * @param[in] c         The collection to clean up
44          * @remarks                     The collection should be destructible and support the RemoveAll(bool) method.
45          *                                      IList, IMap, and IMultiMap support this concept.
46          */
47         template< typename Collection >
48         void operator ()(Collection* c)
49         {
50                 c->RemoveAll(true);
51                 delete c;
52         }
53 };
54 }}}
55
56 #endif // _FBASE_COL_ALL_ELEMENTS_DELETER_H_